scope of variables

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Wed May 3 23:17:06 CEST 2006


In <874q06bz4c.fsf at localhost.localdomain>, 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 trying that code.
 Running this::

 b = 3
 def adding(a):
     print a + b

 adding(5)

Puts out 8 as expected.

Ciao,	
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list