473,795 Members | 3,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Re: class(object) and (type)??

Subclassing 'object' makes the class new-style as opposed to
old-style. object is the ultimate superclass of all new-style classes.
Old-style classes are deprecated and will be removed in Python 3.0,
but they're currently the default for backward-compatibility reasons.
See http://docs.python.org/ref/node33.html for more info.

- Chris

On Mon, Sep 8, 2008 at 2:35 PM, AON LAZIO <ao******@gmail .comwrote:
Hi again pythoners,
I notice in the class of a code having (object) and (type) attached to
the name of the class.
I know that in other cases, that means the class inherits methods and
properties from other but
In this case, what does it mean?
For example,

class PY(object):
def __init__(self):
...

class PO(type):
def __init__(self):
...
What do "object" and "type" mean?

Thanks in advance

Aonlazio

--
http://mail.python.org/mailman/listinfo/python-list


--
Follow the path of the Iguana...
http://rebertia.com
Sep 8 '08 #1
1 1126
On Mon, Sep 8, 2008 at 2:35 PM, AON LAZIO <ao******@gmail .comwrote:
Hi again pythoners,
I notice in the class of a code having (object) and (type) attached to
the name of the class.
I know that in other cases, that means the class inherits methods and
properties from other but
In this case, what does it mean?
The very same thing. Why should it have a different meaning ?

For the record :

- 'object' is the base class for 'new-style' classes - that is, the
'new' (hem) object model that came with Python 2.2 (released december
2001 - so it's not that 'new'). The old one - known as 'classic classes'
has been kept so far for backward compat only, and will finally
disappear with Python 3.x.

- 'type' is the base metaclass. Python's classes being objects, they
have to be instances of a class - known as the metaclass. To avoid
metametaclasses , metametametacla sses etc ad infinitum, 'type' is an
instance of itself. And FWIW, a subclass of 'object', which is itself an
instance of 'type' (usually, brains start melting here...)

You'll find more informations (and hopefully clearer explanations) here:
http://www.python.org/doc/newstyle/

and of course in the FineManual(tm):
http://docs.python.org/ref/datamodel.html

HTH
Sep 9 '08 #2

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

Similar topics

2
1768
by: Krzysztof Stachlewski | last post by:
I tried to run the following piece of code: Python 2.3.4 (#53, May 25 2004, 21:17:02) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> o = object() >>> o.a = 5 Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: 'object' object has no attribute 'a'
106
5617
by: A | last post by:
Hi, I have always been taught to use an inialization list for initialising data members of a class. I realize that initialsizing primitives and pointers use an inialization list is exactly the same as an assignment, but for class types it has a different effect - it calls the copy constructor. My question is when to not use an initalisation list for initialising data members of a class?
9
4813
by: justanotherguy63 | last post by:
Hi, I am designing an application where to preserve the hierachy and for code substitability, I need to pass an array of derived class object in place of an array of base class object. Since I am using vector class(STL), the compiler does not allow me to do this. I do realize there is a pitfall in this approach(size of arrays not matching etc), but I wonder how to get around this problem. I have a class hierachy with abstract base...
1
16245
by: ypjofficial | last post by:
Dear All, According to OOPs , a base class pointer can to point to derived class object....call this as fact1 But somehow I am not comfortable while understanding this concept. The explanaition to the fact1 is given as since the derived object always consists of the base part , the base class pointer will always point to the base part in the derived object unless otherwise the function in the base class are declared as virtual and are...
1
1444
by: lovecreatesbeauty | last post by:
--------- quotation --------- The default method of initialization using special member functions is to perform a bit-for-bit copy from the initializer into the object to be initialized. This technique is applicable only to: 1. Objects of built-in types. 2. Pointers. 3. References. 4. Objects of class type, where the class has no private or protected members, no virtual functions, and no base classes. --------- of of quotation ---------
6
1280
by: Brad | last post by:
I am creating a class (not a control) which implements IStateManager. I've created the class and all of the implementations (LoadView, SaveViewState, etc...). My Question is: How do I instantiate this class in a page and then re-instantiate it on post back such that I don't lose it's viewstate? If the page always uses x = new myclass to instantiate, the myclass constructor is always going to reinitialize its statebag.
3
1728
by: Tony Johansson | last post by:
Hello!! You may correct me if I have made any wrong assumptions. Below I have some simple classes. When you have this t.ToString() below it's the ToString() method in Object class that is called and when you have this t.GetType() below it's the GetType() method in the Object class that is called.
13
2426
by: docschnipp | last post by:
Hi, I have a bunch of object derived from the same base class. They all share the same constructor with some parameters. Now, instead of using a large switch() statement where I call every single Object by itself, I'd like to assign a reference to the class type and call it later without knowing the derived type. Example:
1
2198
by: archana | last post by:
Hi all, I am confuse in concept of inheritance. I am having following 2 classes class base1 { public void abc() { System.Console.WriteLine("base1 abc"); }
13
4936
by: Rahul | last post by:
Hi Everyone, I was just playing around virtual functions and landed up with the following, class Base1 { public: virtual void sample() { printf("base::sample\n");
0
9519
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
10214
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
10164
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
10001
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...
0
9042
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...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
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
4113
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
2920
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.