[Python-3000-checkins] r60132 - in python/branches/py3k/Doc: howto/doanddont.rst library/bdb.rst tutorial/controlflow.rst
georg.brandl
python-3000-checkins at python.org
Sun Jan 20 12:22:21 CET 2008
Author: georg.brandl
Date: Sun Jan 20 12:22:21 2008
New Revision: 60132
Modified:
python/branches/py3k/Doc/howto/doanddont.rst
python/branches/py3k/Doc/library/bdb.rst
python/branches/py3k/Doc/tutorial/controlflow.rst
Log:
Fix now-wrong :keyword: markup. Remove the section about
"exec without namespace" from the "don't" howto since exec()
can't overwrite names in the calling namespace anymore.
Modified: python/branches/py3k/Doc/howto/doanddont.rst
==============================================================================
--- python/branches/py3k/Doc/howto/doanddont.rst (original)
+++ python/branches/py3k/Doc/howto/doanddont.rst Sun Jan 20 12:22:21 2008
@@ -75,39 +75,6 @@
* When the module advertises itself as ``from import *`` safe.
-Unadorned :keyword:`exec` and friends
--------------------------------------
-
-The word "unadorned" refers to the use without an explicit dictionary, in which
-case those constructs evaluate code in the *current* environment. This is
-dangerous for the same reasons ``from import *`` is dangerous --- it might step
-over variables you are counting on and mess up things for the rest of your code.
-Simply do not do that.
-
-Bad examples::
-
- >>> for name in sys.argv[1:]:
- >>> exec "%s=1" % name
- >>> def func(s, **kw):
- >>> for var, val in kw.items():
- >>> exec "s.%s=val" % var # invalid!
- >>> exec(open("handler.py").read())
- >>> handle()
-
-Good examples::
-
- >>> d = {}
- >>> for name in sys.argv[1:]:
- >>> d[name] = 1
- >>> def func(s, **kw):
- >>> for var, val in kw.items():
- >>> setattr(s, var, val)
- >>> d={}
- >>> exec(open("handle.py").read(), d, d)
- >>> handle = d['handle']
- >>> handle()
-
-
from module import name1, name2
-------------------------------
Modified: python/branches/py3k/Doc/library/bdb.rst
==============================================================================
--- python/branches/py3k/Doc/library/bdb.rst (original)
+++ python/branches/py3k/Doc/library/bdb.rst Sun Jan 20 12:22:21 2008
@@ -294,7 +294,7 @@
.. method:: Bdb.run(cmd, [globals, [locals]])
- Debug a statement executed via the :keyword:`exec` statement. *globals*
+ Debug a statement executed via the :func:`exec` function. *globals*
defaults to :attr:`__main__.__dict__`, *locals* defaults to *globals*.
.. method:: Bdb.runeval(expr, [globals, [locals]])
Modified: python/branches/py3k/Doc/tutorial/controlflow.rst
==============================================================================
--- python/branches/py3k/Doc/tutorial/controlflow.rst (original)
+++ python/branches/py3k/Doc/tutorial/controlflow.rst Sun Jan 20 12:22:21 2008
@@ -263,7 +263,7 @@
technically speaking, procedures do return a value, albeit a rather boring one.
This value is called ``None`` (it's a built-in name). Writing the value
``None`` is normally suppressed by the interpreter if it would be the only value
-written. You can see it if you really want to using :keyword:`print`::
+written. You can see it if you really want to using :func:`print`::
>>> fib(0)
>>> print(fib(0))
More information about the Python-3000-checkins
mailing list