"Karim" <karim.liat...@free.fr> wrote

>>> import params
>>> dir(params)
['EntryTextMail', 'EntryTextName', '__builtins__', '__doc__',

But the file to import should have '.py' extension (<Module>.py) (if there is a way to avoid that I wanted to use a 'hidden' file kind of ".config" ,

You can exec a file and you can read the file into a string as a variable then exec the string. BUT doing this is a huge security risk since anyone can put any kind of arbitrary code in your config file and you will blindly
execute it. That's why config files are generally not executable code
but some kind of data format - it's much safer and very little extra work.

At first I tried to access it as variables instead of using <Module>.variable. I learnt something here!

Any time you import a module you need to use the module name
to access its contents - or use the from moo import * format, but
that introduces even more risk!

I strongly recommend that you think again and use a data format
config file.

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to