how to build a street with more than 1 house ?

Stef Mientki stef.mientki at gmail.com
Fri Jun 6 18:45:07 EDT 2008


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




More information about the Python-list mailing list