A community for students. Sign up today!
Here's the question you clicked on:
 0 viewing

This Question is Closed

estudier
 2 years ago
Best ResponseYou've already chosen the best response.3Where is that in the course materials?

Shadowys
 2 years ago
Best ResponseYou've already chosen the best response.0Just a question while I was tking...most objectoriented programming choose to have a init function to iniatiate it.

estudier
 2 years ago
Best ResponseYou've already chosen the best response.3Strictly speaking, it should be initializes a class instance, right?

Shadowys
 2 years ago
Best ResponseYou've already chosen the best response.0Yup, but I don't really see why I shouldn't call the instance straight from the class instead. Unless, of course, I am supposed to use the class to start a function. However, in python 2.x classes need to be initiated, quite annoying actually.

estudier
 2 years ago
Best ResponseYou've already chosen the best response.3That is sort of one of the reasons for going over to 3 although the transition will likely take some time. Then we can have all the same arguments that we have in "grown up" languages all over again...:)

Shadowys
 2 years ago
Best ResponseYou've already chosen the best response.0LOL I getcha. Programming objects in python 2.x is a pain and normally I tk in Python 3.x instead. So, basically __init__ is just there to ...init a function contained in the class, then?

estudier
 2 years ago
Best ResponseYou've already chosen the best response.3This will save me a lot of typing: http://stackoverflow.com/questions/8609153/whydoweuseinitinpythonclasses

Shadowys
 2 years ago
Best ResponseYou've already chosen the best response.0Very nice, I get it. It's just there to iniatialize the instances. thanks!

snark
 2 years ago
Best ResponseYou've already chosen the best response.0you can initialize class values in the class. for example, directly initialize two values  node = Node(a,b), where __init__ can be used to set class values. Same as n = Node() # create a new Node thingy n.var1 = a # assign a value to a class variable n.var2 = b # assign another value instead you have def __init__(self,a,b,): self.var1 = a self.var2 = b it's useful if you want to initialize many objects of this class with different values. n1 = Node(1,2) n2 = Node(3,4) ....
Ask your own question
Ask a QuestionFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.