Re: [Tutor] Question
what exactly you want to do by [1,2,3] = "Anything" the above code is called unpacking of sequence, so there must be some variable on left side of assignment operator. but you have list of integers, why? On Tue, Jul 23, 2013 at 11:15 PM, Don Jennings wrote: > > On Jul 21, 2013, at 10:26 PM, Amandeep Behl wrote: > > > > > > > def Move(label): > > label = "Anything" > > > > a_list = [1,2,3] > > Move(a_list) > > > > I don't see any error when executing above but when i manually assign > [1,2,3] = "Anything" i get error > > Why? > > Repeat after me: label is a name, label is a name, label is a name ;>) > > So, you misunderstand what is happening in your code. Your function > accepts the argument named "label", but you do nothing with the object (a > list of numbers in this case). Instead, you use the same name and assign it > to the string object "Anything". > > Assignment works by assigning a name (on the left side of the operator), > to an object on the right side. > > Take care, > Don > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Coursera Python Course starts today
i signed up for the course...lets see how much i gain from this. On Tue, Aug 20, 2013 at 11:43 AM, Anung Ariwibowo wrote: > This should go to the list > > Let's discuss our progress then, if it is allowed by list rules. I was > just retake the course as well. > > Regards, > Anung > > > On 8/20/13, Leam Hall wrote: > > Hey all, > > > > In case I'm not the absolute last person to know, the newest edition of > > the Coursera "Learn to Program" course started today. It is Python > > based, free, lasts 7 weeks, and pretty fun. I didn't get a certificate > > last time as life got in the way. Hope to succeed this time. > > > > https://class.coursera.org/programming1-002/class/index > > > > Leam > > > > > > -- > > http://31challenge.net > > http://31challenge.net/insight > > ___ > > Tutor maillist - Tutor@python.org > > To unsubscribe or change subscription options: > > http://mail.python.org/mailman/listinfo/tutor > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Coursera Python Course starts today
@anung..have you started this course? On Tue, Aug 20, 2013 at 11:44 AM, Anung Ariwibowo wrote: > Just started today before catching bus to work. I will start this evening. > > Regards, > Anung > > > On 8/20/13, Leam Hall wrote: > > A little cooperation is motivating. I have finished up Week 1 but I was > > a few minutes late for work this morning! :) > > > > You? > > > > Leam > > > > On 08/19/2013 08:12 PM, barli...@gmail.com wrote: > >> Let's discuss our progress then, if it is allowed by list rules. I was > >> just retake the course as well. > >> > >> Regards, > >> Anung > >> > >> Sent from my BlackBerry® smartphone from Sinyal Bagus XL, Nyambung > >> Teruuusss...! > >> > >> -Original Message- > >> From: Leam Hall > >> Sender: "Tutor" Date: > Mon, 19 > >> Aug 2013 20:02:25 > >> To: > >> Subject: [Tutor] Coursera Python Course starts today > >> > >> Hey all, > >> > >> In case I'm not the absolute last person to know, the newest edition of > >> the Coursera "Learn to Program" course started today. It is Python > >> based, free, lasts 7 weeks, and pretty fun. I didn't get a certificate > >> last time as life got in the way. Hope to succeed this time. > >> > >> https://class.coursera.org/programming1-002/class/index > >> > >> Leam > >> > > -- > > http://31challenge.net > > http://31challenge.net/insight > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] class data member and objects of class in python
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 print "a pizza pls!! {}:".format(pizza_order.next()) StopIteration don't know where i am doing mistakeany help will be appreciated... i have other questions on based on this class ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] class data member and objects of class in python
class PizzaShop(): pizza_stock = 10 def get_pizza(self): while 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() # print "{}".format(repr(pizza_order.next())) for order in pizza_order: print "{}".format(repr(order)) domino_pizza_store = mypizza_shop.get_pizza() print "{}".format(repr(domino_pizza_store.next())) mypizza_shop.pizza_stock = 10 domino_pizza_store = mypizza_shop.get_pizza() print "{}".format(repr(domino_pizza_store.next())) can't we again use the same object mypizza_shop once its generator is exhausted On Thu, Sep 12, 2013 at 6:53 AM, Marc Tompkins wrote: > On Wed, Sep 11, 2013 at 5:40 AM, zubair alam wrote: > >> 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 >> >> print "a pizza pls!! {}:".format(pizza_order.next()) >> StopIteration >> >> >> don't know where i am doing mistakeany help will be appreciated... i >> have other questions on based on this class >> >> > > Change "while not PizzaShop.pizza_stock:" to "while > PizzaShop.pizza_stock:"; I get the following output: > >> a pizza pls!! take yours pizza order, total pizzas left 9: >> a pizza pls!! take yours pizza order, total pizzas left 8: >> > > > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor