Why Python forbids multiple instances of one module?

kedra marbun kedra.marbun at gmail.com
Tue Jul 6 02:26:16 EDT 2010


module obj is instance of types.ModuleType, which is instance of
'type', where class obj is instance of 'type'. even only at this
point, they're diff in to many ways. there are so many things to do
when you truly want module to replace class, as pointed by 2 posts
above

i'm also a beginner, so i can offer you a tip in learning it: follow
the design, py usually has good reasons about it, i've lost in every
challenge i put against py design, luckily i find the reasons through
my own experiment. yes, it's better to find it through hacking, rather
than people talking about it, the reason is the same as coding to
learn programming, not only reading book. it will become more
understandable when people say py has clean design

as for 'self', yes i admit it seems troublesome at first, you'll have
reason for it once you know that method is simply a func, you'll
embrace the more general design (py requires you to specify a name for
the caller) when you learn about metaclass. a nice argument to this is
that human beings are visual creatures, it becomes so much easier to
have a name that desribes the obj it points to (like 'self', 'cls',
'metacls') than implicit name that trying to be as general as possible
(like 'this')



More information about the Python-list mailing list