There are special functions for dealing with class introspection and object identity. These can be useful when selecting and identifying objects.
- [Male Voice] The Python Standard Library…includes functions for working on classes and objects.…Here in Komodo, I've opened a working…copy of hello.py from Chapter 13 of the exercise files,…and I'm going to start by defining a couple of variables.…Here we have a literal integer.…And type of X.…And we'll print X and we'll print Y.…
And when I run that, we get 42 and the type is 'int'.…So this is the type function which…operates on an object and it returns the…class of that object or the type of that object.…Class and type is pretty much the same thing in Python.…Now, that doesn't help us a whole lot…if we want to interspect inside of code…and if we want to ask, is this an instance…of a particular class or not?…And so for that we have the is instance…and I can ask it if it's an instance of 'int'…and if I run this I'll get true…and if I make that 42.0 then I will get false…because that's an instance of float.…
And then finally there is the ID of.…So I can say ID of X.…And that'll print this number that…represents a unique number for that particular object.…
- Python anatomy
- Types and values
- Conditionals and operators
- Building loops
- Defining functions
- Python data structures: lists, tuples, sets, and more
- Creating classes
- Handling exceptions
- Working with strings
- File input/output (I/O)
- Creating modules
- Integrating a database with Python db-api
Skill Level Intermediate
Python: Programming Efficientlywith Michele Vallisneri2h 15m Intermediate
2. Language Overview
3. Types and Values
8. Structured Data
11. String Objects
12. File I/O
13. Built-in Functions
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.