473,396 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

CONSTRUCT - New/Old Style Classes, build-in/extension types

Another topic [1] has raised the need of a deeper teach-in.

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....18ccef252c82cd

--
http://lazaridis.com

Sep 22 '06 #1
12 1914
Ilias Lazaridis wrote:
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>

Sep 22 '06 #2
"Ilias Lazaridis" <il***@lazaridis.comwrites:
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

Sep 22 '06 #3
Ben Finney wrote:
"Ilias Lazaridis" <il***@lazaridis.comwrites:
>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?
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/relea....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).

..

--
http://lazaridis.com
Sep 22 '06 #4
Fredrik Lundh wrote:
Ilias Lazaridis wrote:
>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 ?
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?

..

--
http://lazaridis.com
Sep 22 '06 #5
Ilias Lazaridis wrote:
Fredrik Lundh wrote:
>>Ilias Lazaridis wrote:

>>>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 ?


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?
No, not for new code.
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

Sep 22 '06 #6
Ilias Lazaridis wrote:
Fredrik Lundh wrote:
Ilias Lazaridis wrote:
note: I am aware about search engines.
but you're incapable of using them, or ?
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/

Sep 22 '06 #7
Paul Boddie wrote:
Ilias Lazaridis wrote:
[...]
>>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?
Though of course the easiest way to enforce your classes to new style is
to begin each module with

__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'>)
>>>
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

Sep 22 '06 #8
Steve Holden wrote:
Paul Boddie wrote:
Ilias Lazaridis wrote:
[...]
>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?
Though of course the easiest way to enforce your classes to new style is
to begin each module with

__metaclass__ = 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).
>>__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'>)
>>>
Sep 22 '06 #9

Paul Boddie wrote:
Ilias Lazaridis wrote:
.... (helpful comments)
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....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.

..

--
http://lazaridis.com

Sep 22 '06 #10
Ilias Lazaridis wrote:
Steve Holden wrote:
>>Paul Boddie wrote:
>>>Ilias Lazaridis wrote:

[...]
>>>>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?

Though of course the easiest way to enforce your classes to new style is
to begin each module with

__metaclass__ = 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).
I don't think it would "collapse Python", but since each module requires
its own __metaclass__ setting it certainly wouldn't change much.

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

Sep 22 '06 #11
Steve Holden wrote:
Ilias Lazaridis wrote:
>Steve Holden wrote:
....
>>Though of course the easiest way to enforce your classes to new style is
to begin each module with

__metaclass__ = 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).
I don't think it would "collapse Python", but since each module requires
its own __metaclass__ setting it certainly wouldn't change much.
I understand.

Thus I cannot set "__metaclass__ = object" on e.g. project-level or
site-level, but only module-level.

..

--
http://lazaridis.com
Sep 23 '06 #12
In article <ef**********@mouse.otenet.gr>,
Ilias Lazaridis <il***@lazaridis.comwrote:
>
Have those old style classes any benefits?
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
Sep 25 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John Abel | last post by:
A while back, I saw a thread asking if the standard lib modules would be modified to use the new logging module, and it got me thinking. As the new-style classes will be default for 2.4, will the...
3
by: Grant Edwards | last post by:
Is it just me, or does the "new style american girlfriend" line from "Sixteen Candles" pop into anybody else's head when the see the phrase "new style classes" mentioned on a subject line? Ah....
5
by: Chris S. | last post by:
I'm generating the source of an object from a list of objects. Therefore I need to determine if the object is a class definition (i.e. 'def something(whatever):') or a class instance (i.e....
3
by: Hallvard B Furuseth | last post by:
Why do new-style classes disable __coerce__()? It seems cumbersome to have to write a whole set of methods (e.g. __add__, __radd__, etc.) to get the same effect. Is there some way to...
1
by: George Sakkis | last post by:
Searching the archives for something related to the title, I found a few relevant threads (e.g. http://tinyurl.com/avyg6 or http://tinyurl.com/b5b6v); however they don't seem to give a...
1
by: Paul Rubin | last post by:
Just a slight rant, I think I can find a workaround. I wanted to trace all the output being sent through a socket: from socket import * sock = socket() socket.connect((host, post))...
12
by: Vaibhav | last post by:
I recently heard about 'new-style classes'. I am very sorry if this sounds like a newbie question, but what are they? I checked the Python Manual but did not find anything conclusive. Could someone...
3
by: Kalle Anke | last post by:
I'm confused by the concepts of old-style vs new-style classes, I've read most of the documents I found about this but it doesn't "click". Probably because I wasn't around before 2.2. Anyway,...
5
by: Joseph Barillari | last post by:
Hi python-list, I've just started using new-style classes and am a bit confused as to why I can't seem to alter methods with special names (__call__, etc.) of new-style class instances. In other...
3
by: Torsten Mohr | last post by:
Hi, i have some questions related to new style classes, they look quite useful but i wonder if somebody can give me an example on constructors using __new__ and on using __init__ ? I just see...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.