Where can I find _compact_ documentation about
* Differece between New Style / Old Style Classes
Are there any documents available (again: compact ones) which describe
unification attemps subjecting
* New Style Classes
* Old Style Classes
* Build In Types
* Extension Types
(note: I am aware about search engines. I ask for documentation which
other developers have found useful)
.
[1]
CONSTRUCT - Adding Functionality to the Overall System
http://groups.google.com/group/comp.lang.python/browse_thread/thread/4618ccef252c82cd
> note: I am aware about search engines.
but you're incapable of using them, or ?
> I ask for documentation which other developers have found useful
most recent Python books contains good discussions of the things you're
asking for. maybe you should buy a book ?
</F>
> Where can I find _compact_ documentation about
Can you tell us what is lacking about the documentation at
<URL:http://www.python.org/doc/> ? Specifically, what problems have
you found in understanding these topics from the documentation
available at that site?
--
\ "The World is not dangerous because of those who do harm but |
`\ because of those who look at it without doing anything." -- |
_o__) Albert Einstein |
Ben Finney
Of course:
"
Unifying types and classes in Python 2.2
Python Version: 2.2.3
Guido van Rossum
This paper is an incomplete draft. I am soliciting feedback. If you find
any problems, please write me at gu...@python.org.
"
http://www.python.org/download/releases/2.2.3/descrintro/
-
Weaknesses:
* draft version
* written by the system designer
* size
* code examples uncolored
* code examples missaligned
-
I've looking for a _compact_ analysis of this topic, prefered in
standard OO jargon. Around 100 lines and 1 diagramm (or 500 lines and 3
diagramms, but not more).
.
-
>> I ask for documentation which other developers have found useful
>
> most recent Python books contains good discussions of the things you're
> asking for. maybe you should buy a book ?
I'm interested in online resources, experiences etc..
Maybe you can clarify some things (for me and for readers):
Do I need old style classes?
Does the python standard library use old style classes?
Have those old style classes any benefits?
.
> Does the python standard library use old style classes?
>
Yes, because it was easier to leave them as they were than risk
introducing incompatibilities.
> Have those old style classes any benefits?
>
> ..
>
No.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
Well, "Python new-style old-style classes" in Google gives a range of
discussions, but an old version of the definitive guide [1] is found
via one of the later results on the first page (which is some section
of the reference manual). According to that and the newer guide [2],
the official documentation still isn't updated, despite it having been
a good three years since new-style classes first arrived in a real
Python release.
Of course, the lengthening paper trail shouldn't be a surprise to you
or I, but with more "exciting" additions to the language in 2.5, it is
somewhat unnerving that the last major changes still sit partially
documented in "additional documentation" that a beginner wouldn't be
inclined to read through.
> >> I ask for documentation which other developers have found useful
> >
> > most recent Python books contains good discussions of the things you're
> > asking for. maybe you should buy a book ?
>
> I'm interested in online resources, experiences etc..
And I don't see what's wrong with that.
> Maybe you can clarify some things (for me and for readers):
>
> Do I need old style classes?
No, but you can still use them. I use them a lot.
> Does the python standard library use old style classes?
Yes, I'd imagine, since it would otherwise have needed someone to go
through the library and change everything, and I doubt that anyone is
that interested to do so.
> Have those old style classes any benefits?
That you don't have to write the bizarre conceptual accident that is
"(object)" when declaring a "top-level" class?
Paul
[1] http://www.python.org/doc/newstyle.html
[2] http://www.python.org/doc/newstyle/
__metaclass__ = type
>>> __metaclass__ = type
>>> class X: pass
...
>>> X
<class '__main__.X'>
>>> X()
<__main__.X object at 0x186c6f0c>
>>> x = X()
>>> isinstance(x, object)
True
>>> type(x), type(X)
(<class '__main__.X'>, <type 'type'>)
I assume placing this in the central site import (e.g.
sitecustomize.py) would collapse python? (I don't want to try it, maybe
someone has an isolated instance available for trials).
> > Have those old style classes any benefits?
>
> That you don't have to write the bizarre conceptual accident that is
> "(object)" when declaring a "top-level" class?
This was most possibly done for back-compatibility reasons.
Although introducing a change like this:
def MyOldClass(oldstyle)
def MyNewClass()
an giving lazy developers the search&replace patterns to migrate the
code would have been of benefit.
Possibly something for Python 2.6.
> Paul
>
> [1] http://www.python.org/doc/newstyle.html
> [2] http://www.python.org/doc/newstyle/
this page points to nice documentation (which I would place in top of
the list!!!):
http://www.cafepy.com/article/python_types_and_objects/ch03.html#id833463
-
"Guido's essay on new-style classes and should be your starting point."
This article should _not_ be suggested as a starting point.
.
I understand.
Thus I cannot set "__metaclass__ = object" on e.g. project-level or
site-level, but only module-level.
.
Yes, if you want your code to run on Python 2.1 and earlier.
--
Aahz (aa...@pythoncraft.com) <*> http://www.pythoncraft.com/
"LL YR VWL R BLNG T S" -- www.nancybuttons.com