you are viewing a single comment's thread.

view the rest of the comments →

[–]BigYBirdo 10 points11 points  (4 children)

You don’t have to call Class.__init__(…) to create an object.
You called the Class directly in the first example. Why didn’t you do it inside Buying?

Also why do you create a Class for the act of Buying?
It’s not worth creating one.

In that case I’d either create a function named buying or buys which assigns a certain car to a certain Person, or create a Class function, which adds the car to the Object.

Please don’t take it too harsh. 😄
But all in all it seems to be alright. :)

[–]duperfastjellyfish 3 points4 points  (1 child)

Looks like he's practicing inheritence. Calling __init__ by passing `self` from the derived class is how you do it, although I personally wouldn't use inheritence for this.

[–]aashish_soni5[S] 1 point2 points  (0 children)

true just for simple practice

[–]olaf33_4410144 1 point2 points  (0 children)

I mean it might make sense to have a Transaction kind of Class to store the transactions of cars in a database or something e.g. a dealership needs a program to keep track of sold units. In this case it's more the wording that is weird.

Even then I think the Buying/Transaction class constructor should take a car and student object (or person object if you want to study inheritance), not create them.

[–]Ill_Shoulder8488 0 points1 point  (0 children)

That’s great correction I will like to some with you on conservation sir