Name:
[002] Ian Ozsvald
Member:
90 months
Authored:
181 videos
Description:
I am the co-founder of ShowMeDo (see http://showmedo.com/about), author of `The Screencasting Handbook <http://thescreencastinghandbook.com>`_ and the founder of the professional screencast production company `ProCasts <http://procasts.co.uk>`_:
.. image:: http://procasts.co.uk/media/procasts_sma ...
Variables are Objects [ID:743] (2/14)
in series: Python Beginners - Common Variables and Containers
video tutorial by Ian Ozsvald, added 07/08
Name:
[002] Ian Ozsvald
Member:
90 months
Authored:
181 videos
Description:
I am the co-founder of ShowMeDo (see http://showmedo.com/about), author of `The Screencasting Handbook <http://thescreencastinghandbook.com>`_ and the founder of the professional screencast production ...
Our authors tell us that feedback from you is a big motivator. Please take a few moments to let them know what you think of their work.
All variables in Python are references to objects, more than one variable can reference the same object (which isn't true of some other languages). Since everything in Python is an object, everything has methods that govern its behaviour - again this isn't true in some languages.
Here I give you a quick demo of the dynamic-typing and strong-typing nature of Python, along with the fact that you can declare variables on the fly (and redeclare as necessary). I also show you about id(), type(), isinstance() so you can dig into the object you're looking at.
Links - Python Tutorial on Objects, Alan Gauld has an object tutorial. There's a Python library reference for objects. For more background reading here's an older but still useful Effbot article on objects.
Got any questions?
Get answers in the ShowMeDo Learners Google Group.
Video statistics:
- Video's rank shown in the most popular listing
- Video plays: 664 (since July 30th)
- Plays in last week: 2
- Published: 59 months ago
Thank-yous, questions and comments
If this video tutorial was helpful please take some time to say thank-you to the authors for their hard work. Feel free to ask questions. Let the author know why their video tutorial was useful - what are you learning about? Did the video tutorial save you time? Would you like to see more?
You may also want to see our ShowMeDo Google Group to speak to our active users and authors.
All comments excluding tick-boxed quick-comments
very nice and helpful!
very helpful
Another helpful video. Great intro to the subject of Variables as Objects, Classes, and good sources of reference materials and help.
Useful for the people like me - but still must be complemented with books
excellent!
Awesome stuff.
awsome!
ok
Good content, thanks.
Now I am starting to get into stuff I didn't know. Thanks...
Very good. Though I wonder why you introduced IPython into the mix rather than use Idle. This was sort of not expected since I couldn't find a reference to Ipython in your other videos.
great, thank you!!
Great intro to python. I learned a hell of a lot in just 10 minutes! Thanks!
Fantastic! Answered lots of questions for me regarding 'type' problems I have experienced and now overcome.
Thanks very very useful.
Thanks, I took a class and did not come out with this understanding
SpotTheDog - you need to use IPython, not the standard Python interpreter. This is mentioned at the start of the video, you can get IPython here:
http://ipython.scipy.org/moin/
Ian.
Review of Variables are Objects
Following your video, I'm not able to achieve the same output as you. Why?
a. doesn't work
a? doesn't work
a.__doc__ does work
dir(a) does work
I'm using the latest version of Python
>>>
>>> a=3
>>> a.
File "<stdin>", line 1
a.
^
SyntaxError: invalid syntax
>>> a.__doc__
'int(x[, base]) -> integer\n\nConvert a string or number to an integer, if possible. A floating point\nargument will
truncated towards zero (this does not include a string\nrepresentation of a floating point number!) When converting
string, use\nthe optional base. It is an error to supply a base when converting a\nnon-string. If the argument is out
de the integer range a long object\nwill be returned instead.'
>>> a.
File "<stdin>", line 1
a.
^
SyntaxError: invalid syntax
>>> a?
File "<stdin>", line 1
a?
^
SyntaxError: invalid syntax
>>> type(a)
<type 'int'>
>>> help(a)
Help on int object:
class int(object)
| int(x[, base]) -> integer
|
| Convert a string or number to an integer, if possible. A floating point
| argument will be truncated towards zero (this does not include a string
| representation of a floating point number!) When converting a string, use
| the optional base. It is an error to supply a base when converting a
| non-string. If the argument is outside the integer range a long object
| will be returned instead.
|
| Methods defined here:
|
| __abs__(...)
| x.__abs__() <==> abs(x)
|
Review of Variables are Objects
Following your video, I'm not able to achieve the same output as you. Why?
a. doesn't work
a? doesn't work
a.__doc__ does work
dir(a) does work
I'm using the latest version of Python
>>>
>>> a=3
>>> a.
File "<stdin>", line 1
a.
^
SyntaxError: invalid syntax
>>> a.__doc__
'int(x[, base]) -> integer\n\nConvert a string or number to an integer, if possible. A floating point\nargument will
truncated towards zero (this does not include a string\nrepresentation of a floating point number!) When converting
string, use\nthe optional base. It is an error to supply a base when converting a\nnon-string. If the argument is out
de the integer range a long object\nwill be returned instead.'
>>> a.
File "<stdin>", line 1
a.
^
SyntaxError: invalid syntax
>>> a?
File "<stdin>", line 1
a?
^
SyntaxError: invalid syntax
>>> type(a)
<type 'int'>
>>> help(a)
Help on int object:
class int(object)
| int(x[, base]) -> integer
|
| Convert a string or number to an integer, if possible. A floating point
| argument will be truncated towards zero (this does not include a string
| representation of a floating point number!) When converting a string, use
| the optional base. It is an error to supply a base when converting a
| non-string. If the argument is outside the integer range a long object
| will be returned instead.
|
| Methods defined here:
|
| __abs__(...)
| x.__abs__() <==> abs(x)
|
clear explanation.
Great video, lots of good basic information to help me start learning Python. Easy to watch the videos and then open up an interactive prompt and try out the new features I just learned. I also like the web links for additional details.
Video published, thanks for contributing to ShowMeDo
