Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAndras Andras
8,230 PointsNew instance of a class means inheritance?
Hello, I am a bit confused. Does the new instance of a class in python means inheritance like in c#
1 Answer
hamsternation
26,616 PointsNot sure about C#, but in python, new instance is not the same as inheritance.
An inheritance is when a new class you create uses the methods from another existing class.
Basically a new instance is a variable of that class.
For example:
word = str("foo")
word.upper()
The variable word is an instance of the string object, and it has all of the methods that the string object has.
You can create other instances of str() by assigning str() to other variables:
thing = str("goodies")
food = str("pizza")
movie = str("Lord of the Rings")
thing, food, and movie are all instances of str().
Not sure if this made any sense... I'm bad at explaining things.
Andras Andras
8,230 PointsAndras Andras
8,230 PointsThanks hamsternation, It makes sense now, there are a lot of expression starting with letter "i".