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 trial


Andras Andras
Andras Andras
7,941 Points

New 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

Not 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")

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
Andras Andras
7,941 Points

Thanks hamsternation, It makes sense now, there are a lot of expression starting with letter "i".