Some Newbie Questions
Larry Bates
lbates at swamisoft.com
Wed May 26 10:15:15 EDT 2004
On question #1: I see this question a lot on
this list, but I'm curious about why you don't
want to instantiate the class? I can't think
of a reason not to and am very curious if I'm
missing something here???
On question #2:
I normally write my programs so that they can be
called with an option on the processor call line
to override the "config-file". Something like:
python foo.py -i newconfigfile.ini
Then I use ConfigParser to read the options from
the .INI file. This provides unlimited flexibility
in having .INI files to drive the program.
I find that reading config parameters from an
external .INI file to be superior to putting
values in a .PY file and importing it. I know
others on this list may differ.
On question #3:
I use loggerclass to keep trace/debug information
in a logfile as the program executes. Actually I
normally have debug "levels" that give increasingly
more information as the number increases. I read
these from .INI file but allow user to override the
.INI file on the processor call line.
Example:
python foo.py -t -d 2
would turn trace on and debug at level 2
Then put lines in your code like:
if trace: log("Entering function a")
HTH,
Larry Bates
Syscon, Inc.
"Leopold Schwinger" <leoel at gmx.at> wrote in message
news:40b47710 at e-post.inode.at...
> Hello!
>
> I am a really newbie to python, and I have some questions. I couldn't
> find anything in the manual, so it would be nice if you could help me.
>
> (1) Is there any operator in Python in order to call a Member-Function
> from a class without creating an instance of the class? (In C++ and PHP
> there ist this operator "::" <class>::<memberfunction>)
>
> (2) Is there any way to dynamically import modules, where the name of
> the module is not known during implementation but can be defined durch
> scipt execution? Think of lots of different config-Files, which differ
> by Path & Name but the variables are all named equal, and i want to
> import a special config-File during the execution of the script.
>
> (3) Is there any way to obtain a kind of "trace"-Info (the actual
> filename and codeline) in order to provide some debug-Info in the case
> of errors (In C++ and PHP there are these "__line__" and "__file__"
> functions, For Python I have only found <Class>.__dict__ and dir(<Class>))
>
> Thank you very much,
> Leo
More information about the Python-list
mailing list