Need help with OOP

Christopher Koppler klapotec at
Fri Nov 7 10:11:54 CET 2003

On Fri, 07 Nov 2003 06:47:20 GMT, Icarus Sparry
<usenet at> wrote:

>class ipaddress:
>        def __init__(self,str):
>                self.string_rep=str

However, using str as (even a local) variable name is not that good an
idea, since it's the name of the built-in type representing strings,
which could not be used in this __init__ method because of that. An
example which does just that could be:

class ipaddress:
   def __init__(self, address):
       self.adress_string = str(address)

to convert whatever parameter gets passed to a string. Using built-in
names for variables is a habit that shouldn't be started ;-)


More information about the Python-list mailing list