]> granicus.if.org Git - python/commitdiff
Fix now-wrong :keyword: markup. Remove the section about
authorGeorg Brandl <georg@python.org>
Sun, 20 Jan 2008 11:22:21 +0000 (11:22 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 20 Jan 2008 11:22:21 +0000 (11:22 +0000)
"exec without namespace" from the "don't" howto since exec()
can't overwrite names in the calling namespace anymore.

Doc/howto/doanddont.rst
Doc/library/bdb.rst
Doc/tutorial/controlflow.rst

index 0e6b3e8d947c482e9a9087f4fcdb3fb1f5b0969d..9e8a052c7acee0f9c4ede4e57c61de08e3a926d1 100644 (file)
@@ -75,39 +75,6 @@ There are situations in which ``from module import *`` is just fine:
 * 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
 -------------------------------
 
index 36f83007f63db443fc960369e6c89198eca018f5..84ea0aeb9bc8837529b0c0309a8f0e6dec47efdb 100644 (file)
@@ -294,7 +294,7 @@ The following two methods can be called by clients to use a debugger to debug a
 
 .. 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]])
index 3fedb56bcb9d4bb9b10d72eebfdf8c998f9df17e..82a89772fc83fbae4ce7a5b62132898b298e8d69 100644 (file)
@@ -263,7 +263,7 @@ like in C, procedures are just functions that don't return a value.  In fact,
 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))