homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author posita
Recipients mark.dickinson, pitrou, posita, rhettinger, serhiy.storchaka, tim.peters, vstinner
Date 2021年09月23日.14:09:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1632406171.9.0.578525802857.issue40346@roundup.psfhosted.org>
In-reply-to
Content
I landed here after investigating this surprising result:
 # test_case.py
 from random import Random
 from typing import Sequence, Union
 
 _RandSeed = Union[None, int, Sequence[int]]
 
 class MyRandom(Random):
 def __init__(
 self,
 seed: _RandSeed = None,
 ):
 if seed is not None and not isinstance(seed, int):
 seed = sum(seed)
 super().__init__(seed)
 
 MyRandom([1, 2])
Output:
 python ./test_case.py
 Traceback (most recent call last):
 File "/..././test_case.py", line 16, in 
 <module>
 MyRandom([1, 2])
 TypeError: unhashable type: 'list'
In my observation, the Random class aspires to be an interface (and default implementation), but doesn't really live up to those aspirations. (See also https://github.com/python/typeshed/issues/6063.) I suspect nudging Random closer to its claims was the point of this proposal. I'm kind of sad it (or something like it) was rejected in favor of a process that will probably take years. Is there a reason not to do both, meaning heal what lives in the standard library now to live up to its own marketing *and* work toward a better interface in the future?
History
Date User Action Args
2021年09月23日 14:09:31positasetrecipients: + posita, tim.peters, rhettinger, mark.dickinson, pitrou, vstinner, serhiy.storchaka
2021年09月23日 14:09:31positasetmessageid: <1632406171.9.0.578525802857.issue40346@roundup.psfhosted.org>
2021年09月23日 14:09:31positalinkissue40346 messages
2021年09月23日 14:09:31positacreate

AltStyle によって変換されたページ (->オリジナル) /