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

Python

The difference between 'class' and 'type'

I've come across several forums and articles talking about classes in Python. And no matter how many times i've read the definitions being given - i haven't come one bit closer to knowing the difference. I haven't yet come across any definitions of 'class' on here. Can someone explain this in a simple manner.

2 Answers

Simon, here's something from the net that might help:

"In the olden days, there was a difference between user-defined classes and built in types. But since 2.2, as long as you're using "new-style" classes (classes that inherit from object in 2.x, and are default in 3.x), there is no real difference. Essentially, a class is a mechanism Python gives us to create new user-defined types from Python code."

http://eli.thegreenplace.net/2012/03/30/python-objects-types-classes-and-instances-a-glossary

Ah - That makes so much more sense then. Thanks! :)