Newbie help- Can multiple instances with multiple names automatically created.

Nav navjotmusic at
Tue Jan 5 04:12:53 CET 2010

Okay, let me ask another question:

When we create instances of objects by doing
x = className ()
are we using globalnamespace?

if yes then:
  if using globalnamespace is bad then why does every book or tutorial
about python classes give the above  style of assignment as an

Second why do we use a dictionary to create something like this? I
know how it works, but what is wrong with simply creating instances
automatically? Once created the data for the instances is
automatically saved in their own space? Why have a round about way
using dictionaries?
Is there an advantage or does it conflict with something else?

Why not have
for i in specialList:  #I presume it would have to be special, because
it can't be a problematic type
  i = className(whatever)

> > what are the risks of globalnamespace use
> You're unnecessarily tying your code to the implementation.
> > and what are the benefits?
> Absolutely none that using a dictionary doesn't also give you.

More information about the Python-list mailing list