Re: Configuring an object via a dictionary

2024-03-18 Thread Anders Munch via Python-list
dn wrote: >Loris Bennett wrote: >> However, with a view to asking forgiveness rather than >> permission, is there some simple way just to assign the dictionary >> elements which do in fact exist to self-variables? > >Assuming config is a dict: > > self.__dict__.update( config ) Here's

[issue44283] Add jump table for certain safe match-case statements

2021-06-07 Thread Anders Munch
Anders Munch added the comment: Are you sure you want to do this? This optimisation is not applicable if the matched values are given symbolic names. You would be encouraging people to write bad code with lots of literals, for speed. -- nosy: +AndersMunch

[issue43115] locale.getlocale fails if locale is set

2021-02-23 Thread Anders Munch
Anders Munch added the comment: >> What does use getlocale is time.strptime and datetime.datetime.strptime, so >> when getlocale fails, strptime fails. > Would they work with getlocale() returning None for the encoding ? Yes. All getlocale is used for in _strptime.py is comp

[issue43115] locale.getlocale fails if locale is set

2021-02-17 Thread Anders Munch
Anders Munch added the comment: > BTW: What is wxWidgets doing with the returned values ? wxWidgets doesn't call getlocale, it's a C++ library (wrapped by wxPython) that uses C setlocale. What does use getlocale is time.strptime and datetime.datetime.strptime, so when getlocale fa

[issue43115] locale.getlocale fails if locale is set

2021-02-17 Thread Anders Munch
Anders Munch added the comment: getlocale is documented to return None for the encoding if no encoding can be determined. There's no need to guess. I can't change the locale.setlocale call, because where I'm actually having the problem, I'm not even calling locale.setlocale: wxWidgets

[issue43115] locale.getlocale fails if locale is set

2021-02-17 Thread Anders Munch
Anders Munch added the comment: I discovered that this can happen with underscores as well: Python 3.8.7 (tags/v3.8.7:6503f05, Dec 21 2020, 17:59:51) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license"

[issue43115] locale.getlocale fails if locale is set

2021-02-03 Thread Anders Munch
New submission from Anders Munch : getlocale fails with an exception when the string returned by _setlocale is already an RFC 1766 language tag. Example: Python 3.10.0a4 (tags/v3.10.0a4:445f7f5, Jan 4 2021, 19:55:53) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyr

Re: Sorting NaNs

2018-06-11 Thread Anders Munch
Steven D'Aprano: It is not a guess if the user explicitly specifies that as the behaviour. If that was the context, sure, no problem. - Anders -- https://mail.python.org/mailman/listinfo/python-list

Re: Sorting NaNs

2018-06-10 Thread Anders Munch
Richard Damon wrote: The two behaviors that I have heard suggested are: 1) If any of the inputs are a NaN, the median should be a NaN. (Propagating the NaN as indicator of a numeric error) 2) Remove the NaNs from the input set and process what is left. If nothing, then return a NaN (treating