S
Stef Mientki
hello,
In the code below, I can build a large street like this:
large_street = house * 25
but not a small street. like this:
small_street = 5 * house
Why is this different ?
And more interesting, how do I get the right results ?
thanks,
Stef Mientki
class type_house ( object ) :
def __init__( self, front_doors = 1 ) :
self.front_doors = front_doors
def __mul__ ( self, b ) :
return type_house ( self.front_doors * b )
house = type_house ()
large_street = house * 25
print large_street.front_doors
small_street = 5 * house
print small_street.front_doors
In the code below, I can build a large street like this:
large_street = house * 25
but not a small street. like this:
small_street = 5 * house
Why is this different ?
And more interesting, how do I get the right results ?
thanks,
Stef Mientki
class type_house ( object ) :
def __init__( self, front_doors = 1 ) :
self.front_doors = front_doors
def __mul__ ( self, b ) :
return type_house ( self.front_doors * b )
house = type_house ()
large_street = house * 25
print large_street.front_doors
small_street = 5 * house
print small_street.front_doors