On Fri, 2008-05-16 at 06:04 -0700, globalrev wrote: > On 16 Maj, 13:54, Peter Otten <[EMAIL PROTECTED]> wrote: > > Christian Heimes wrote: > > > globalrev schrieb: > > >> cust1 = customer.__init__('12',['1','435','2332']) > > > > > cust1 = customer('12',['1','435','2332']) > > > > ... and before that > > > > from customer import customer > > > > Peter > > why do i have to write that? > > if i do import customer im importing everything no? >
Not exactly. That's how perl and PHP tend to do it, but python's import system is much more conservative (and far superior because of it). When you import a name you get that name and nothing else. You can still call your class without doing from customer import customer, but you have to include the module in the class name like this: cust1 = customer.customer('12',['1','435','2332']) Everything stays hidden behind the name customer. That way, if customer defines a class that has the same name that you already have in your namespace, it won't get overwritten. Say you define a class Purchase in your customer module, and then in the interpreter, you write py>>> import customer py>>> Purchase = 4 py>>> bread = customer.Purchase('bread') py>>> Purchase 4 py>>> bread <customer.Purchase object at 0xabcdefab> py>>> Purchase and customer.Purchase can live happily side by side. In perl or PHP, the default behavior causes errors which are hard to debug because you can't see what names are being pulled into your namespace. > but youre right it doesnt work unless i do, i just dont get why. > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list