Re: Namespacedifference reading - writing ??

Discussion in 'Python' started by Duncan Booth, Jun 27, 2003.

  1. Duncan Booth

    Duncan Booth Guest

    (Peter Abel) wrote in
    news::

    > Is there really a difference in namespacehandling depending
    > on writing or reading variables?


    Yes, in most cases Python can determine at compile time whether you are
    referencing a local variable, a nested scope variable, or a global
    variable. The rules for this are quite simple:

    If a variable is listed in a global statement it is a global.
    Otherwise, if you assign to it, it is local.
    Otherwise, if there is a variable of the same name in a nested scope, it is
    a nested scope variable.
    Otherwise it is either global or builtin (which it is, is decided at
    runtime).


    --
    Duncan Booth
    int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
    "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
     
    Duncan Booth, Jun 27, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pieter Hulshoff
    Replies:
    0
    Views:
    1,068
    Pieter Hulshoff
    Aug 13, 2003
  2. Chris Pruett
    Replies:
    0
    Views:
    1,444
    Chris Pruett
    Aug 14, 2003
  3. Modukuri
    Replies:
    0
    Views:
    2,950
    Modukuri
    May 19, 2004
  4. HNguyen
    Replies:
    4
    Views:
    2,458
    HNguyen
    Dec 21, 2004
  5. Steven Taschuk
    Replies:
    0
    Views:
    673
    Steven Taschuk
    Jun 27, 2003
Loading...

Share This Page