Re: [Python-3000] The meaning of "global variable"

2006-11-06 Thread Nick Coghlan
Georg Brandl wrote: > Marcin 'Qrczak' Kowalczyk wrote: >> The rule should be: >> >> The keyword 'nonlocal' causes the lookup to be performed as if there >> were no assignments to that variable in the scope containing the >> 'nonlocal' declaration. > > Plus, if there's no binding in an enclosing sc

Re: [Python-3000] Draft PEP for outer scopes

2006-11-06 Thread Nick Coghlan
Andrew McNamara wrote: >> Python, C/C++, JavaScript, Ruby, and Perl all have this in common: >> >>A "global variable" is visible to the entire file and does >>not belong to any particular function. > > I note that you didn't say "a global variable is visible to the entire > application" -

Re: [Python-3000] Draft PEP for outer scopes

2006-11-06 Thread Michael Urman
>def weird(local=True): >if local: >n = 1 >else: >global n # [ or nonlocal n, in Nick's ] >n += 1 >return n I'm not sure what you're both trying to explain here. First off, the above code yields a SyntaxWarning. Secondly all its acc

Re: [Python-3000] Mini Path object

2006-11-06 Thread Josiah Carlson
Talin <[EMAIL PROTECTED]> wrote: > I'd like to replace this with: > > .component( slice_object ) > > where the semantics of 'component' are identical to __getitem__ on an > array or tuple. So for example: > > Path( "a", "b" ).component( 0 ) => "a" > Path( "a", "b" ).component( 1 )

Re: [Python-3000] Draft PEP for outer scopes

2006-11-06 Thread Josiah Carlson
"Michael Urman" <[EMAIL PROTECTED]> wrote: > I personally expect that while there is a theoretical clash between > variable names in nested scopes, that's already a poor coding > decision. The module level globals should not unintentionally collide > with function-local non-local access. Thus reus

Re: [Python-3000] Mini Path object

2006-11-06 Thread Talin
Josiah Carlson wrote: > Talin <[EMAIL PROTECTED]> wrote: >> I'd like to replace this with: >> >> .component( slice_object ) >> >> where the semantics of 'component' are identical to __getitem__ on an >> array or tuple. So for example: >> >> Path( "a", "b" ).component( 0 ) => "a" >> Pat

Re: [Python-3000] Draft PEP for outer scopes

2006-11-06 Thread Neil Toronto
Josiah Carlson wrote: >"Michael Urman" <[EMAIL PROTECTED]> wrote: > > >>I personally expect that while there is a theoretical clash between >>variable names in nested scopes, that's already a poor coding >>decision. The module level globals should not unintentionally collide >>with function-loca

Re: [Python-3000] Backward compatibility for "nonlocal"

2006-11-06 Thread Brett Cannon
On 11/5/06, Ka-Ping Yee <[EMAIL PROTECTED]> wrote: As an aside to the discussion about "nonlocal", here are a couple ofthoughts on backward compatibility.For some of the proposed keywords, here's the number of occurrencesof the keyword in the current standard library (not including comments and doc

Re: [Python-3000] Draft PEP for outer scopes

2006-11-06 Thread Nick Coghlan
Michael Urman wrote: >>def weird(local=True): >>if local: >>n = 1 >>else: >>global n # [ or nonlocal n, in Nick's ] >>n += 1 >>return n > > I'm not sure what you're both trying to explain here. First off, the > above code yields a S

Re: [Python-3000] Mini Path object

2006-11-06 Thread Mike Orr
My latest idea is something like this: BEGIN class Path(unicode): """Pathname-manipulation methods.""" pathlib = os.path # Subclass can specify (posix|nt|mac)path. safe_args_only = False# Glyph can set this to True in a subclass. class FSPath(object): """File

Re: [Python-3000] Mini Path object

2006-11-06 Thread Antoine Pitrou
Le lundi 06 novembre 2006 à 14:37 -0800, Mike Orr a écrit : > def __init__(klass, *args): > if len(args) == 1 and isinstance(args[0], klass.path_class): > self.path = args[0] > else: > self.path = self.path_class(*args) s/klass/self/, I suppose ? > Subc

Re: [Python-3000] Mini Path object

2006-11-06 Thread Ron Adam
> [Mike Orr wrote:] > In this vein, a common utility module with back-end functions would be > good. Then we can solve the difficult problems *once* and have a test > suite that proves it, and people would have confidence using any OO > classes that are built over them. We can start by gathering