Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91576 > unrolled thread
| Started by | Eddilbert Macharia <edd.cowan@gmail.com> |
|---|---|
| First post | 2015-05-31 07:34 -0700 |
| Last post | 2015-06-03 06:17 -0700 |
| Articles | 20 on this page of 100 — 20 participants |
Back to article view | Back to comp.lang.python
Everything is an object in python - object class and type class Eddilbert Macharia <edd.cowan@gmail.com> - 2015-05-31 07:34 -0700
Re: Everything is an object in python - object class and type class Marco Buttu <marco.buttu@gmail.com> - 2015-05-31 17:13 +0200
Re: Everything is an object in python - object class and type class Terry Reedy <tjreedy@udel.edu> - 2015-05-31 11:37 -0400
Re: Everything is an object in python - object class and type class Steven D'Aprano <steve@pearwood.info> - 2015-06-01 04:00 +1000
Re: Everything is an object in python - object class and type class "Dr. Bigcock" <dreamingforward@gmail.com> - 2015-06-01 10:35 -0700
Re: Everything is an object in python - object class and type class Eddilbert Macharia <edd.cowan@gmail.com> - 2015-05-31 17:29 -0700
Re: Everything is an object in python - object class and type class Steven D'Aprano <steve@pearwood.info> - 2015-06-01 14:09 +1000
Re: Everything is an object in python - object class and type class Eddilbert Macharia <edd.cowan@gmail.com> - 2015-05-31 20:09 -0700
Re: Everything is an object in python - object class and type class Steven D'Aprano <steve@pearwood.info> - 2015-06-01 14:24 +1000
Re: Everything is an object in python - object class and type class Eddilbert Macharia <edd.cowan@gmail.com> - 2015-06-01 05:03 -0700
Re: Everything is an object in python - object class and type class BartC <bc@freeuk.com> - 2015-06-01 23:59 +0100
Re: Everything is an object in python - object class and type class BartC <bc@freeuk.com> - 2015-06-02 11:45 +0100
Re: Everything is an object in python - object class and type class Rustom Mody <rustompmody@gmail.com> - 2015-06-02 04:16 -0700
Re: Everything is an object in python - object class and type class Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-02 09:09 -0600
Re: Everything is an object in python - object class and type class TheDoctor <dreamingforward@gmail.com> - 2015-06-01 17:24 -0700
Re: Everything is an object in python - object class and type class Chris Angelico <rosuav@gmail.com> - 2015-06-02 10:32 +1000
Re: Everything is an object in python - object class and type class TheDoctor <dreamingforward@gmail.com> - 2015-06-01 18:02 -0700
Re: Everything is an object in python - object class and type class Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-06-02 16:30 +1000
Re: Everything is an object in python - object class and type class TheDoctor <dreamingforward@gmail.com> - 2015-06-01 18:15 -0700
Re: Everything is an object in python - object class and type class Chris Angelico <rosuav@gmail.com> - 2015-06-02 11:30 +1000
Re: Everything is an object in python - object class and type class random832@fastmail.us - 2015-06-02 00:13 -0400
Re: Everything is an object in python - object class and type class Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-06-02 16:23 +1000
Re: Everything is an object in python - object class and type class Rustom Mody <rustompmody@gmail.com> - 2015-06-01 20:15 -0700
Re: Everything is an object in python - object class and type class Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-02 04:46 +0100
Re: Everything is an object in python - object class and type class TheDoctor <dreamingforward@gmail.com> - 2015-06-01 21:47 -0700
Re: Everything is an object in python - object class and type class Rustom Mody <rustompmody@gmail.com> - 2015-06-01 22:01 -0700
Religion [was Re: Everything is an object in python - object class and type class] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-06-02 16:04 +1000
Re: Religion [was Re: Everything is an object in python - object class and type class] Rustom Mody <rustompmody@gmail.com> - 2015-06-01 23:17 -0700
Re: Religion [was Re: Everything is an object in python - object class and type class] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-02 07:20 +0100
Re: Everything is an object in python - object class and type class random832@fastmail.us - 2015-06-02 00:08 -0400
Re: Everything is an object in python - object class and type class TheDoctor <dreamingforward@gmail.com> - 2015-06-01 21:54 -0700
Re: Everything is an object in python - object class and type class Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-06-02 17:12 +1000
Re: Everything is an object in python - object class and type class Rustom Mody <rustompmody@gmail.com> - 2015-06-02 00:44 -0700
Re: Everything is an object in python - object class and type class Chris Angelico <rosuav@gmail.com> - 2015-06-02 18:37 +1000
Re: Everything is an object in python - object class and type class Rustom Mody <rustompmody@gmail.com> - 2015-06-02 02:18 -0700
Re: Everything is an object in python - object class and type class Marko Rauhamaa <marko@pacujo.net> - 2015-06-02 12:23 +0300
Re: Everything is an object in python - object class and type class vern.muhr@gmail.com - 2015-06-01 14:12 -0700
Re: Everything is an object in python - object class and type class Eddilbert Macharia <edd.cowan@gmail.com> - 2015-06-02 03:36 -0700
Re: Everything is an object in python - object class and type class Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-02 12:11 +0100
Re: Everything is an object in python - object class and type class Steven D'Aprano <steve@pearwood.info> - 2015-06-02 21:27 +1000
Re: Everything is an object in python - object class and type class Rustom Mody <rustompmody@gmail.com> - 2015-06-02 04:40 -0700
Re: Everything is an object in python - object class and type class Steven D'Aprano <steve@pearwood.info> - 2015-06-03 01:08 +1000
Re: Everything is an object in python - object class and type class Rustom Mody <rustompmody@gmail.com> - 2015-06-02 09:14 -0700
Re: Everything is an object in python - object class and type class BartC <bc@freeuk.com> - 2015-06-02 13:49 +0100
Re: Everything is an object in python - object class and type class Marko Rauhamaa <marko@pacujo.net> - 2015-06-02 16:13 +0300
Re: Everything is an object in python - object class and type class Steven D'Aprano <steve@pearwood.info> - 2015-06-03 03:00 +1000
Re: Everything is an object in python - object class and type class BartC <bc@freeuk.com> - 2015-06-02 18:59 +0100
Re: Everything is an object in python - object class and type class random832@fastmail.us - 2015-06-02 14:07 -0400
Re: Everything is an object in python - object class and type class Ned Batchelder <ned@nedbatchelder.com> - 2015-06-02 11:10 -0700
Re: Everything is an object in python - object class and type class Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-02 13:36 -0600
Re: Everything is an object in python - object class and type class Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2015-06-02 18:10 +0000
Re: Everything is an object in python - object class and type class "Dr. Bigcock" <dreamingforward@gmail.com> - 2015-06-02 11:22 -0700
Re: Everything is an object in python - object class and type class Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2015-06-02 18:47 +0000
Re: Everything is an object in python - object class and type class "Dr. Bigcock" <dreamingforward@gmail.com> - 2015-06-02 12:00 -0700
Re: Everything is an object in python - object class and type class Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2015-06-02 19:31 +0000
Re: Everything is an object in python - object class and type class Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-02 13:50 -0600
Re: Everything is an object in python - object class and type class Grant Edwards <invalid@invalid.invalid> - 2015-06-02 21:19 +0000
Re: Everything is an object in python - object class and type class Marko Rauhamaa <marko@pacujo.net> - 2015-06-03 01:33 +0300
Re: Everything is an object in python - object class and type class "Dr. Bigcock" <dreamingforward@gmail.com> - 2015-06-02 15:49 -0700
Re: Everything is an object in python - object class and type class Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-06-03 18:13 +1000
Re: Everything is an object in python - object class and type class "Dr. Bigcock" <dreamingforward@gmail.com> - 2015-06-03 21:38 -0700
Re: Everything is an object in python - object class and type class Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-06-03 18:24 +1000
Re: Everything is an object in python - object class and type class Marko Rauhamaa <marko@pacujo.net> - 2015-06-03 11:57 +0300
Re: Everything is an object in python - object class and type class Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-03 07:57 -0600
Re: Everything is an object in python - object class and type class "Dr. Bigcock" <dreamingforward@gmail.com> - 2015-06-03 21:42 -0700
Re: Everything is an object in python - object class and type class "Dr. Bigcock" <dreamingforward@gmail.com> - 2015-06-02 12:58 -0700
Re: Everything is an object in python - object class and type class Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-02 22:47 +0100
Re: Everything is an object in python - object class and type class Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-02 18:49 -0600
Re: Everything is an object in python - object class and type class Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-06-03 18:32 +1000
Re: Everything is an object in python - object class and type class Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-02 13:37 -0600
Re: Everything is an object in python - object class and type class Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-06-03 18:08 +1000
Re: Everything is an object in python - object class and type class "Dr. Bigcock" <dreamingforward@gmail.com> - 2015-06-02 11:00 -0700
Re: Everything is an object in python - object class and type class Eddilbert Macharia <edd.cowan@gmail.com> - 2015-06-02 21:16 -0700
Re: Everything is an object in python - object class and type class Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-03 06:23 +0100
Re: Everything is an object in python - object class and type class BartC <bc@freeuk.com> - 2015-06-03 11:20 +0100
Re: Everything is an object in python - object class and type class Chris Angelico <rosuav@gmail.com> - 2015-06-03 20:38 +1000
Re: Everything is an object in python - object class and type class BartC <bc@freeuk.com> - 2015-06-03 12:08 +0100
Re: Everything is an object in python - object class and type class Marko Rauhamaa <marko@pacujo.net> - 2015-06-03 15:08 +0300
Re: Everything is an object in python - object class and type class BartC <bc@freeuk.com> - 2015-06-03 17:00 +0100
Re: Everything is an object in python - object class and type class Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-03 17:29 +0100
Re: Everything is an object in python - object class and type class BartC <bc@freeuk.com> - 2015-06-03 19:59 +0100
Re: Everything is an object in python - object class and type class Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-03 21:58 +0100
Re: Everything is an object in python - object class and type class BartC <bc@freeuk.com> - 2015-06-03 22:33 +0100
Re: Everything is an object in python - object class and type class Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-03 22:49 +0100
Re: Everything is an object in python - object class and type class BartC <bc@freeuk.com> - 2015-06-04 00:04 +0100
Re: Everything is an object in python - object class and type class Laura Creighton <lac@openend.se> - 2015-06-04 12:06 +0200
Re: Everything is an object in python - object class and type class BartC <bc@freeuk.com> - 2015-06-04 13:01 +0100
Re: Everything is an object in python - object class and type class Laura Creighton <lac@openend.se> - 2015-06-04 15:39 +0200
Re: Everything is an object in python - object class and type class "Dr. Bigcock" <dreamingforward@gmail.com> - 2015-06-03 21:50 -0700
Re: Everything is an object in python - object class and type class Eddilbert Macharia <edd.cowan@gmail.com> - 2015-06-03 22:43 -0700
Re: Everything is an object in python - object class and type class Michael Torrie <torriem@gmail.com> - 2015-06-03 10:36 -0600
Re: Everything is an object in python - object class and type class BartC <bc@freeuk.com> - 2015-06-03 18:26 +0100
Re: Everything is an object in python - object class and type class Steven D'Aprano <steve@pearwood.info> - 2015-06-05 00:11 +1000
Re: Everything is an object in python - object class and type class Terry Reedy <tjreedy@udel.edu> - 2015-06-03 13:17 -0400
Re: Everything is an object in python - object class and type class Chris Angelico <rosuav@gmail.com> - 2015-06-03 22:19 +1000
Re: Everything is an object in python - object class and type class Marco Buttu <marco.buttu@gmail.com> - 2015-06-03 14:10 +0200
Re: Everything is an object in python - object class and type class BartC <bc@freeuk.com> - 2015-06-03 12:13 +0100
Re: Everything is an object in python - object class and type class Terry Reedy <tjreedy@udel.edu> - 2015-06-03 13:05 -0400
Re: Everything is an object in python - object class and type class Terry Reedy <tjreedy@udel.edu> - 2015-06-02 12:23 -0400
Re: Everything is an object in python - object class and type class Eddilbert Macharia <edd.cowan@gmail.com> - 2015-06-03 06:17 -0700
Page 2 of 5 — ← Prev page 1 [2] 3 4 5 Next page →
| From | random832@fastmail.us |
|---|---|
| Date | 2015-06-02 00:13 -0400 |
| Message-ID | <mailman.40.1433218429.13271.python-list@python.org> |
| In reply to | #91753 |
On Mon, Jun 1, 2015, at 21:15, TheDoctor wrote: > In Python 2.7 type(type) is type (not object), but isinstance(type, > object) is true -- so it is ambiguous, even contradictory, in the > language. isinstance(type, object) is true because object is the parent class of type. issubclass(type, object) is also true, and that is why isinstance(int, object) is true. There is no more contradiction than in anything else being an instance of its own class, its parent class, that class's parent class, and ultimately... well, object. type in object.__subclasses__() is also true. type.__base__ is object. I could go on.
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2015-06-02 16:23 +1000 |
| Message-ID | <556d4bd2$0$12899$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #91753 |
On Tuesday 02 June 2015 11:15, TheDoctor wrote: > A type is not an object. Yes it is. py> isinstance(type, object) True py> isinstance(int, object) True > You see it as one, because you are MENTALLY > lexing your own code on the screen. No, I see it as one, because it is one. > But python does not define a type. Of course it does. py> isinstance(int, type) # int is a type True py> isinstance(42, type) # 42 is not a type False > It defines certain primitives, like strings and integers. But it doesn't > define what an OBJECT is. In one sense, it does: something is an object if it is an instance of type "object". In another sense, it doesn't, because the definition of "object" is bigger than Python and exists outside of Python. Python had objects before it had a built-in type called "object". > So you and everyone else are beating around the > bush trying to define something that the LANGUAGE ITSELF doesn't define. Incorrect. > In Python 2.7 type(type) is type (not object), but isinstance(type, > object) is true -- so it is ambiguous, even contradictory, in the > language. No, it is not ambiguous nor contradictory. It just means that types (classes), include type itself, are *both* types AND objects. Which is the whole point of saying that everything is an object! This is not true in all Object Oriented languages, for instance it is not true in Java, but it is true in Python. Notice that we do NOT say that "everything is a type": py> isinstance(42, type) False In Python, all types (classes) are objects, but not all objects (instances) are types. -- Steve
[toc] | [prev] | [next] | [standalone]
| From | Rustom Mody <rustompmody@gmail.com> |
|---|---|
| Date | 2015-06-01 20:15 -0700 |
| Message-ID | <74537c3e-7b7e-4418-a14c-557874e6933f@googlegroups.com> |
| In reply to | #91735 |
Two unrelated points: On Tuesday, June 2, 2015 at 5:54:43 AM UTC+5:30, TheDoctor wrote: > On Monday, June 1, 2015 at 7:03:49 AM UTC-5, Eddilbert Macharia wrote: > > I think i kind of understand now. > > > > Instead of python having data types like int, string, e.t.c it has two primitive types which are class type and class object which are created by python interpreter during its setup .using this two classes python is able to create some more data types > > Eddibert, don't let this crowd (Terry, Stephen, et al.) confuse you. They are as confused about it as you are. > > The truth is, that they've told a lie to themselves (everything is an object) to hide some details FROM THEMSELVES in their model. They climb a ladder of ambiguity anytime there's a new problem in their model and call it a "type", or they pull out the "metaclass" term (because no one really knows that that is, so they feel *pretty* safe). > > A type is not an object in the same way an instantiated type is an object -- anymore than a blueprint for a building is the building itself. Point 1 Yes. You may be onto something here Mark [I assume that's your name]. Some very intelligent people have suggested that the sloppy use of 'is' causes more misunderstanding than any useful communication. See http://en.wikipedia.org/wiki/E-Prime. And in "Gödel, the Mind and the Laws of Physics" Roger Penrose draws a picture of Three worlds and the mysteries that connect them http://sustainedreaction.yuku.com/topic/4931/Three-Worlds-Three-Mysteries#.VW0b9rzGI8o 1. The mathematical world 2. The mental world 3. The physical world which means that the 'is' in each is different. As enumerated here http://blog.languager.org/2015/03/cs-history-0.html the history and very existence of CS has arisen from grapping with these questions. Point 2: [unrelated to the content of the OP] You may wish to consider whether your style and the names you keep assuming and changing are helping you. Best I can see many people have begun to killfile you.
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2015-06-02 04:46 +0100 |
| Message-ID | <mailman.38.1433217271.13271.python-list@python.org> |
| In reply to | #91776 |
On 02/06/2015 04:15, Rustom Mody wrote: > Two unrelated points: > > On Tuesday, June 2, 2015 at 5:54:43 AM UTC+5:30, TheDoctor wrote: >> On Monday, June 1, 2015 at 7:03:49 AM UTC-5, Eddilbert Macharia wrote: >>> I think i kind of understand now. >>> >>> Instead of python having data types like int, string, e.t.c it has two primitive types which are class type and class object which are created by python interpreter during its setup .using this two classes python is able to create some more data types >> >> Eddibert, don't let this crowd (Terry, Stephen, et al.) confuse you. They are as confused about it as you are. >> >> The truth is, that they've told a lie to themselves (everything is an object) to hide some details FROM THEMSELVES in their model. They climb a ladder of ambiguity anytime there's a new problem in their model and call it a "type", or they pull out the "metaclass" term (because no one really knows that that is, so they feel *pretty* safe). >> >> A type is not an object in the same way an instantiated type is an object -- anymore than a blueprint for a building is the building itself. > > Point 1 > > Yes. You may be onto something here Mark [I assume that's your name]. > Some very intelligent people have suggested that the sloppy use of 'is' > causes more misunderstanding than any useful communication. > See http://en.wikipedia.org/wiki/E-Prime. > I thought it was our pot smoking hippy back under another name. he seems to have more lives than a black cat and a phoenix combined. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | TheDoctor <dreamingforward@gmail.com> |
|---|---|
| Date | 2015-06-01 21:47 -0700 |
| Message-ID | <f21fdb69-d90b-4d33-8ad7-c961ba3b28f0@googlegroups.com> |
| In reply to | #91776 |
> > A type is not an object in the same way an instantiated type is an object -- anymore than a blueprint for a building is the building itself. > > Point 1 > > Yes. You may be onto something here Mark [I assume that's your name]. > Some very intelligent people have suggested that the sloppy use of 'is' > causes more misunderstanding than any useful communication. > See http://en.wikipedia.org/wiki/E-Prime. Ah, yes. Very good. Probably relevant. > And in "Gödel, the Mind and the Laws of Physics" Roger Penrose draws a picture > of Three worlds and the mysteries that connect them > http://sustainedreaction.yuku.com/topic/4931/Three-Worlds-Three-Mysteries#.VW0b9rzGI8o Amazing you reference that site. I used to interact with Ghost Dog who's referenced at the bottom of that post. Are you familiar with sustainedaction.org? > 1. The mathematical world > 2. The mental world > 3. The physical world > > which means that the 'is' in each is different. Yes. That's good. > As enumerated here http://blog.languager.org/2015/03/cs-history-0.html > the history and very existence of CS has arisen from grapping with these questions. Interesting, will read up more. > Point 2: [unrelated to the content of the OP] > You may wish to consider whether your style and the names you keep assuming > and changing are helping you. Best I can see many people have begun to killfile you. Yes, I know. The names change based on mood. The canonical address remains the same. People are dumb, but perhaps I am dumb for treating them as equals. Perhaps that's not a fair assumption. I thought it was polite. It's quite clear, that there's a bit of religion here and when I come in and point it out, they pull out their Bible and cast me out. I get too weary to explain more. You know how it is arguing to evangelical Christians. Perhaps another time. Mark, one of my real names.
[toc] | [prev] | [next] | [standalone]
| From | Rustom Mody <rustompmody@gmail.com> |
|---|---|
| Date | 2015-06-01 22:01 -0700 |
| Message-ID | <96a55389-5d7a-4593-8e3d-b52e9ff8af87@googlegroups.com> |
| In reply to | #91790 |
On Tuesday, June 2, 2015 at 10:17:55 AM UTC+5:30, TheDoctor wrote: > > Mark, one of my real names. Thanks -- that helps. > People are dumb, but perhaps I am dumb for treating them as equals. Perhaps > that's not a fair assumption. That doesn't. > It's quite clear, that there's a bit of religion here and when I come in and point it out, they pull out their Bible and cast me out. > > I get too weary to explain more. You know how it is arguing to evangelical Christians. Perhaps another time. Do realize that this is an internation list and so a word like 'religion' with wildly different connotations in different cultures does not usually aid communication. [Sarcasm can communicate when there is a large shared culture else fails miserably] eg Would it make sense to you if you were told that there are widespread religions like Buddhism that are agnostic or Jainism that are strictly atheistic?
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2015-06-02 16:04 +1000 |
| Subject | Religion [was Re: Everything is an object in python - object class and type class] |
| Message-ID | <556d4766$0$12918$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #91794 |
On Tuesday 02 June 2015 15:01, Rustom Mody wrote: > eg Would it make sense to you if you were told that there are widespread > religions like Buddhism that are agnostic or Jainism that are strictly > atheistic? No of course it wouldn't make sense. But nothing to do with religion, spirituality and superstition makes sense, the whole point of them is that they speak to the emotions, not logic. (You note that I am carefully not commenting on whether this is a good thing or not.) Draw up two sets of overlapping axes, and label the vertical axes "Agnosticism / Gnosticism" and the horizontal axes "Supernatural / Natural". Belief systems can be found in all four quadrants. Agnostic religions are easy, they're just in the Supernatural+Agnostic quadrant. If you define religion to be merely any belief system, then even an atheist religion is understandable: it could be anything on the Natural half of the graph. Personally, I consider that redefining religion to refer to belief systems which do not include supernatural divine gods is an abuse of language (except informally, as in "football is my religion" or "the religious war between Vi and Emacs users"). it's like the food processor that is advertised as being a "three speed food-processor" because there are three settings on the control: High, Low and OFF. -- Steve
[toc] | [prev] | [next] | [standalone]
| From | Rustom Mody <rustompmody@gmail.com> |
|---|---|
| Date | 2015-06-01 23:17 -0700 |
| Subject | Re: Religion [was Re: Everything is an object in python - object class and type class] |
| Message-ID | <8f91f88b-de16-46ad-8e2f-e9b28bd19fec@googlegroups.com> |
| In reply to | #91798 |
On Tuesday, June 2, 2015 at 11:34:34 AM UTC+5:30, Steven D'Aprano wrote: > On Tuesday 02 June 2015 15:01, Rustom Mody wrote: > > > eg Would it make sense to you if you were told that there are widespread > > religions like Buddhism that are agnostic or Jainism that are strictly > > atheistic? > > No of course it wouldn't make sense. But nothing to do with religion, > spirituality and superstition makes sense, the whole point of them is that > they speak to the emotions, not logic. Emotions dont make sense? In what sense of 'sense'? If understanding rather than pronouncing is your intention this may help: http://en.wikipedia.org/wiki/Triune_brain [You may remember a recent poster with the moniker 'PointedEars' in his name making wild emotional outbursts. So much for 20th century movie-mythology] (You note that I am carefully not > commenting on whether this is a good thing or not.) > > Draw up two sets of overlapping axes, and label the vertical axes > "Agnosticism / Gnosticism" and the horizontal axes "Supernatural / Natural". > Belief systems can be found in all four quadrants. Agnostic religions are > easy, they're just in the Supernatural+Agnostic quadrant. If you define > religion to be merely any belief system, then even an atheist religion is > understandable: it could be anything on the Natural half of the graph. > > Personally, I consider that redefining religion to refer to belief systems > which do not include supernatural divine gods is an abuse of language > (except informally, as in "football is my religion" or "the religious war > between Vi and Emacs users"). it's like the food processor that is > advertised as being a "three speed food-processor" because there are three > settings on the control: High, Low and OFF. > I am reminded of the TinTin(?) comic: Telescope informs about a giant alien coming to invade from outer space. Further examination of telescope shows 'alien' to be a bug (not the software variety) in the telescope.
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2015-06-02 07:20 +0100 |
| Subject | Re: Religion [was Re: Everything is an object in python - object class and type class] |
| Message-ID | <mailman.45.1433226023.13271.python-list@python.org> |
| In reply to | #91798 |
On 02/06/2015 07:04, Steven D'Aprano wrote: > On Tuesday 02 June 2015 15:01, Rustom Mody wrote: > >> eg Would it make sense to you if you were told that there are widespread >> religions like Buddhism that are agnostic or Jainism that are strictly >> atheistic? > > No of course it wouldn't make sense. But nothing to do with religion, > spirituality and superstition makes sense, the whole point of them is that > they speak to the emotions, not logic. (You note that I am carefully not > commenting on whether this is a good thing or not.) > > Draw up two sets of overlapping axes, and label the vertical axes > "Agnosticism / Gnosticism" and the horizontal axes "Supernatural / Natural". > Belief systems can be found in all four quadrants. Agnostic religions are > easy, they're just in the Supernatural+Agnostic quadrant. If you define > religion to be merely any belief system, then even an atheist religion is > understandable: it could be anything on the Natural half of the graph. > > Personally, I consider that redefining religion to refer to belief systems > which do not include supernatural divine gods is an abuse of language > (except informally, as in "football is my religion" or "the religious war > between Vi and Emacs users"). it's like the food processor that is > advertised as being a "three speed food-processor" because there are three > settings on the control: High, Low and OFF. > > If anybody wishes to discuss this can they please take it off list, as it surely has no place here when we're meant to be discussing the Python programming langauge. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | random832@fastmail.us |
|---|---|
| Date | 2015-06-02 00:08 -0400 |
| Message-ID | <mailman.39.1433218133.13271.python-list@python.org> |
| In reply to | #91735 |
On Mon, Jun 1, 2015, at 20:24, TheDoctor wrote: > A type is not an object in the same way an instantiated type is an object > -- anymore than a blueprint for a building is the building itself. What is an object? It's something you can call str or repr on. It's something you can lookup attributes from its internal dictionary and call methods on. It's something you can compare whether it's == to something else. It's something you can pass as a parameter to a function In many languages, you can't do any of these things (or their equivalents for those languages) to a type. In others, you have to get a special "class object" that isn't _really_ the same thing as the type itself, via some special syntax like typeof(Foo) or Foo.class, and can only work with it through magic methods in a certain module. In python, you can. Why is this bad or confusing?
[toc] | [prev] | [next] | [standalone]
| From | TheDoctor <dreamingforward@gmail.com> |
|---|---|
| Date | 2015-06-01 21:54 -0700 |
| Message-ID | <5a959fda-25ac-4cd8-a8e4-f0d10fbf0ed0@googlegroups.com> |
| In reply to | #91781 |
On Monday, June 1, 2015 at 11:09:09 PM UTC-5, rand...@fastmail.us wrote: > On Mon, Jun 1, 2015, at 20:24, TheDoctor wrote: > > A type is not an object in the same way an instantiated type is an object > > -- anymore than a blueprint for a building is the building itself. > > What is an object? > > It's something you can call str or repr on. It's something you can > lookup attributes from its internal dictionary and call methods on. It's > something you can compare whether it's == to something else. It's > something you can pass as a parameter to a function That's good material for relating to the issue. I wish I could justify my position better, but it gets into non-computational arguments. > In many languages, you can't do any of these things (or their > equivalents for those languages) to a type. In others, you have to get a > special "class object" that isn't _really_ the same thing as the type > itself, via some special syntax like typeof(Foo) or Foo.class, and can > only work with it through magic methods in a certain module. > > In python, you can. Why is this bad or confusing? It breaks a conceptual barrier. It's like the difference between seeing an ASCII character symbol and knowing the 8-bit binary digits. One is a name, the other is the data. That's an important distinction and they shouldn't be confused in the machine (which can't happen because the machine already creates that boundary). In the case of the reader though, they can get confused -- they're not interchangeable. They get "lexed" in the head very differently. Mark
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2015-06-02 17:12 +1000 |
| Message-ID | <556d574f$0$12905$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #91735 |
On Tuesday 02 June 2015 10:24, TheDoctor wrote: > A type is not an object in the same way an instantiated type is an object > -- anymore than a blueprint for a building is the building itself. Nobody says that blueprints are *buildings*. But buildings are not the only kind of object that exists. Plates and spoons and knives and forks are objects. Cars and trucks and ships and planes are objects. Books and shoes and maps and compasses are objects. Buildings are objects. And blueprints of buildings are objects too. > The reason this confusion appears is for the exact reason I said on an > earlier thread: Python does not define classes in it's grammar Of course it does. Otherwise "class K: pass" would give you a syntax error. > -- so it > can't account for the difference between an [instantiated] object and it's > definition/type. Of course it can and does. Python has a rich set of tools for introspecting values and determining whether they are instances or classes, what they are an instance of, and viewing the differences between the type and the class, starting with the humble human-readable string representation: py> type(23) <class 'int'> and going on isinstance, issubclass, vars(), dir(), the inspect module, the dis module, and more. The simplest test to tell whether something is an instance (an object) is: isinstance(the_thing, object) and that returns True *always*. The next test is to check whether it is a class (a type): isinstance(the_thing, type) which returns True only for classes and types. So, classes *are* objects, as well as being classes -- just as dogs are mammals, as well as being dogs. -- Steve
[toc] | [prev] | [next] | [standalone]
| From | Rustom Mody <rustompmody@gmail.com> |
|---|---|
| Date | 2015-06-02 00:44 -0700 |
| Message-ID | <3d06de71-a517-4cac-be12-a61813465735@googlegroups.com> |
| In reply to | #91804 |
On Tuesday, June 2, 2015 at 12:42:31 PM UTC+5:30, Steven D'Aprano wrote:
> On Tuesday 02 June 2015 10:24, TheDoctor wrote:
>
> > A type is not an object in the same way an instantiated type is an object
> > -- anymore than a blueprint for a building is the building itself.
>
> Nobody says that blueprints are *buildings*. But buildings are not the only
> kind of object that exists.
>
> Plates and spoons and knives and forks are objects.
> Cars and trucks and ships and planes are objects.
> Books and shoes and maps and compasses are objects.
> Buildings are objects.
> And blueprints of buildings are objects too.
You are using 'are' as if they are all the same 'are'. Are they?
Consider the type int.
It is supposed to model mathematical integers.
ie 1 ∈ int (in some sense)
Consider the generator
def int2():
i = 0
yield i
while True:
yield i
yield -i
1 ∈ int2 [Not to mention 1 ∈ int2()]
Consider range(10) (in python2 and 3)
And finally [1,2,3,4]
1 ∈ all these
Are the '∈'s here same? Similar?
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2015-06-02 18:37 +1000 |
| Message-ID | <mailman.48.1433234251.13271.python-list@python.org> |
| In reply to | #91809 |
On Tue, Jun 2, 2015 at 5:44 PM, Rustom Mody <rustompmody@gmail.com> wrote:
>> Plates and spoons and knives and forks are objects.
>> Cars and trucks and ships and planes are objects.
>> Books and shoes and maps and compasses are objects.
>> Buildings are objects.
>> And blueprints of buildings are objects too.
>
> You are using 'are' as if they are all the same 'are'. Are they?
> Consider the type int.
> It is supposed to model mathematical integers.
> ie 1 ∈ int (in some sense)
>
> Consider the generator
> def int2():
> i = 0
> yield i
> while True:
> yield i
> yield -i
>
> 1 ∈ int2 [Not to mention 1 ∈ int2()]
>
> Consider range(10) (in python2 and 3)
> And finally [1,2,3,4]
>
> 1 ∈ all these
> Are the '∈'s here same? Similar?
Yes, they are. Every one of them is asserting (or asking, depending on
your point of view) whether or not the instance to its left is a
member of the set to its right. The sets on the right are all
different, but the set membership operation is identical.
But even more so: The original collection of statements ("are
objects") all used the same RHS. In exactly the same senses, all of
those examples were testing for the same "objectness". (Although you
could argue that Steven's examples were talking about subclass
relationships rather than instance relationships, but really, an
instanceof relationship is a special case of subclass, where the class
on the left is defined by some form of object identity. Stating "All
books are objects" is a subclass relationship; stating "This book is
an object" is an instanceof relationship; both assertions use the same
meaning of "object(s)".)
All shoes are objects.
All ships are objects.
All lumps of sealing-wax are objects.
All cabbages are objects.
All kings are objects. (Some kings are also subjects, but not many.)
I can pick up a shoe, I can look at it, I can verify that it has
certain attributes common to all objects (location, mass, etc).
Superman can do the same with a ship (they're a bit big for me to pick
up). The actions you can perform on all objects are the attributes of
objects in general. Some subclasses of object may provide additional
actions (you can tip a king, for instance), but you can still do all
of these actions, so they're all the same type of object.
Note that not one iota of this has anything to do with Python's
documentation, its rules, its behaviour, or anything. Python follows
the natural expectations of our universe. The standard actions that
can be performed on Python objects are slightly different from the
standard actions that can be performed in Dungeons and Dragons, and
different again from the standard actions of the world we live in, but
they are no less applicable to all objects in that hierarchy:
* You can bind a name to an object (any object).
* You can pass an object as a function parameter.
* You can return an object from a function.
* You can reference objects in other objects' attributes.
* You can distinguish one object from another (that is, objects have
unique identities).
(In CPython, you can recognize an object by its GC header - an object
invariably has a reference count and so on. This is not a fundamental
attribute of objects, but it's a way to recognize them.)
Not everything that Python uses is an object. Syntax is not, itself,
manipulable; you can represent a syntax tree with either source code
(as a string) or an AST object, but syntax itself is not something you
can grasp. You can't assign "foo = def" in Python. But anything that
you can work with, in any way, is an object - and is an instance of
(some subclass of) the type 'object'. So, yes: They ARE all the same
meaning of "are" and "objects".
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Rustom Mody <rustompmody@gmail.com> |
|---|---|
| Date | 2015-06-02 02:18 -0700 |
| Message-ID | <08e0d883-95ce-4101-8330-3bc6832c8033@googlegroups.com> |
| In reply to | #91810 |
On Tuesday, June 2, 2015 at 2:08:08 PM UTC+5:30, Chris Angelico wrote:
> On Tue, Jun 2, 2015 at 5:44 PM, Rustom Mody wrote:
> >> Plates and spoons and knives and forks are objects.
> >> Cars and trucks and ships and planes are objects.
> >> Books and shoes and maps and compasses are objects.
> >> Buildings are objects.
> >> And blueprints of buildings are objects too.
> >
> > You are using 'are' as if they are all the same 'are'. Are they?
> > Consider the type int.
> > It is supposed to model mathematical integers.
> > ie 1 ∈ int (in some sense)
> >
> > Consider the generator
> > def int2():
> > i = 0
> > yield i
> > while True:
> > yield i
> > yield -i
> >
> > 1 ∈ int2 [Not to mention 1 ∈ int2()]
> >
> > Consider range(10) (in python2 and 3)
> > And finally [1,2,3,4]
> >
> > 1 ∈ all these
> > Are the '∈'s here same? Similar?
>
> Yes, they are. Every one of them is asserting (or asking, depending on
> your point of view) whether or not the instance to its left is a
> member of the set to its right. The sets on the right are all
> different, but the set membership operation is identical.
>
> But even more so: The original collection of statements ("are
> objects") all used the same RHS. In exactly the same senses, all of
> those examples were testing for the same "objectness". (Although you
> could argue that Steven's examples were talking about subclass
> relationships rather than instance relationships, but really, an
> instanceof relationship is a special case of subclass, where the class
> on the left is defined by some form of object identity. Stating "All
> books are objects" is a subclass relationship; stating "This book is
> an object" is an instanceof relationship; both assertions use the same
> meaning of "object(s)".)
>
> All shoes are objects.
> All ships are objects.
> All lumps of sealing-wax are objects.
> All cabbages are objects.
> All kings are objects. (Some kings are also subjects, but not many.)
>
> I can pick up a shoe, I can look at it, I can verify that it has
> certain attributes common to all objects (location, mass, etc).
> Superman can do the same with a ship (they're a bit big for me to pick
> up). The actions you can perform on all objects are the attributes of
> objects in general. Some subclasses of object may provide additional
> actions (you can tip a king, for instance), but you can still do all
> of these actions, so they're all the same type of object.
>
> Note that not one iota of this has anything to do with Python's
> documentation, its rules, its behaviour, or anything. Python follows
> the natural expectations of our universe. The standard actions that
> can be performed on Python objects are slightly different from the
> standard actions that can be performed in Dungeons and Dragons, and
> different again from the standard actions of the world we live in, but
> they are no less applicable to all objects in that hierarchy:
>
> * You can bind a name to an object (any object).
> * You can pass an object as a function parameter.
> * You can return an object from a function.
> * You can reference objects in other objects' attributes.
> * You can distinguish one object from another (that is, objects have
> unique identities).
>
> (In CPython, you can recognize an object by its GC header - an object
> invariably has a reference count and so on. This is not a fundamental
> attribute of objects, but it's a way to recognize them.)
>
> Not everything that Python uses is an object. Syntax is not, itself,
> manipulable; you can represent a syntax tree with either source code
> (as a string) or an AST object, but syntax itself is not something you
> can grasp. You can't assign "foo = def" in Python. But anything that
> you can work with, in any way, is an object - and is an instance of
> (some subclass of) the type 'object'. So, yes: They ARE all the same
> meaning of "are" and "objects".
Lets take this practically.
>>> isinstance(1,int)
True
>>> 1 in [1,2,3]
True
>>> def int2():
... i = 0
... while True:
... yield i
... i += 1
>>> 1 in int2()
True
>>>
>>> 1 in range(10)
True
4 True-returning python expressions. 5 if you consider that range in python 2
and 3 are quite different.
Do you consider the computational processes evoked (in the CPython sources) by
these 4 statements to be the same?
[Hint: What does
>>> "shoes" in int2()
return?
And try to take care to distinguish computational from ontological answer
]
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2015-06-02 12:23 +0300 |
| Message-ID | <87zj4i79b5.fsf@elektro.pacujo.net> |
| In reply to | #91810 |
Chris Angelico <rosuav@gmail.com>:
> On Tue, Jun 2, 2015 at 5:44 PM, Rustom Mody <rustompmody@gmail.com> wrote:
>> 1 ∈ all these
>> Are the '∈'s here same? Similar?
>
> Yes, they are. Every one of them is asserting (or asking, depending on
> your point of view) whether or not the instance to its left is a
> member of the set to its right. The sets on the right are all
> different, but the set membership operation is identical.
That is the risk of taking classes into Python. People start to obsess
about membership and ontological relationships. I think you should use
the type() function only for troubleshooting and isinstance() virtually
never.
I think objects should be understood only through their operational
semantics, ie, their methods. It doesn't matter what an object is; what
matters is what it does. Don't test it, just call it.
Yeah, I'm preaching to the choir:
Alex Martelli made an early (2000) use of the term in a message to
the comp.lang.python newsgroup:
In other words, don't check whether it IS-a duck: check whether
it QUACKS-like-a duck, WALKS-like-a duck, etc, etc, depending on
exactly what subset of duck-like behaviour you need to play your
language-games with.
<URL: http://en.wikipedia.org/wiki/Duck_typing>
Marko
PS I have written code that violates my stated rule. For example, an
argument could be a string or a list of strings for convenience.
However, this kind of testing should not be performed on anything
created with the "class" keyword. IOW, some types *are* more primitive
than others -- in our minds and in practical use.
[toc] | [prev] | [next] | [standalone]
| From | vern.muhr@gmail.com |
|---|---|
| Date | 2015-06-01 14:12 -0700 |
| Message-ID | <3096a7a0-12dd-4e4a-a239-1be3766a067c@googlegroups.com> |
| In reply to | #91576 |
On Sunday, May 31, 2015 at 7:34:20 AM UTC-7, Eddilbert Macharia wrote:
> Hello All ,
>
> I'm wrecking my head trying to understand. where the class object comes into play .
>
> Is it only meant to act as base class and does it mean there is an actual class called object in python which all the objects created using the class type inherit ?
>
> i'm assuming the metaclass if simplified would look something like this :
>
> type('dict', (object,),{})
>
> And when we use the class type as a metaclass are we using the instance version of the class type or are we actually using the type class itself ?
>
> Also when we say everything is an object in python, are we referring to the fact that everything is an instance of the class type or does it have to with the object class inherited ?
>
> As can be attested by using type() function as below :
>
> >>> type(int)
> <class 'type'>
> >>> type(list)
> <class 'type'>
> >>> type(dict)
> <class 'type'>
> >>> type(type)
> <class 'type'>
> >>> type(object)
> <class 'type'>
>
> From my understanding this means all of this are instances of the class type. which means the class type was used to create this instances.
>
> Now if i look at the __bases__ of all this objects i get :
>
> >>> type.__base__
> <class 'object'>
> >>> type.__bases__
> (<class 'object'>,)
> >>> dict.__bases__
> (<class 'object'>,)
> >>> list.__bases__
> (<class 'object'>,)
> >>> int.__bases__
> (<class 'object'>,)
> >>> object.__bases__
> ()
>
> This tells me that all of this objects inherit from the class object which has nothing to do with them being instances.
It may be helpful to try "dir(object)" to see what methods object provides to all those other classes.
Best regards, Vern
[toc] | [prev] | [next] | [standalone]
| From | Eddilbert Macharia <edd.cowan@gmail.com> |
|---|---|
| Date | 2015-06-02 03:36 -0700 |
| Message-ID | <48fc36e9-fa67-45d5-9864-0921b7e819ce@googlegroups.com> |
| In reply to | #91576 |
On Sunday, May 31, 2015 at 5:34:20 PM UTC+3, Eddilbert Macharia wrote:
> Hello All ,
>
> I'm wrecking my head trying to understand. where the class object comes into play .
>
> Is it only meant to act as base class and does it mean there is an actual class called object in python which all the objects created using the class type inherit ?
>
> i'm assuming the metaclass if simplified would look something like this :
>
> type('dict', (object,),{})
>
> And when we use the class type as a metaclass are we using the instance version of the class type or are we actually using the type class itself ?
>
> Also when we say everything is an object in python, are we referring to the fact that everything is an instance of the class type or does it have to with the object class inherited ?
>
> As can be attested by using type() function as below :
>
> >>> type(int)
> <class 'type'>
> >>> type(list)
> <class 'type'>
> >>> type(dict)
> <class 'type'>
> >>> type(type)
> <class 'type'>
> >>> type(object)
> <class 'type'>
>
> From my understanding this means all of this are instances of the class type. which means the class type was used to create this instances.
>
> Now if i look at the __bases__ of all this objects i get :
>
> >>> type.__base__
> <class 'object'>
> >>> type.__bases__
> (<class 'object'>,)
> >>> dict.__bases__
> (<class 'object'>,)
> >>> list.__bases__
> (<class 'object'>,)
> >>> int.__bases__
> (<class 'object'>,)
> >>> object.__bases__
> ()
>
> This tells me that all of this objects inherit from the class object which has nothing to do with them being instances.
you guys are just confusing me, you are going in loops, and still i have understood ,what makes everything in python an object.
hey is where i'm at :
*** type in python refers to data types e.g. int, str, boolean e.t.c. right ?
*** The interpreter creates two classes type and object when setting up a python environment. right ?
*** The creator (metaclass) of all data types (i.e. int,str) in python is the class type. right ?
>>> isinstance(int,type)
True
*** The instance of class type is a data type an instance of class type. right ?
>>> type(type)
<class 'type'>
>>> isinstance(type,type)
True
*** Class type gets some of its behavior from class object through inheritance.right ?
>>> issubclass(type,object)
True
*** instance of class object is type, in the sense it created using class type which inherits from class object.right ?
>>> isinstance(object,type)
True
>>> isinstance(object,object)
True
****so is it right to say, everything in python is an object because they are instance of the class type which inherits from class object ?
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2015-06-02 12:11 +0100 |
| Message-ID | <mailman.51.1433243541.13271.python-list@python.org> |
| In reply to | #91817 |
On 02/06/2015 11:36, Eddilbert Macharia wrote: > > you guys are just confusing me, you are going in loops, and still i have understood ,what makes everything in python an object. After 14 or more years writing Python I can't really answer that and quite frankly it doesn't worry me as I can quite happily write working code, what with practicality beating purity and all that. Does it worry you that much? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve@pearwood.info> |
|---|---|
| Date | 2015-06-02 21:27 +1000 |
| Message-ID | <556d931a$0$12991$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #91817 |
On Tue, 2 Jun 2015 08:36 pm, Eddilbert Macharia wrote:
> you guys are just confusing me, you are going in loops, and still i have
> understood ,what makes everything in python an object. hey is where i'm at
> : *** type in python refers to data types e.g. int, str, boolean e.t.c.
> right ?
Yes. Also classes you create with the "class" keyword:
class K(object):
...
K is now a "type", just like int, str, list, object, etc.
> *** The interpreter creates two classes type and object when setting up a
> python environment. right ?
Many more than just two: it also creates list, str, dict, etc. But *first*
it has to create type and object. So you are correct.
> *** The creator (metaclass) of all data types (i.e. int,str) in python is
> the class type. right ?
Correct.
[Aside: I'm only talking about Python 3 here. In Python 2 there is also a
second hierarchy of classes, called "classic classes" or "old-style
classes", which are *not* subclasses of type. But let's just ignore them,
because they are gone in the most recent versions of Python.]
>>>> isinstance(int,type)
> True
>
> *** The instance of class type is a data type an instance of class type.
> right ?
>>>> type(type)
> <class 'type'>
type has many instances, not just one.
Instances of int are individual ints, like 0, 1, 2, 3, ...
Instances of type are individual types, like int, dict, str, list, ...
But one of those many instances of type is, yes, type itself! So *one* of
the instances of type is type, which is also an instance of itself:
>>>> isinstance(type,type)
> True
Correct. This makes type special. Most types are *not* instances of
themselves:
py> isinstance(int, int)
False
> *** Class type gets some of its behavior from class object through
> inheritance.right ?
>
>>>> issubclass(type,object)
> True
Correct.
> *** instance of class object is type, in the sense it created using class
> type which inherits from class object.right ?
>
>>>> isinstance(object,type)
> True
>>>> isinstance(object,object)
> True
>
> ****so is it right to say, everything in python is an object because they
> are instance of the class type which inherits from class object ?
No! That's not what we mean when we say "everything is an object".
Eddilbert, have you programmed in any other languages? It would help you
understand if you have.
"Object" has a general meaning in computer science and programming, it is a
compound data structure that is explicitly linked to a type which provides
functionality that operates on that data structure.
In the programming language C, *no* values are objects. C has types (int16,
uint32, bool, and many more) but no objects.
In the programming language Java, *some* values are objects, and some values
are not objects.
In the programming language Python, *all* values are objects, in the general
sense. That is what we mean by "Everything is an object".
Let's go back in time about 15 years or so. We're now using Python 1.5. In
Python 1.5, there is no built-in object, and type is just a function, not a
class:
>>> import sys
>>> print sys.version
1.5.2 (#1, Aug 27 2012, 09:09:18) [GCC 4.1.2 20080704 (Red Hat 4.1.2-52)]
>>> object
Traceback (innermost last):
File "<stdin>", line 1, in ?
NameError: object
>>> type
<built-in function type>
In Python 1.5, classes you create do not inherit from object, because object
does not exist! BUT even in Python 1.5, it is true that everything is an
object.
Remember, "object" can refer to two things:
- *specifically* the class called "object";
- the *general concept* of objects, from object oriented programming.
In Python 1.5:
- everything is an object [the general concept]
- nothing is an instance of the class called "object"
In Python 2:
- everything is an object [the general concept]
- some things, but not all things, are instances of the class
called "object"
In Python 3:
- everything is an object [the general concept]
- everything is an instance of the class called "object"
--
Steven
[toc] | [prev] | [next] | [standalone]
Page 2 of 5 — ← Prev page 1 [2] 3 4 5 Next page →
Back to top | Article view | comp.lang.python
csiph-web