Declaration of an array of unspecified size

Bertel Lund Hansen nospamius at lundhansen.dk
Mon Sep 1 08:43:03 CEST 2003


Ulrich Petri skrev:

>> class PopMailServer:
>>   host = ""
>>   user = ""
>>   password = "*"
>>   mails = 0
>>   mail[] # This is wrong but what do I do?
>mail = [] #would work

>But you are creating class-variables here. Are you sure thats what you want?

Yes. I have the habit from Java and C++. Is there a better way to
declare them in Python?

I am using the class for inheritance. Does that matter?

In my present version i deleted the lines where I declared empty
attributes. It seems to work anyway.

>>     self.mails=len(pop.list()[1])
>you can skip the "mails" variable. len(mail) will give the same.

Yes, I saw that in another posting. But I have a habit that I
aquired working with slow computers: always to substitute
function-calls with variables (faster). Is that a bad habit?

-- 
Bertel, Denmark




More information about the Python-list mailing list