[Python-ideas] Return False from __contains__ method if object not hashable for set and dict.
Now if do something like `[] in set()` python raise an exception, but if an object isn't hashable then we know for sure that it isn't in the set. Propose return False for these cases. What do you think? ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/NZZV5ZNN45TUZK2IZPWVFBZ54JTEGZ7W/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Re: Propouse add context to json module.
Chris Angelico wrote: > Why do you want dump and load to take parameters from "somewhere > else"? Because developers of libraries don't think about configuring json.dump method in mos of cases. I would like to have a mechanism that would allow tweaking the behaviour for the entire program. I just don't know how best to do it. The idea with the configuration via the context manager seems to me to be good. I know exactly what code will be patched and I can catch the bug. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/SVJ5Q4JSK3WVWZ63K4SQ7LB6GDNIYCEB/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Re: Propouse add context to json module.
The problem in this code lib.py ``` from json import dumps def some_func(): # do something res = dumps(...) # do something ``` If I patch dumps like you propose lib doesn't see any change. Also, it's all hacks. I wish dump and load themselves could take parameters from somewhere else, and that was the standard behaviour. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/BEV7LQOEA2MP27XFX2FE5DZO35ZEI6DC/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Re: Propouse add context to json module.
Chris Angelico wrote: > Not gonna be 100% reliable and I don't think it belongs in the stdlib, > but might be useful. That is the problem. Sometimes libs import only methods. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/OX42AD3UYPBOGSPLT5VHZPDR3DZZVRWD/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Re: Propouse add context to json module.
Maybe use context as a context manager. For example ``` with json.Context(ensure_ascii=False): json.dumps(...) ``` Implementation can be done via contextlib. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/XIGD3UXW3ZJR67NOBMQMYTVFK3PCYHHA/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Propouse add context to json module.
JSON serialization used in many different libraries without the ability for configuration (Example https://github.com/aio-libs/aioredis/blob/8a207609b7f8a33e74c7c8130d97186e78cc0052/aioredis/commands/pubsub.py#L18). Propose to add something like the context in the decimal module, wIch will contain all global configs for dump and load functions. Thanks! ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/FHQ3OL7TPMXHNFH3W6UKLTUQWNBBXHTJ/ Code of Conduct: http://python.org/psf/codeofconduct/
[Python-ideas] Add close method to queue
I have a problem with notifying all current subscribers and new subscribers about the closure of the queue and the reason. For example, I have a producer that reads messages from websocket or something else and send this to a queue, and several consumers (I do not know how many). If any exception occurred, then all current subscribers and subscribers which will be added later should know about this error. I tried to send an exception to a queue, but that did not help, because I have several consumers. Also, this will not protect new consumers. I propose to add a new close method with exc argument, which will throw an exception when calling the get method, and also throw an exception for all current _getters. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/EYVGOE5XUJPHKMDAGDHAXZ32VP6IAZL5/ Code of Conduct: http://python.org/psf/codeofconduct/