On Dec 5, 4:18 am, Rod Person <[EMAIL PROTECTED]> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I've been doing python programming for about 2 years as a hobby and now
> I'm finally able to use it at work in an enterprise environment. Since
> I will be creating the base classes and libraries I wondering which why
> is consider best when creating python classes:
>
> 1:
> class Foo(object):
>   member1=''
>   member2=0
>
>   def __init__(self,member1='',member2=0):
>         self.member1 = member1
>         self.member2 = member2
>
> 2:
> class Foo(object):
>         def  __init(self,member1='',member2=0):
>                 self.member1 = member1
>                 self.member2 = member2
>
> - --
> Rodhttp://roddierod.homeunix.net:8080
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (FreeBSD)
>
> iD8DBQFHVeAscZAIaGStcnARAhRnAKCNFfjStOPGs/9tMI6bKuBQTPiJHQCdEMdY
> OQPSSZlJWqkLxZvPwI2ctVs=
> =CfvK
> -----END PGP SIGNATURE-----

It depends on what we try to achieve.

The first definition gets me class defined with two class and instance
variables of the names member1 and member2. Where as second definition
gets class with only instance variables member1 and member2.

Both the definitions would allow me, Foo().member1 and Foo().member2.
Where as first definition would also allow me Foo.member1 and
Foo.member2.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to