Join Club ShowMeDo to Learn Python!

This series is a part of Club ShowMeDo. Click to learn why you should join our club with a simple monthly subscription.

  • We teach Python and all the cool modules
  • Topics include beginner Python, GUIs, Web and Desktop Apps
  • Long, specially crafted video tutorials just for you
  • Club video tutorials extend our normal Free content
  • Save your time - we've done the research for you
  • Keep your skills up-to-date
  • Learn at your own pace, everything you need is shown to you
  • Over 12 hours of archived material are waiting for you in the club

Name: [002] Ian Ozsvald
Member: 109 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

(Showmedo is undergoing major changes. To report any problems viewing the videos please email us and include browser and OS specifics. Cheers - Kyran.)

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: 690 (since July 30th)
  • Plays in last week: 0
  • Published: 78 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.

Your email address will not be published.

Show some quick comments >>








All comments excluding tick-boxed quick-comments

very nice and 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


Awesome stuff.


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


Showmedo is a peer-produced video-tutorials and screencasts site for free and open-source software (FOSS)- with the exception of some club videos, the large majority are free to watch and download.

how to help » about » faq »

Educating the Open-source Community With Showmedo

Although as important as the software it supports, education and documentation are relatively neglected in the Open-source world. Coders love to code, and explaining how best to use or improve the software tends to be deferred or even sidelined.

At Showmedo we believe the community can play a vital role here and also say thanks for the tools and software that make our lives easier. If you have a piece of software you love or a programming langugage you are enthusiastic about, why not make a screencast showing others how to use it? All the stuff you wish you'd been told, the tips, tricks, insights that would have saved you time and frustration.

Screencasting is easier than you think, and we're happy to help you. You can emailus for advice or just use some of the how-to screencasts on the site. This screencasting learning-pathis a good place to start.

Kudos and Thanks for Ian

Content

Feedback

Showmedo's development is fairly rapid and bugs will inevitably creep in. If you have any problems please drop us a line using the contact address below. Likewise, any suggestions for improvements to the site are gratefully received.

feedback@showmedo.com