scope of variables

Leif K-Brooks eurleif at ecritters.biz
Wed May 3 18:58:04 EDT 2006


Gary Wessle wrote:
> the example was an in-accuretlly representation of a the problem I am
> having. my apologies.
> 
> a = []
> def prnt():
>    print len(a)
> 
>>>> prnt
> <function prnt at 0xb7dc21b4>
> 
> I expect to get 0 "the length of list a"

Python requires parenthesis to call a function.

  >>> a = []
  >>> def prnt():
  ...     print len(a)
  ...
  >>> prnt
  <function prnt at 0xb7dcad84>
  >>> prnt()
  0



More information about the Python-list mailing list