scope of variables

Lord Landon lordlandon at gmail.com
Thu May 4 00:59:16 CEST 2006


Try >>> prnt()
o.o'

On 04 May 2006 08:25:01 +1000, Gary Wessle <phddas at yahoo.com> wrote:
> "Steve R. Hastings" <steve at hastings.org> writes:
>
> > On Thu, 04 May 2006 07:02:43 +1000, Gary Wessle wrote:
> > > b = 3
> > > def adding(a)
> > >     print a + b
> > >
> > > it seams not to see the up-level scope where b is defined.
> >
> > Assuming you put a ':' after the "def adding(a)", this should work in
> > recent versions of Python.  In Python 2.0 and older, this will not work.
>
> 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"
> --
> http://mail.python.org/mailman/listinfo/python-list
>


--
Lord Landon rules over all!



More information about the Python-list mailing list