Re: scope of variables

2006-05-04 Thread Gary Wessle
thank you -- http://mail.python.org/mailman/listinfo/python-list

Re: scope of variables

2006-05-04 Thread bruno at modulix
Gary Wessle wrote: > Ryan Forsythe <[EMAIL PROTECTED]> writes: > > >>Gary Wessle wrote: >> >>>the example was an in-accuretlly representation of a the problem I am >>>having. my apologies. >>> (snip) > I finally was able to duplicate the error with a through away code > as follows, > >

Re: scope of variables

2006-05-04 Thread Gary Wessle
Ryan Forsythe <[EMAIL PROTECTED]> writes: > 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 > > > > > > I expect to get 0 "the length of list a" > > You wa

Re: scope of variables

2006-05-03 Thread Rob E
> is the code below correct? > > b = 3 > def adding(a) > print a + b > > it seams not to see the up-level scope where b is defined. Yes except for the missing : at the end of the "def" line. Rob -- http://mail.python.org/mailman/listinfo/python-list

Re: scope of variables

2006-05-03 Thread Ryan Forsythe
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 > > > I expect to get 0 "the length of list a" You want prnt(), not prnt: >>> a = [] >>> def prnt(): ... print len(a) ...

Re: scope of variables

2006-05-03 Thread Leif K-Brooks
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 > > > I expect to get 0 "the length of list a" Python requires parenthesis to call a function. >>> a = [] >>> def prnt(

Re: scope of variables

2006-05-03 Thread Lord Landon
Try >>> prnt() o.o' On 04 May 2006 08:25:01 +1000, Gary Wessle <[EMAIL PROTECTED]> wrote: > "Steve R. Hastings" <[EMAIL PROTECTED]> 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-leve

Re: scope of variables

2006-05-03 Thread Gary Wessle
"Steve R. Hastings" <[EMAIL PROTECTED]> 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 >

Re: scope of variables

2006-05-03 Thread Ben Finney
Gary Wessle <[EMAIL PROTECTED]> writes: > is the code below correct? It's best to post an example that you've tried yourself, and that is small but completely demonstrates the issue in question. > b = 3 > def adding(a) > print a + b This, for example, would fail the syntax check (the 'def'

Re: scope of variables

2006-05-03 Thread Steve R. Hastings
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

Re: scope of variables

2006-05-03 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Gary Wessle wrote: > is the code below correct? No... > b = 3 > def adding(a) ...a colon is missing at the end of the above line. > print a + b > > it seams not to see the up-level scope where b is defined. It does. And you could easily find out yourself by just