newbie question:

Alan Gauld alan.gauld at gssec.bt.co.uk
Tue Aug 8 11:31:03 EDT 2000


Reading your post again, I'll have another go ;-)

> import whrandom
> import pickle
> import string
> def init():
>     mainlist = open('lists/main.txt')

mainlist is local to init() and is therefore garbage collected
after init() runs.

Try:

def init()
    return open('lists/main.txt')

Although why you'd do that is beyond me, just call 
the open function directly... But maybe you really 
do more than you've shown us inside init()

Alan g.
-- 
=================================================
This post represents the views of the author 
and does not necessarily accurately represent 
the views of BT.



More information about the Python-list mailing list