Re: [Tutor] Using Class Properly - early beginner question

2017-03-24 Thread boB Stepp
On Fri, Mar 24, 2017 at 9:05 AM, Rafael Knuth wrote: > I have another question :) > I noticed that you split your class into three methods: > > def __init__(self): > # initialize instances of class > > def make_shopping_list(self): > # input > > def display_shopping_list(self): > # output > > I wa

Re: [Tutor] Using Class Properly - early beginner question

2017-03-24 Thread boB Stepp
On Fri, Mar 24, 2017 at 6:51 AM, Rafael Knuth wrote: > Thank you so much for your help. > I have a question: When creating an instance of GroceryListMaker, you are > using: > > if __name__ == "__main__": > > What is that specifically for? > I tested your code and both worked, with and without > i

Re: [Tutor] Using Class Properly - early beginner question

2017-03-24 Thread Alan Gauld via Tutor
On 24/03/17 21:42, boB Stepp wrote: >> I noticed that you split your class into three methods: Many real world classes have a lot more than 3 methods. >> def __init__(self): >> # initialize instances of class >> >> def make_shopping_list(self): >> # input >> >> def display_shopping_list(self): >

Re: [Tutor] Using Class Properly - early beginner question

2017-03-24 Thread Alan Gauld via Tutor
On 24/03/17 21:41, boB Stepp wrote: >> I have a question: When creating an instance of GroceryListMaker, you are >> using: >> >> if __name__ == "__main__": >> >> What is that specifically for? Its a common trick in Python that enables a single file to act as both a module and a program. When a s

Re: [Tutor] Using Class Properly - early beginner question

2017-03-24 Thread boB Stepp
I'm forwarding this to Tutor. Please respond to the whole group and not just me personally, so you can have access to the experts as well as allowing all of us learners the opportunity to learn more. On Fri, Mar 24, 2017 at 9:05 AM, Rafael Knuth wrote: > I have another question :) > I noticed th

Re: [Tutor] Using Class Properly - early beginner question

2017-03-24 Thread boB Stepp
I'm forwarding this to Tutor. Please respond to the whole group and not just me personally, so you can have access to the experts as well as allowing all of us learners the opportunity to learn more. I can't respond now, but will try to do so later. On Fri, Mar 24, 2017 at 6:51 AM, Rafael Knuth

Re: [Tutor] Using Class Properly - early beginner question

2017-03-23 Thread Alan Gauld via Tutor
On 22/03/17 12:30, Rafael Knuth wrote: > I wrote a function that does exactly what I want, and that is: > Create a shopping list and then let the user decide which items (food) > are supposed to be instantly consumed and which ones stored. That's a good start, because it means you understand your

Re: [Tutor] Using Class Properly - early beginner question

2017-03-23 Thread Mats Wichmann
On 03/22/2017 06:30 AM, Rafael Knuth wrote: > thanks for your feedback! @boB > > I wrote a function that does exactly what I want, and that is: > Create a shopping list and then let the user decide which items (food) > are supposed to be instantly consumed and which ones stored. > > def ManageFoo

Re: [Tutor] Using Class Properly - early beginner question

2017-03-22 Thread boB Stepp
On Wed, Mar 22, 2017 at 7:30 AM, Rafael Knuth wrote: > thanks for your feedback! @boB > ...(it does what it's > supposed to do, but not sure if a pro would write it same way I did). I'll leave it to others to evaluate your function which I snipped as I am not a pro! ~(:>)) > > Besides that, I w

Re: [Tutor] Using Class Properly - early beginner question

2017-03-22 Thread Rafael Knuth
thanks for your feedback! @boB I wrote a function that does exactly what I want, and that is: Create a shopping list and then let the user decide which items (food) are supposed to be instantly consumed and which ones stored. def ManageFood(): create_shopping_list = [] prompt = ("Which fo

Re: [Tutor] Using Class Properly - early beginner question

2017-03-21 Thread boB Stepp
On Tue, Mar 21, 2017 at 12:20 PM, Rafael Knuth wrote: > > While writing the parent class, I ran into the following issue: > How do I properly declare a variable that takes user input? > Do I write methods in the same fashion like in a regular function? > And how do I call that class properly? Wh

[Tutor] Using Class Properly - early beginner question

2017-03-21 Thread Rafael Knuth
I am trying to write a food shopping list. The user should be able to add items to that shopping list, and later on decide what should happen to those purchased foods: instantly consumed or stored. My initial idea was to create a parent class to populate the shopping list and a child class to mana