On 2007-11-03, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Sat, 03 Nov 2007 17:30:45 -0000, Sullivan WxPyQtKinter
><[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
>
>> Actually I am quite satisfied with and error, which is my expectation.
>> But the implicit global variable access seems quite uncomfortable to
>> me. Why is that necessary?
>
>       Would you want to have to write things like:

Well it would be explicit and explicit is better than implicit.

> import os
> import os.path
> import sys
>
> def dFunc(more): 
>       return "The full path of the item is: %s" % more
>
> def aFunc(something):
>       global os.path
>       global sys
>       global dFunc
>       sys.stdout.write(dFunc(os.path.join("nonsense", something)))
>
>       Your "variable" follows the same logic used for name look ups of all
> items -- "read" access will, after exhausting the local scope, search
> the module level names (note that you don't need "global" to modify a
> mutable object in module level -- it is only the rebinding of the name
> itself that needs "global")

-- 
Antoon Pardon
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to