473,796 Members | 2,482 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1595
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
2716
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 new(self,*args,**keywords): from new import instance s=instance(self.__class__) if hasattr(D(),'__init__'): s.__init__(*args,**keywords) return s
20
1963
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. In one case, I might want a Library class with only Nations of with the continent variable "Europe", and so I'll do something like library.getContinent('Europe') which will return a Library() instance with only European nations. Similarly, I...
0
1102
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 __get__(None, a) called on it)? Pre-metaclasses, one might assume it was isinstance(a, (types.TypeType, types.ClassType))
9
7559
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 be implemented. So if you have a class which inherits base class that inherts an interface, then your classes will have a standard. I suppose you can also check for interface at run time say when dll is loaded and see if it implememts whats...
6
1433
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 Foo(object): ... def show(self): ... print "I'm a Foo" ... >>> p = pickle.dumps(Foo) >>> p 'c__main__\nFoo\np0\n.'
7
4721
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 be found in the class definition (the compiler complains) My problem is the MyEnum types have to be defined inside the class
9
2360
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 = CDec(txbInv.Text) Wage = CDec(txbTotWage.Text)
26
1838
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 = 80 a = coffer() if a.temp 60:
21
5202
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 actually the same thing: - both are instances of a metaclass, and the same metaclass ('type') can instantiate both classes and types. - both can be instantiated and yield an "ordinary" object - I can even inherit from a type and get a class
0
9673
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
9525
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
10221
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...
1
10169
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9050
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
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
5440
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...
1
4115
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
3
2924
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.