cafepy.com

Discuss: Python Attributes and Methods

Kevin Whitefoot, 03:54 AM on Jun 01, 2005

Brilliant. Thank you very much for the clearest exposition of Python's type system I have seen.

Jeronimo Albi, 09:37 AM on Jul 23, 2005

Yes, very well explained. It's a plesure to read articles like
this one.
By the way, I really like cafepy site design =).

Don Bora, 07:44 PM on Sep 06, 2005

How does one start a new discussion ? I want to start a discuss between PHP and Python , which is better ?

Don Bora, 07:53 PM on Sep 06, 2005

Okay i figured it out. Must be tired tonight. :(

Anonymous, 04:26 AM on Jan 17, 2006

Is there a large python discussion board / community out there somewhere?

Anonymous, 06:56 PM on Jan 18, 2006

http://groups.google.com/group/comp.lang.python

Anonymous, 05:24 PM on Feb 22, 2006

This is excellent.

I got particularly intersted at SpecialType. It would be interstesting to have the distinction between 'type(list)' ('list' is given in the library doc as a builtin function) and types.ListType made clear.

It seems that 'list' is, in fact, a class or type name and, when called becomes an instance constructor.

Colin W.

Shalabh Chaturvedi, 10:57 PM on Feb 22, 2006

Any 'class or type name' when called returns the instance - in fact that is the standard way of creating an instance in Python - call the class name. This is true for built-in types as well as classes you define. The built-in list used to be a function but version 2.2 onward it is a type. Interestingly the behavior seems same as before when you use it to convert something to a list. But technically you are instantiating a list object rather than calling a function.

Also, list and types.ListType are one and the same object. In fact you can check in Python yourself:

>>> import types
>>> types.ListType is list
True

When you say type(list), you get the metaclass <type 'type'>. See http://cafepy.com/article/python_types_and_objects/ch03.html (Python Objects Map), which shows both list (shown as <type 'list'>) and <type 'type'>.

Anonymous, 05:44 AM on Dec 08, 2006

Thank you *very* much for these guides. They've answered virtually all of my questions regarding objects and types the standard documentation didn't answer - and there were a lot of those.

Anonymous, 10:30 AM on Oct 06, 2007

You've written that when retrieving an attribute from an object (print objectname.attrname) the first step performed by Python is to check whether attrname is a Python-provided attribute for objectname and if it is - return it. How exactly is this step performed?
Also, I've looked for a good guide explaining what is found in object and what the dictproxy object is, and have found nothing - could you refer me to such a guide?

Thanks in advance!


Post Comments
Format of Comments*
Plain Restructured Text

Comments*

Human Test*
The CAPTCHA image Listen
Enter image text:





Log in to post non-anonymously.

Please Login
Username*

Password*