A newbie question about class

Fernando Pérez fperez528 at yahoo.com
Sat Feb 9 12:41:39 EST 2002


newgene wrote:

> Hi, group,
>      I have a newbie question about building a class:
> 
> eg.
> 
> class A:
>    def __init__(self,x=None):
>        self.x=x
>        if self.x != None:
>             self.y=x**2
>        else:
>             self.y=x**2

This code has a problem: None**2 gives a TypeError exception.

f



More information about the Python-list mailing list