newbie question:

Aahz Maruch aahz at netcom.com
Mon Aug 7 18:08:42 EDT 2000


In article <ujGj5.3524$pu4.276151 at typhoon.ne.mediaone.net>,
Azratax <archicanis at yahoo.com> wrote:
>      i have made a simple module with a function (init() )  that opens a file 
>to an object. I imported this module and ran init() . Thought i get no error, 
>the fileobject is nowhere to be found. i have tried a dir() through every 
>module yet cant find any object with that name... what have i done wrong?
>the code is (code in c:\python16\azrand\itemgen.py):
>
>import whrandom
>import pickle
>import string
>def init():
>    mainlist = open('lists/main.txt') 

Try this:

In itemgen.py:

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

In your main script:

import itemgen
mainlist = itemgen.init()
--
                      --- Aahz (Copyright 2000 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

NOTE: end of September, Earthlink kills Netcom.  My new permanent address is 
aahz at pobox.com.  I have not decided where to set my primary shell account.
Please do not send me e-mail condolences; my mailbox is already too big.



More information about the Python-list mailing list