473,395 Members | 1,730 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,395 software developers and data experts.

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 1106
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, metametametaclasses 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
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...
106
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...
9
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...
1
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...
1
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...
6
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...
3
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...
13
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...
1
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
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,...

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.