[Tutor] Re: what is an object?
Sandip Bhattacharya
sandip at linux-delhi.org
Sat Feb 28 18:26:33 EST 2004
Christopher Spears wrote:
> fundamental question to ask. What exactly is an
> object? A part of my understands what an object is,
> but I cannot articulate this to another person.
>
There is a general Object-Oriented answer, and then there is a python
answer. ;)
Fundamentally, an object is a distinct entity or an instance of a class
of types. So if humans are a class of living beings, Christopher Spears
is an instance of the human class and can therefore be considered an
"object". ;)
Similarly, if you have a class named AClass then the following creates
two instances/objects of the same class.
a = AClass()
b = AClass()
This is how most OO based programming languages like C++/Java define
objects.
However, python extends the term "object" further - in Python even the
types are considered objects! So in the above example, even AClass is
condered an object! Even string literals ("String"), lists ([]), etc are
called as objects!
- Sandip
--
Sandip Bhattacharya
sandip (at) puroga.com
Puroga Technologies Pvt. Ltd.
Work: http://www.puroga.com Home: http://www.sandipb.net
GPG: 51A4 6C57 4BC6 8C82 6A65 AE78 B1A1 2280 A129 0FF3
More information about the Tutor
mailing list