A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-December/106760.html below:

[Python-Dev] Using logging in the stdlib and its unit tests

[Python-Dev] Using logging in the stdlib and its unit testsNick Coghlan ncoghlan at gmail.com
Mon Dec 13 05:27:21 CET 2010
On Mon, Dec 13, 2010 at 2:13 PM, Robert Kern <robert.kern at gmail.com> wrote:
>>> level = logging._levelNames[opt.logLevel]
>>
>> That doesn't work (_levelNames maps from integers to strings, we want
>> the mapping from strings to integers and it is only the module globals
>> that provides that).
>
> At least in Python 2.6, it maps both ways. But then again, it is an
> _implementation _detail that should not be relied upon in your programs.

Ah, you're quite right - I didn't notice that when looking at the
contents (the first entries happened to map levels to names)

> I
> would suggest that there should be two dictionaries as part of the
> documented API, one mapping numbers to names and one mapping names to
> numbers. Or functions/methods returning said dictionaries. Having the entire
> mappings at hand is more useful than having functions that do the
> translation. They would allow you to auto-generate UIs (e.g. the help text
> for a --log-level argument or a radio box widget in a GUI). Having separate
> mappings makes them easier to work with than the 2.6-style _levelNames
> mapping.

Definitely something worth considering for 3.3.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4