sharing vars with different functions
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Mon Oct 29 05:08:42 EDT 2007
On Mon, 29 Oct 2007 09:03:14 +0000, scripteaze at gmail.com wrote:
> Im tryin to call a var thats sitting in a function, example:
>
> class someclass(object):
> somevar = open(blah, 'r').readlines()
Thats a class variable. Is that really what you want!?
> def something():
>
> for line in somevar:
> print line
> -----------------------------------------------------------------------
>
> i guess im not graspng the whole global or local var topic..
There is no real global here. One is (somewhat) local to the class the
other local to the function.
> Any examples??
def something(lines):
for line in lines:
print lines
And the call it with the object.
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list