473,791 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1950
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***@lazaridi s.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***@lazaridi s.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.or g.
"
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 incompatibiliti es.
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.p y) 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(olds tyle)
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

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

Similar topics

1
1222
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 standard lib modules be modified accordingly? Thanks John
3
1725
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. Just me? I was afraid of that. --
5
1528
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. 'somename = somethingelse()'). With classic classes this is trivial, since all I have to do is check the type. However, for the new "improved" style classes this seems next to impossible, since everything is essentially an instance of something. ...
3
2279
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 automatically generate those methods, or are we simply not supposed to do coercion for some reason? -- Hallvard
1
1560
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 satisfactory answer, so here it goes again: What's the equivalent new-style Delegate class ? class Delegate: def __init__(self, principal): self._principal = principal
1
1355
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)) socket.send('hello over there\n') # I want to log the string Sounds like a job for new style classes:
12
1594
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 please enlighten me? Thanks!
3
1283
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, the reason for new style classes are to make the whole type/object thing work better together. There are a number of new features etc. I think my problem is when new-style classes are used, at first I thought that all classes become new-style...
5
1477
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 words, I can do this: .... pass .... 33
3
2774
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 that when using it i can't give parameters to __new__ and when i additionally define __init__ then __new__ is not called.
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9515
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10426
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7537
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.