i am learning how a __class__ data member behaves in python as compared to
static data member in java, but following code is throwing error
class PizzaShop():
pizza_stock = 10
def get_pizza(self):
while not PizzaShop.pizza_stock:
PizzaShop.pizza_stock -= 1
yield "take yours pizza order, total pizzas left
{}".format(PizzaShop.pizza_stock)
mypizza_shop = PizzaShop()
pizza_order = mypizza_shop.get_pizza() # iterator is obtained
print "a pizza pls!! {}:".format(pizza_order.next())
print "a pizza pls!! {}:".format(pizza_order.next())
output:
Traceback (most recent call last):
File "/home/scott/pythonfiles/core_python/pizza.py", line 10, in <module>
print "a pizza pls!! {}:".format(pizza_order.next())
StopIteration
don't know where i am doing mistake....any help will be appreciated... i
have other questions on based on this class
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor