Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Andras Andras7,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#
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.
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.