Dictionary from a file

Sami Hangaslammi shang.remove_edu at st.jyu.fi.edu
Mon Jan 24 02:25:56 EST 2000


Peter Schopfer (aka Dr. J. - magician) <drj at mail.bulkley.net> wrote in
message news:388BF0C4.F0E08005 at mail.bulkley.net...
> Hello
>
> I have a dictionary that is too big to fit right in my program, so i
> was going to have it as a seperat file, labeled dic.py. how would i
be
> able to retrieve this dictionary. wuld this work:
>
> from dic.py import dictionary
> mydic=dic.dictionary

This works with a couple of changes. First, you omit the '.py'
extension in module names when importing them. Secondly, the 'from
module import stuff'-syntax inserts the 'stuff' into current module's
namespace, so you don't use the module name when referring to it. i.e.

from dic import dictionary
mydic = dictionary

--
Sami Hangaslammi
shang (at) st (dot) jyu (dot) fi





More information about the Python-list mailing list