473,406 Members | 2,345 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,406 software developers and data experts.

Diff. between Class types and classic classes

Hi,
can some one properly explain the differences between class types and
classic classes? ... Still face problems in identifying what is what.

Nov 8 '05 #1
5 1566
venk wrote:
Hi,
can some one properly explain the differences between class types and
classic classes? ... Still face problems in identifying what is what.


I'm not sure I understand your question. Are you talking about the diff
between old-style and new-style classes, or the diff between classes and
metaclasses ?

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Nov 8 '05 #2
bruno at modulix wrote:
venk wrote:
Hi,
can some one properly explain the differences between class types and
classic classes? ... Still face problems in identifying what is what.

I'm not sure I understand your question. Are you talking about the diff
between old-style and new-style classes, or the diff between classes and
metaclasses ?

"new" classes inherit from object. Classic classes do not.
"new" classes have a __new__ method. Classic classes generally do not.
The type of a "new" class is types.TypeType
The type of a classic class is a classobj
The type of an instance of a "new" class is the name of the class
The type of an instnce of a classic class is an instance

This is shown below:
class A(object): .... def __init__(self):
.... pass
.... a= A()
class B: .... def __init__(self):
.... pass
.... b= B()
type(A) <type 'type'> type(a) <class '__main__.A'> type(B) <type 'classobj'> type(b) <type 'instance'>


I hope that this helps.

Colin W.
Nov 8 '05 #3
Colin J. Williams a écrit :
bruno at modulix wrote:
venk wrote:
Hi,
can some one properly explain the differences between class types and
classic classes? ... Still face problems in identifying what is what.
I'm not sure I understand your question. Are you talking about the diff
between old-style and new-style classes, or the diff between classes and
metaclasses ?

"new" classes inherit from object. Classic classes do not.

(snip)
I hope that this helps.


Colin,

I don't personaly need much help with this !-) In fact, your answer is
almost the same as the one I was going to post - before I re-read the
OP's question. And I'm still not sure that what the OP is looking for.
Nov 9 '05 #4
Bruno Desthuilliers wrote:
Colin J. Williams a écrit :
bruno at modulix wrote:
venk wrote:

Hi,
can some one properly explain the differences between class types and
classic classes? ... Still face problems in identifying what is what.


I'm not sure I understand your question. Are you talking about the diff
between old-style and new-style classes, or the diff between classes and
metaclasses ?

"new" classes inherit from object. Classic classes do not.


(snip)

I hope that this helps.

Colin,

I don't personaly need much help with this !-) In fact, your answer is
almost the same as the one I was going to post - before I re-read the
OP's question. And I'm still not sure that what the OP is looking for.

Bruno,

Sorry, my reponse should have been addressed to venk.

Colin W
Nov 9 '05 #5
Dear Colin,
Forgive me for this late reply. Your explanation was of great help to
me.
Thank you very much. It was crystal clear.

Nov 11 '05 #6

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

Similar topics

18
by: Samuel Kleiner | last post by:
Is there a builtin way of making making another instance of your own class? I really expected type(self)(*args, **keywords) to work this way. Currently i'm doing this: def...
20
by: syd | last post by:
In my project, I've got dozens of similar classes with hundreds of description variables in each. In my illustrative example below, I have a Library class that contains a list of Nation classes. ...
0
by: John Perks and Sarah Mount | last post by:
I'm talk from the point of view of descriptors. Consider a.x = lambda self:None # simple function When a.x is later got, what criterion is used to see if a class (and so the func would have...
9
by: phl | last post by:
hi, I am kind of confused aobut interfaces and abstract classes. In short as I understand it, an interface is like a contract between the class and the interface, so that certain funtions must...
6
by: Kent Johnson | last post by:
Is there a way to persist a class definition (not a class instance, the actual class) so it can be restored later? A naive approach using pickle doesn't work: >>> import pickle >>> class...
7
by: for.fun | last post by:
Hi everybody, I have the following problem : B class need A::MyEnum type and A class need B::MyEnum type. In both case, the class type is incomplete so it is obvious that the ::MyEnum can not...
9
by: Rudy | last post by:
Hello All! I'm a little confused on Public Class or Modules. Say I have a this on form "A" Public Sub Subtract() Dim Invoice As Decimal Dim Wage As Decimal Static PO As Decimal Invoice =...
26
by: momobear | last post by:
hi, I am puzzled about how to determine whether an object is initilized in one class, anyone could give me any instructions? here is an example code: class coffee: def boil(self): self.temp =...
21
by: Nikolaus Rath | last post by:
Hello, Can someone explain to me the difference between a type and a class? After reading http://www.cafepy.com/article/python_types_and_objects/ it seems to me that classes and types are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
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.