Hi,
So should I not use getattr()?
If I have one class in one module, then should I use global?
I found getattr() very easy to use, my only dowbt is that if there is
going to be one class per module then will it be a good idea?
some thing like module, class_name
happy hacking.
Krishnakantt.
On
On Wed, Jan 14, 2009 at 12:15 AM, Krishnakant krm...@gmail.com wrote:
Hi,
So should I not use getattr()?
If I have one class in one module, then should I use global?
I found getattr() very easy to use, my only dowbt is that if there is
going to be one class per module then will it be a good
Hi steevan,
I liked this idea of dispatchTable.
is it possible to say some thing like
inst = dispatchTable{ham}
according to me, inst will become the instance of class ham.
Another thing to note is that all the classes are in different modules.
So where do I create the dict of classes mapped
On Wed, 14 Jan 2009 13:19:23 +0530, Krishnakant wrote:
On Tue, 2009-01-13 at 21:51 -0800, Chris Rebert wrote:
Assuming all the classes are in the same module as the main program:
instance = vars()[class_name](args, to, init)
The classes are not in the same module. Every glade window is
On Wed, 2009-01-14 at 00:20 -0800, Chris Rebert wrote:
Aside from Steven's excellent idea, to use the getattr() technique
with your module scheme you'd probably also need to use __import__()
to dynamically import the right module.
I would generally import all the modules I would need at the
On Wed, Jan 14, 2009 at 12:36 AM, Krishnakant krm...@gmail.com wrote:
On Wed, 2009-01-14 at 00:20 -0800, Chris Rebert wrote:
Aside from Steven's excellent idea, to use the getattr() technique
with your module scheme you'd probably also need to use __import__()
to dynamically import the right
Krishnakant wrote:
hello all,
I have a strange situation where I have to load initiate an instance of
a class at run-time with the name given by the user from a dropdown
list.
Is this possible in python and how?
To make things clear, let me give the real example.
there is an inventory
On Wed, 2009-01-14 at 04:09 -0500, Steve Holden wrote:
You don't need to have the names of the classes related to anything in
the interface. Just use a list of classes, and have the user interface
return the correct index for each class. Then (supposing the selection
by the user is seln)
On Wed, 2009-01-14 at 00:39 -0800, Chris Rebert wrote:
On Wed, Jan 14, 2009 at 12:36 AM, Krishnakant krm...@gmail.com wrote:
On Wed, 2009-01-14 at 00:20 -0800, Chris Rebert wrote:
Aside from Steven's excellent idea, to use the getattr() technique
with your module scheme you'd probably also
Hi,
try the following exemplarily for the os module
import os, types
[(c, klass) for (c,klass) in os.__dict__.items() if
type(klass)==types.ClassType]
will print: [('_Environ', class os._Environ at 0xb7d8114c)]
Regards,
wr
Am Mittwoch, 14. Januar 2009 10:55:27 schrieb Krishnakant:
On Wed,
Krishnakant krm...@gmail.com wrote:
By the way, is there a kind of global list of modules/classes which are
maintained in a package once the program is loaded into memory?
sys.modules is a dict of loaded module objects, keyed by module name.
So:
getattr(sys.modules[sys], version_info)
(2, 5,
Krishnakant hackin...@gmail.com wrote:
I liked this idea of dispatchTable.
is it possible to say some thing like
inst = dispatchTable{ham}
according to me, inst will become the instance of class ham.
Another thing to note is that all the classes are in different modules.
So where do I
On Wed, 14 Jan 2009 13:53:52 +0530, Krishnakant wrote:
Hi steevan,
I liked this idea of dispatchTable.
is it possible to say some thing like inst = dispatchTable{ham}
according to me, inst will become the instance of class ham.
Yes, that works, provided you fix the syntax. (You used {}
hello all,
I have a strange situation where I have to load initiate an instance of
a class at run-time with the name given by the user from a dropdown
list.
Is this possible in python and how?
To make things clear, let me give the real example.
there is an inventory management system and products
On Tue, Jan 13, 2009 at 9:46 PM, Krishnakant krm...@gmail.com wrote:
hello all,
I have a strange situation where I have to load initiate an instance of
a class at run-time with the name given by the user from a dropdown
list.
Is this possible in python and how?
To make things clear, let me
On Tue, 2009-01-13 at 21:51 -0800, Chris Rebert wrote:
Assuming all the classes are in the same module as the main program:
instance = vars()[class_name](args, to, init)
The classes are not in the same module.
Every glade window is coupled with one py file (module) containing one
class that
On Wed, 14 Jan 2009 11:16:58 +0530, Krishnakant wrote:
hello all,
I have a strange situation where I have to load initiate an instance of
a class at run-time with the name given by the user from a dropdown
list.
Not strange at all.
Is this possible in python and how?
Of course. Just use a
On Tue, Jan 13, 2009 at 11:49 PM, Krishnakant krm...@gmail.com wrote:
On Tue, 2009-01-13 at 21:51 -0800, Chris Rebert wrote:
Assuming all the classes are in the same module as the main program:
instance = vars()[class_name](args, to, init)
The classes are not in the same module.
Every glade
18 matches
Mail list logo