473,804 Members | 3,185 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
12 1953
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.p y) 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 "__metaclas s__ = object" on e.g. project-level or
site-level, but only module-level.

..

--
http://lazaridis.com
Sep 23 '06 #12
In article <ef**********@m ouse.otenet.gr> ,
Ilias Lazaridis <il***@lazaridi s.comwrote:
>
Have those old style classes any benefits?
Yes, if you want your code to run on Python 2.1 and earlier.
--
Aahz (aa**@pythoncra ft.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
1224
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
2280
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
1561
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
1356
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
1595
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
1478
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
2775
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
9704
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
9572
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
10319
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
10070
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
7608
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
5508
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4282
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.