[issue19789] Improve wording of how to "undo" a call to logging.disable(lvl)

2013-11-25 Thread Simon Weber

New submission from Simon Weber:

In http://bugs.python.org/issue14864, this line was added to the 
logging.disable docstring:

To undo the effect of a call to logging.disable(lvl), call 
logging.disable(logging.NOTSET).

To prevent misunderstanding, I propose that this line be changed to:

Calling logging.disable(logging.NOTSET) will undo all previous calls to 
logging.disable(lvl).


While the original change was an improvement, it's misleading. "undoing the 
effect of a call" reads as "undoing the effect of the last call", which implies 
a stack -- think of text editor "undo" functionality. In other words, the 
current documentation implies behavior like a context manager:

>>> import logging
# start with all logging enabled

>>> logging.disable(logging.CRITICAL)
# all logging disabled

>>> logging.disable(logging.WARNING)
# only CRITICAL enabled

>>> logging.disable(logging.NOTSET)
# undo; all logging disabled

>>> logging.disable(logging.NOTSET)
# undo; all logging enabled

Since logging.disable is idempotent, we're not undoing *a call*, we're undoing 
*all calls*.

--
assignee: docs@python
components: Documentation
messages: 204451
nosy: docs@python, eric.araujo, ezio.melotti, georg.brandl, simonmweber
priority: normal
severity: normal
status: open
title: Improve wording of how to "undo" a call to logging.disable(lvl)
type: enhancement

___
Python tracker 
<http://bugs.python.org/issue19789>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19789] Improve wording of how to "undo" a call to logging.disable(lvl)

2013-11-30 Thread Simon Weber

Simon Weber added the comment:

That sounds much clearer. Thanks!

--

___
Python tracker 
<http://bugs.python.org/issue19789>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22425] 2to3 import fixer writes dotted_as_names into import_as_names

2014-09-16 Thread Simon Weber

New submission from Simon Weber:

When dealing with implicit relative imports of the form "import 
 as...", the 2to3 import fixer will rewrite them as "from . 
import  as...".

This is invalid syntax. Here's an example:

$ tree package/
package/
├── __init__.py
├── rootmod.py
└── subpackage
├── __init__.py
└── mod.py

1 directory, 4 files

$ cat package/rootmod.py  # this is the only nonempty file
import subpackage.mod as my_name

$ python package/rootmod.py

$ 2to3 -w -f import package/
RefactoringTool: Refactored package/rootmod.py
--- package/rootmod.py  (original)
+++ package/rootmod.py  (refactored)
@@ -1 +1 @@
-import subpackage.mod as my_name
+from . import subpackage.mod as my_name
RefactoringTool: Files that were modified:
RefactoringTool: package/rootmod.py

$ python package/rootmod.py
  File "package/rootmod.py", line 1
from . import subpackage.mod as my_name
^
SyntaxError: invalid syntax

Probably the easiest way to rewrite this is "from .subpackage import mod as 
my_name".

--
components: 2to3 (2.x to 3.x conversion tool)
messages: 226965
nosy: simonmweber
priority: normal
severity: normal
status: open
title: 2to3 import fixer writes dotted_as_names into import_as_names
type: behavior
versions: Python 2.7, Python 3.4

___
Python tracker 
<http://bugs.python.org/issue22425>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com