Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #84665 > unrolled thread
| Started by | Mario Figueiredo <marfig@gmail.com> |
|---|---|
| First post | 2015-01-27 21:12 +0100 |
| Last post | 2015-01-27 18:11 -0800 |
| Articles | 20 on this page of 63 — 17 participants |
Back to article view | Back to comp.lang.python
An object is an instance (or not)? Mario Figueiredo <marfig@gmail.com> - 2015-01-27 21:12 +0100
Re: An object is an instance (or not)? Ethan Furman <ethan@stoneleaf.us> - 2015-01-27 12:36 -0800
Re: An object is an instance (or not)? André Roberge <andre.roberge@gmail.com> - 2015-01-27 12:50 -0800
Re: An object is an instance (or not)? Mario Figueiredo <marfig@gmail.com> - 2015-01-27 22:06 +0100
Re: An object is an instance (or not)? André Roberge <andre.roberge@gmail.com> - 2015-01-27 13:38 -0800
Re: An object is an instance (or not)? Mario Figueiredo <marfig@gmail.com> - 2015-01-27 22:43 +0100
Re: An object is an instance (or not)? André Roberge <andre.roberge@gmail.com> - 2015-01-27 13:49 -0800
Re: An object is an instance (or not)? Mario Figueiredo <marfig@gmail.com> - 2015-01-27 22:58 +0100
Re: An object is an instance (or not)? Ben Finney <ben+python@benfinney.id.au> - 2015-01-28 09:32 +1100
Re: An object is an instance (or not)? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-28 18:55 +1100
Re: An object is an instance (or not)? Ben Finney <ben+python@benfinney.id.au> - 2015-01-28 22:20 +1100
Re: An object is an instance (or not)? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-27 23:12 +0000
Re: An object is an instance (or not)? Mario Figueiredo <marfig@gmail.com> - 2015-01-28 01:52 +0100
Re: An object is an instance (or not)? Marko Rauhamaa <marko@pacujo.net> - 2015-01-28 07:25 +0200
Re: An object is an instance (or not)? Rustom Mody <rustompmody@gmail.com> - 2015-01-27 21:53 -0800
Re: An object is an instance (or not)? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-28 05:57 +0000
Re: An object is an instance (or not)? Mario Figueiredo <marfig@gmail.com> - 2015-01-28 11:48 +0100
Re: An object is an instance (or not)? random832@fastmail.us - 2015-01-28 00:37 -0500
Re: An object is an instance (or not)? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-28 19:45 +1100
Re: An object is an instance (or not)? Devin Jeanpierre <jeanpierreda@gmail.com> - 2015-01-27 21:43 -0800
Re: An object is an instance (or not)? random832@fastmail.us - 2015-01-28 01:01 -0500
Re: An object is an instance (or not)? Rustom Mody <rustompmody@gmail.com> - 2015-01-27 22:22 -0800
Re: An object is an instance (or not)? Ben Finney <ben+python@benfinney.id.au> - 2015-01-28 18:03 +1100
Re: An object is an instance (or not)? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-28 19:48 +1100
Re: An object is an instance (or not)? Ben Finney <ben+python@benfinney.id.au> - 2015-01-28 17:59 +1100
Re: An object is an instance (or not)? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-01-28 20:21 +1300
Re: An object is an instance (or not)? Ben Finney <ben+python@benfinney.id.au> - 2015-01-28 18:48 +1100
Re: An object is an instance (or not)? random832@fastmail.us - 2015-01-28 12:08 -0500
Re: An object is an instance (or not)? Rustom Mody <rustompmody@gmail.com> - 2015-01-28 18:29 -0800
Re: An object is an instance (or not)? Ned Batchelder <ned@nedbatchelder.com> - 2015-01-27 18:22 -0500
Re: An object is an instance (or not)? Mario Figueiredo <marfig@gmail.com> - 2015-01-28 01:17 +0100
Re: An object is an instance (or not)? Chris Angelico <rosuav@gmail.com> - 2015-01-28 11:30 +1100
Re: An object is an instance (or not)? Mario Figueiredo <marfig@gmail.com> - 2015-01-28 01:35 +0100
Re: An object is an instance (or not)? alex23 <wuwei23@gmail.com> - 2015-01-28 14:44 +1000
Re: An object is an instance (or not)? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-01-28 23:33 +1300
Re: An object is an instance (or not)? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-28 22:52 +1100
Re: An object is an instance (or not)? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-01-29 19:22 +1300
Re: An object is an instance (or not)? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-29 18:16 +1100
Re: An object is an instance (or not)? Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-29 08:48 -0700
Re: An object is an instance (or not)? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-01-30 22:07 +1300
Re: An object is an instance (or not)? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-31 10:45 +1100
Re: An object is an instance (or not)? Ned Batchelder <ned@nedbatchelder.com> - 2015-01-27 21:21 -0500
Re: An object is an instance (or not)? Rustom Mody <rustompmody@gmail.com> - 2015-01-27 18:52 -0800
Re: An object is an instance (or not)? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-28 20:16 +1100
Re: An object is an instance (or not)? Chris Angelico <rosuav@gmail.com> - 2015-01-28 21:01 +1100
Re: An object is an instance (or not)? Rick Johnson <rantingrickjohnson@gmail.com> - 2015-01-29 14:22 -0800
Re: An object is an instance (or not)? Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-27 19:15 -0700
Re: An object is an instance (or not)? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-28 20:28 +1100
Re: An object is an instance (or not)? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-01-28 23:33 +1300
Re: An object is an instance (or not)? Grant Edwards <invalid@invalid.invalid> - 2015-01-28 00:23 +0000
Re: An object is an instance (or not)? Ben Finney <ben+python@benfinney.id.au> - 2015-01-28 10:39 +1100
Re: An object is an instance (or not)? Mario Figueiredo <marfig@gmail.com> - 2015-01-28 01:24 +0100
Re: An object is an instance (or not)? Ben Finney <ben+python@benfinney.id.au> - 2015-01-28 12:00 +1100
Re: An object is an instance (or not)? Mario Figueiredo <marfig@gmail.com> - 2015-01-28 02:14 +0100
Re: An object is an instance (or not)? alex23 <wuwei23@gmail.com> - 2015-01-28 14:47 +1000
Re: An object is an instance (or not)? Rustom Mody <rustompmody@gmail.com> - 2015-01-27 21:23 -0800
Re: An object is an instance (or not)? random832@fastmail.us - 2015-01-28 00:44 -0500
Re: An object is an instance (or not)? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-28 20:21 +1100
Re: An object is an instance (or not)? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-28 20:17 +1100
Re: An object is an instance (or not)? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-28 20:09 +1100
Re: An object is an instance (or not)? Chris Angelico <rosuav@gmail.com> - 2015-01-28 10:42 +1100
Re: An object is an instance (or not)? Mario Figueiredo <marfig@gmail.com> - 2015-01-28 01:31 +0100
Re: An object is an instance (or not)? Rustom Mody <rustompmody@gmail.com> - 2015-01-27 18:11 -0800
Page 1 of 4 [1] 2 3 4 Next page →
| From | Mario Figueiredo <marfig@gmail.com> |
|---|---|
| Date | 2015-01-27 21:12 +0100 |
| Subject | An object is an instance (or not)? |
| Message-ID | <MPG.2f320f923eedd5a69896a1@nntp.aioe.org> |
This is a follow up from a previous discussion in which it is argued
that the following code produces the correct error message terminology,
considering that in Python an object is also an instance.
>>> class Sub:
>>> pass
>>> foo = Sub()
>>> foo.__bases__
[...]
AttributeError: 'Sub' object has no attribute '__bases__'
I'm making this into a new thread, because the particular discussion of
whether an object is an instance in Python seems more interesting than
discussing whether that error message should be changed or not.
Here's another example where the terminology keeps indicating that in
Python an object is an instance:
>>> class Sub:
pass
>>> x = Sub()
>>> x
<__main__.Sub object at 0x02631690>
The problem is that I personally cannot agree with this terminology and
I would like to hear arguments that could convince me to adopt the
Python way. But before your replies, here's my argumentation:
An instance IS an object. On that we can agree. After all, everything in
Python is an object. Even classes are. We can even pass them as function
arguments:
>>> class Sub:
pass
>>> def show(aClass):
print(type(aClass))
>>> show(Sub)
<class 'type'>
The problem is that an object isn't always an instance. The word
instance in OOP has a very formal meaning. In programming languages in
which the classes aren't fully realized objects, it is ok to speak of
'instance' and 'object' interchangeably. But even then, sometimes the
term 'object instance' is preferred, as a way to separate these
'instances' from other variable instances that may not be created from
class definitions (e.g. C++ built-in types).
The fact that in Python classes are objects, should not just eliminate
this distinction. The OOP terminology should exist beyond the language
implementing it. It facilitates discourse and helps transmiting concepts
when describing your ideas to another programmer. And because in python,
classes are of the type 'type' and they exist as fully realized objects,
is no excuse to make a distinction between them and their own fully
realized instances. The language implementation details should not exist
as a way for us to freely reformulate long standing terms.
Because, from my own study of Python, I've came to realize that the
distinction between objects and instances of objects actually exists. In
Python, class objects cannot participate in OOP, only their instances.
This is why I say that even in Python, where a class is an object, an
object is not always an instance. The language itself forces that
distinction.
...
I don't think that any of this is reason enough to rewrite error
messages in Python. Seems unnecessary. What I'm arguing thought is that
error messages in Python cannot become the source of new terminology.
The language itself implements a very clear distinction between class
objects and their instances. And it is thus wrong of us to say that
Object = Instance. At least from an OOP perspective.
[toc] | [next] | [standalone]
| From | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| Date | 2015-01-27 12:36 -0800 |
| Message-ID | <mailman.18184.1422391002.18130.python-list@python.org> |
| In reply to | #84665 |
[Multipart message — attachments visible in raw view] — view raw
On 01/27/2015 12:12 PM, Mario Figueiredo wrote: > > Because, from my own study of Python, I've came to realize that the > distinction between objects and instances of objects actually exists. In > Python, class objects cannot participate in OOP, only their instances. I haven't followed the other thread. Can you give an example of this? Because I have a counter-example ready: the new Enum data type, which uses a metaclass to treat the class just like any other instance of a normal class: list(MyEnum) # fails on a regular class for enum in MyEnum: # fails on a regular class MyEnum['EnumName'] # fails on a regular class -- ~Ethan~
[toc] | [prev] | [next] | [standalone]
| From | André Roberge <andre.roberge@gmail.com> |
|---|---|
| Date | 2015-01-27 12:50 -0800 |
| Message-ID | <80a9f882-6b13-45a7-b514-8c47b3a4c37d@googlegroups.com> |
| In reply to | #84665 |
On Tuesday, 27 January 2015 16:12:47 UTC-4, Mario Figueiredo wrote: > This is a follow up from a previous discussion in which it is argued > that the following code produces the correct error message terminology, > considering that in Python an object is also an instance. > > >>> class Sub: > >>> pass > > >>> foo = Sub() > >>> foo.__bases__ > [...] > AttributeError: 'Sub' object has no attribute '__bases__' > > I'm making this into a new thread, because the particular discussion of > whether an object is an instance in Python seems more interesting than > discussing whether that error message should be changed or not. > > Here's another example where the terminology keeps indicating that in > Python an object is an instance: > > >>> class Sub: > pass > > >>> x = Sub() > >>> x > <__main__.Sub object at 0x02631690> > > The problem is that I personally cannot agree with this terminology and > I would like to hear arguments that could convince me to adopt the > Python way. But before your replies, here's my argumentation: > > An instance IS an object. On that we can agree. After all, everything in > Python is an object. Even classes are. We can even pass them as function > arguments: > > >>> class Sub: > pass > > >>> def show(aClass): > print(type(aClass)) > > >>> show(Sub) > <class 'type'> > > The problem is that an object isn't always an instance. The word > instance in OOP has a very formal meaning. In programming languages in > which the classes aren't fully realized objects, it is ok to speak of > 'instance' and 'object' interchangeably. But even then, sometimes the > term 'object instance' is preferred, as a way to separate these > 'instances' from other variable instances that may not be created from > class definitions (e.g. C++ built-in types). > > The fact that in Python classes are objects, should not just eliminate > this distinction. The OOP terminology should exist beyond the language > implementing it. It facilitates discourse and helps transmiting concepts > when describing your ideas to another programmer. And because in python, > classes are of the type 'type' and they exist as fully realized objects, > is no excuse to make a distinction between them and their own fully > realized instances. The language implementation details should not exist > as a way for us to freely reformulate long standing terms. > > Because, from my own study of Python, I've came to realize that the > distinction between objects and instances of objects actually exists. In > Python, class objects cannot participate in OOP, only their instances. > This is why I say that even in Python, where a class is an object, an > object is not always an instance. The language itself forces that > distinction. > > ... > > I don't think that any of this is reason enough to rewrite error > messages in Python. Seems unnecessary. What I'm arguing thought is that > error messages in Python cannot become the source of new terminology. > The language itself implements a very clear distinction between class > objects and their instances. And it is thus wrong of us to say that > Object = Instance. At least from an OOP perspective. You keep writing "an object is not an instance", making statements such as "the terminology keeps indicating that in Python an object is an instance" and yet, none of the examples you show from Python (tracebacks or repr outputs) include the word "instance". To phrase it differently: all the examples of output from Python that you show use the word "object" and not the word "instance". Yet **you** claim that "Python" states that objects are instances .... Can you point out at least one example where "Python" wrongly use the word instance instead of object?
[toc] | [prev] | [next] | [standalone]
| From | Mario Figueiredo <marfig@gmail.com> |
|---|---|
| Date | 2015-01-27 22:06 +0100 |
| Message-ID | <MPG.2f321c24a502d2bb9896a3@nntp.aioe.org> |
| In reply to | #84668 |
In article <80a9f882-6b13-45a7-b514-8c47b3a4c37d@googlegroups.com>, andre.roberge@gmail.com says... > > You keep writing "an object is not an instance", making statements > such as "the terminology keeps indicating that in Python an object is > an instance" and yet, none of the examples you show from Python > (tracebacks or repr outputs) include the word "instance". I think you misread my argument. Look at the first example on my post, or follow the discussion on "__bases__ misleading error message" here on the newsgroups. That error message has me start that thread arguing that the error is misleading because the Sub object does have the __bases__ attribute. It's the Sub instance object that does not have it. Some of the answers that were given argued that in Python object = instance. > Yet > **you** claim that "Python" states that objects are instances .... That is no my claim. I said that much. You should probably read my post more carefully.
[toc] | [prev] | [next] | [standalone]
| From | André Roberge <andre.roberge@gmail.com> |
|---|---|
| Date | 2015-01-27 13:38 -0800 |
| Message-ID | <a771f6f2-9aa3-44ca-9f87-88a984c7c27e@googlegroups.com> |
| In reply to | #84670 |
On Tuesday, 27 January 2015 17:06:50 UTC-4, Mario Figueiredo wrote:
> In article <80a9f882-6b13-45a7-b514-8c47b3a4c37d@googlegroups.com>,
> andre.roberge@gmail.com says...
> >
> > You keep writing "an object is not an instance", making statements
> > such as "the terminology keeps indicating that in Python an object is
> > an instance" and yet, none of the examples you show from Python
> > (tracebacks or repr outputs) include the word "instance".
>
> I think you misread my argument. Look at the first example on my post,
> or follow the discussion on "__bases__ misleading error message" here on
> the newsgroups.
>
> That error message has me start that thread arguing that the error is
> misleading because the Sub object does have the __bases__ attribute.
> It's the Sub instance object that does not have it.
>
To use the word object to describe an instance is perfectly appropriate. Your claims imply the the opposite is happening.
> Some of the answers that were given argued that in Python object =
> instance.
>
> > Yet
> > **you** claim that "Python" states that objects are instances ....
>
> That is no my claim. I said that much. You should probably read my post
> more carefully.
I read your post carefully: not once did I see an output from Python using the word "instance".
From your post:
==== Python's output ======
AttributeError: 'Sub' object has no attribute '__bases__'
=============================
Python uses the word "object, not "instance".
++++++ your words +++++++++++
Here's another example where the terminology keeps indicating that in
Python an object is an instance:
++++++++++++++++++++++++++++++
==========Python's output ===============
<__main__.Sub object at 0x02631690>
=======================================
Python uses the word "object, not "instance", contrary to what you wrote.
+++++++++++ your words ++++++++++++++
The problem is that an object isn't always an instance.
+++++++++++++++++++++++++++++++++++++
++++++++++++ your words ++++++++++++
What I'm arguing thought is that
error messages in Python cannot become the source of new terminology.
++++++++++++++++++++++++++++++++
Not a single output from Python uses the word instance.
It is appropriate to refer to an instance as an object. It might not be appropriate to refer to an object as an instance ... but Python does not do so as your explicit examples demonstrate, and contrary to your claim.
A.R.
[toc] | [prev] | [next] | [standalone]
| From | Mario Figueiredo <marfig@gmail.com> |
|---|---|
| Date | 2015-01-27 22:43 +0100 |
| Message-ID | <MPG.2f3224d1997790e19896a7@nntp.aioe.org> |
| In reply to | #84675 |
In article <a771f6f2-9aa3-44ca-9f87-88a984c7c27e@googlegroups.com>, andre.roberge@gmail.com says... > > It is appropriate to refer to an instance as an object. It might not > be appropriate to refer to an object as an instance ... but Python > does not do so as your explicit examples demonstrate, and contrary to > your claim. I'll try one more time: It - Is - Not - My - Claim. It is the claim of a few users in here that replied to that thread.
[toc] | [prev] | [next] | [standalone]
| From | André Roberge <andre.roberge@gmail.com> |
|---|---|
| Date | 2015-01-27 13:49 -0800 |
| Message-ID | <9a2cf6ca-2eb8-4a87-9e83-e87d90d5fe42@googlegroups.com> |
| In reply to | #84677 |
On Tuesday, 27 January 2015 17:43:38 UTC-4, Mario Figueiredo wrote: > In article <a771f6f2-9aa3-44ca-9f87-88a984c7c27e@googlegroups.com>, > andre.roberge@gmail.com says... > > > > It is appropriate to refer to an instance as an object. It might not > > be appropriate to refer to an object as an instance ... but Python > > does not do so as your explicit examples demonstrate, and contrary to > > your claim. > > I'll try one more time: It - Is - Not - My - Claim. > > It is the claim of a few users in here that replied to that thread. At the very beginning of the first message I replied to, you wrote: **This is a follow up from a previous discussion in which it is argued that the following code produces the correct error message terminology ** I pointed out to you that the word object WAS used correctly: hence, the correct terminology was used in that error message. You are just wasting people's time.
[toc] | [prev] | [next] | [standalone]
| From | Mario Figueiredo <marfig@gmail.com> |
|---|---|
| Date | 2015-01-27 22:58 +0100 |
| Message-ID | <MPG.2f322851e6cf90ad9896a8@nntp.aioe.org> |
| In reply to | #84678 |
In article <9a2cf6ca-2eb8-4a87-9e83-e87d90d5fe42@googlegroups.com>, andre.roberge@gmail.com says... > > **This is a follow up from a previous discussion in which it is argued > that the following code produces the correct error message terminology ** > > I pointed out to you that the word object WAS used correctly: hence, the correct terminology was used in that error message. > > You are just wasting people's time. That is just rude! I'm still trying to understand what is the problem you are having with my post. Have you followed the previous thread? Is there anything you are not understanding? People were saying to me that in Python object = instance. I'm trying to argue why I believe it isn't and asking for arguments to convince me otherwise. And that's the best you can do? Python does imply that an object is an instance, btw. It is why I got that answer from more than one person. Or so they say. By referring to an instance of Sub as "Sub object", there's an implicit affirmation that an object is an instance. Bye.
[toc] | [prev] | [next] | [standalone]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2015-01-28 09:32 +1100 |
| Message-ID | <mailman.18189.1422397927.18130.python-list@python.org> |
| In reply to | #84680 |
Mario Figueiredo <marfig@gmail.com> writes: > People were saying to me that in Python object = instance. I'm trying > to argue why I believe it isn't and asking for arguments to convince > me otherwise. In Python: * Every value is an object. * Every object is an instance of some class. * To say “object” is uproblematic for values in Python, because the programming term “object” doesn't imply anything about classes. * To say “instance” implies a specific relationship to some particular class; in programming terminology (because in English generally) an instance is so called only because it is an instance of some specific class. > By referring to an instance of Sub as "Sub object", there's an > implicit affirmation that an object is an instance. Correct. That raises a fourth point: * In the distant past of Python, some objects were not instances of any class; the terminology in the documentation and messages shows some confusing legacies from that ancient time. The phrasing “'Foo' object” is ambiguous in a way that “'Foo' instance” would not be. I agree with others that changing the message to refer to “'Foo' instance” would be an improvement. -- \ “Pinky, are you pondering what I'm pondering?” “I think so, | `\ Brain, but I find scratching just makes it worse.” —_Pinky and | _o__) The Brain_ | Ben Finney
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2015-01-28 18:55 +1100 |
| Message-ID | <54c89600$0$12902$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #84681 |
Ben Finney wrote: > * In the distant past of Python, some objects were not instances of any > class; the terminology in the documentation and messages shows some > confusing legacies from that ancient time. I presume you are referring to the type/class distinction? That is, in Python 1.5 (for example), the *instance* 23 was an instance of the *type* int but not of any class, as classes (created with the "class" keyword) were distinct from types. If you mean something else, can you explain please? -- Steve
[toc] | [prev] | [next] | [standalone]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2015-01-28 22:20 +1100 |
| Message-ID | <mailman.18212.1422444039.18130.python-list@python.org> |
| In reply to | #84726 |
Steven D'Aprano <steve+comp.lang.python@pearwood.info> writes: > Ben Finney wrote: > > > * In the distant past of Python, some objects were not instances of any > > class; the terminology in the documentation and messages shows some > > confusing legacies from that ancient time. > > > I presume you are referring to the type/class distinction? > > That is, in Python 1.5 (for example), the *instance* 23 was an > instance of the *type* int but not of any class, as classes (created > with the "class" keyword) were distinct from types. That's what I was referring to, yes. All ancient history now. In all current versions of Python, every type is a class and every class is a type, and every type is an object and every class is an object, and every object is an instance of a class and is an instance of a type (and you are me and all are we together). -- \ “I like to reminisce with people I don't know. Granted, it | `\ takes longer.” —Steven Wright | _o__) | Ben Finney
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2015-01-27 23:12 +0000 |
| Message-ID | <mailman.18190.1422400358.18130.python-list@python.org> |
| In reply to | #84680 |
On 27/01/2015 21:58, Mario Figueiredo wrote: > In article <9a2cf6ca-2eb8-4a87-9e83-e87d90d5fe42@googlegroups.com>, > andre.roberge@gmail.com says... >> >> **This is a follow up from a previous discussion in which it is argued >> that the following code produces the correct error message terminology ** >> >> I pointed out to you that the word object WAS used correctly: hence, the correct terminology was used in that error message. >> >> You are just wasting people's time. > > That is just rude! > > I'm still trying to understand what is the problem you are having with > my post. Have you followed the previous thread? Is there anything you > are not understanding? > > People were saying to me that in Python object = instance. I'm trying to > argue why I believe it isn't and asking for arguments to convince me > otherwise. > > And that's the best you can do? > > Python does imply that an object is an instance, btw. It is why I got > that answer from more than one person. Or so they say. > > By referring to an instance of Sub as "Sub object", there's an implicit > affirmation that an object is an instance. > > Bye. > Mario and Andre, when you have to write code to meet the deadline to get the stage payment, does either of your bosses really care whether or not you are dealing with an object, an instance, or a piece of dead meat dropped by the neighbour's cat? -- 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 | Mario Figueiredo <marfig@gmail.com> |
|---|---|
| Date | 2015-01-28 01:52 +0100 |
| Message-ID | <MPG.2f32513a4d0addbf9896ad@nntp.aioe.org> |
| In reply to | #84682 |
In article <mailman.18190.1422400358.18130.python-list@python.org>, breamoreboy@yahoo.co.uk says... > > Mario and Andre, when you have to write code to meet the deadline to get > the stage payment, does either of your bosses really care whether or not > you are dealing with an object, an instance, or a piece of dead meat > dropped by the neighbour's cat? That is valuable input. You don't care how a type or an instance of a type differ. Should be intersting to ask you to make a Cat object. I wonder if you are not going to ask if they mean a class or an instance of that class. Anyways, more to the point, this is simply a debate on language and how to express Python concepts. If that bothers you, I'll take note.
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2015-01-28 07:25 +0200 |
| Message-ID | <877fw7jx33.fsf@elektro.pacujo.net> |
| In reply to | #84694 |
Mario Figueiredo <marfig@gmail.com>:
> That is valuable input. You don't care how a type or an instance of a
> type differ. Should be intersting to ask you to make a Cat object. I
> wonder if you are not going to ask if they mean a class or an instance
> of that class.
>
> Anyways, more to the point, this is simply a debate on language and how
> to express Python concepts. If that bothers you, I'll take note.
Python itself has answers to your questions:
>>> isinstance(3, int)
True
>>> isinstance("3", int)
False
>>> isinstance(int, type)
True
>>> isinstance(type, int)
False
>>> isinstance(type, type)
True
>>> isinstance(3, type)
False
>>> isinstance(int, 3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: isinstance() arg 2 must be a type or tuple of types
>>> isinstance(3, object)
True
>>> isinstance("3", object)
True
>>> isinstance(int, object)
True
>>> isinstance(type, object)
True
>>> isinstance(object, object)
True
Marko
[toc] | [prev] | [next] | [standalone]
| From | Rustom Mody <rustompmody@gmail.com> |
|---|---|
| Date | 2015-01-27 21:53 -0800 |
| Message-ID | <9010c34b-2b2e-4cff-86c1-a45fc6ef61a1@googlegroups.com> |
| In reply to | #84713 |
On Wednesday, January 28, 2015 at 10:55:32 AM UTC+5:30, Marko Rauhamaa wrote:
> Python itself has answers to your questions:
>
> >>> isinstance(3, int)
> True
> >>> isinstance("3", int)
> False
> >>> isinstance(int, type)
> True
> >>> isinstance(type, int)
> False
> >>> isinstance(type, type)
> True
> >>> isinstance(3, type)
> False
> >>> isinstance(int, 3)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: isinstance() arg 2 must be a type or tuple of types
> >>> isinstance(3, object)
> True
> >>> isinstance("3", object)
> True
> >>> isinstance(int, object)
> True
> >>> isinstance(type, object)
> True
> >>> isinstance(object, object)
> True
>
>
> Marko
neat
Maybe add also
>>> isinstance(type,object)
True
>>> isinstance(object,object)
True
>>> issubclass(object,type)
False
>>> issubclass(type,object)
True
>>> isinstance(object,type)
True
>>> issubclass(int,object)
True
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2015-01-28 05:57 +0000 |
| Message-ID | <mailman.18203.1422424695.18130.python-list@python.org> |
| In reply to | #84694 |
On 28/01/2015 00:52, Mario Figueiredo wrote: > In article <mailman.18190.1422400358.18130.python-list@python.org>, > breamoreboy@yahoo.co.uk says... >> >> Mario and Andre, when you have to write code to meet the deadline to get >> the stage payment, does either of your bosses really care whether or not >> you are dealing with an object, an instance, or a piece of dead meat >> dropped by the neighbour's cat? > > That is valuable input. You don't care how a type or an instance of a > type differ. Should be intersting to ask you to make a Cat object. I > wonder if you are not going to ask if they mean a class or an instance > of that class. > > Anyways, more to the point, this is simply a debate on language and how > to express Python concepts. If that bothers you, I'll take note. > The thing that bothers me is that many people, some of them with maybe 20 years of Python experience, have repeatedly stated Python concepts with respect to the terms class, instance and object. Instead of accepting their knowledge of the language and gracefully stepping back, you've carried on until the twist of knots would make any boy scout proud. -- 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 | Mario Figueiredo <marfig@gmail.com> |
|---|---|
| Date | 2015-01-28 11:48 +0100 |
| Message-ID | <MPG.2f32dcd13b4e4a519896b1@nntp.aioe.org> |
| In reply to | #84718 |
In article <mailman.18203.1422424695.18130.python-list@python.org>, breamoreboy@yahoo.co.uk says... > > The thing that bothers me is that many people, some of them with maybe > 20 years of Python experience, have repeatedly stated Python concepts > with respect to the terms class, instance and object. Instead of > accepting their knowledge of the language and gracefully stepping back, > you've carried on until the twist of knots would make any boy scout proud. Condescending much? I'm not one to lower to arguments from authority. Sorry. Never have, never will. Neither I adopt such attitude on those programming languages in which I am myself an authoritative source. I respect knowledge as anyone else. But I also specifically asked for arguments that could show me the Python way. I have a desire to understand. It's not just a matter of accepting the word of someone who is more experienced than me. That does not do any good to anyone. I'm not trying to change anything, neither I'm a OOP fanatic like some tried to accuse me. I'm just trying to understand. Do *you* understand that? I may have sounded ignorant to you. It's something I cannot avoid, because while I try to argue this issue, I do it from the position of someone who is still learning the Python language syntax and semantics. But I'm much more than what you may think. And I would like to be treated with a little more respect. Like you I'm a software developer and, probably like you, I have decades of software development as a profession on my back. But some of the arguments in here (and yours too) have done very little to help me understand the language semantics on this particular issue. Purportedly, or perhaps innocently due to my clumsiness, some folks in here argue with little more than "but a class object is an instance of 'type'". They choose to ignore that class objects are clearly a special type of object unlike the instances they help define. Like in so many debates, there's unfortunately always a desire to ignore or avoid other side that is arguing with us. Thankfully, I am now starting to understand the semantics. Folks like Ben, Steven or Ian (apologies to a couple others I am missing. Can't remember your names and having an hard time looking through past posts) have helped tremendously by leaving smugness aside, adopting an educational attitude towards a clearly confused person, and -- I would wager -- understanding that I'm asking questions, not trying to set new ways. Don't feel so bothered by my person, sir. Just ignore me if that makes you feel better.
[toc] | [prev] | [next] | [standalone]
| From | random832@fastmail.us |
|---|---|
| Date | 2015-01-28 00:37 -0500 |
| Message-ID | <mailman.18200.1422423469.18130.python-list@python.org> |
| In reply to | #84670 |
On Tue, Jan 27, 2015, at 16:06, Mario Figueiredo wrote: > That error message has me start that thread arguing that the error is > misleading because the Sub object does have the __bases__ attribute. > It's the Sub instance object that does not have it. What do you think "Sub object" means? Sub itself is not a Sub object, it is a type object. "instance" is implicit in the phrase "foo object".
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2015-01-28 19:45 +1100 |
| Message-ID | <54c8a1c6$0$12906$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #84714 |
random832@fastmail.us wrote: > On Tue, Jan 27, 2015, at 16:06, Mario Figueiredo wrote: >> That error message has me start that thread arguing that the error is >> misleading because the Sub object does have the __bases__ attribute. >> It's the Sub instance object that does not have it. > > What do you think "Sub object" means? I think it means the Sub class, which is an object. And Python 3.3 agrees with me: py> class Sub(object): ... pass ... py> isinstance(Sub, object) True Sub is also an instance of type. And object is an instance of type, type is an instance of object, and type is a subclass of object. But object is not a subclass of type. However it is an instance of type. Are we confused yet? There is a sense, taken from Java in particular, that "object" is synonymous for "instance". For example, Oracle's documentation for classes says: "A class contains constructors that are invoked to create objects from the class blueprint." http://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html But you won't find any Java documentation referring to the class itself as an object. Java has no metaclasses, classes are not instances of a metaclass, and so classes are never instances. Classes are classes, objects are instances of a class, and that is all there is to it. But in Python, "object" and "instance" are more ambiguous, thanks to metaclasses. Instances of a metaclass are classes, hence classes are instances as well as classes: py> isinstance(Sub, type) True Sub is an instance of the class "type". And because classes themselves are first-class (ha ha!) values, like ints, strings, lists etc., classes are objects. All classes (in Python 3) are instances of a class (the metaclass), but not all instances are classes. Obviously this is rather confusing, but fortunately metaclasses (other than type itself) are rare, so *most of the time* we can get away with Java-like terminology, and pretend that classes are distinct from instances rather than being just another kind of instance (of the metaclass). But what we cannot do is pretend that "object" means instance, because all classes are objects. Alas, habits from other languages leak in, and the Javaesque terminology "Foo object" meaning an instance of Foo sometimes gets used, even though "Foo object" should refer to the object called Foo, namely the class object itself. The unfortunate ambiguity is that sometimes "Foo object" gets used to mean Foo, and other times it gets used to me some instance of Foo. We say: "the None object has no state" and "the function requires an int object as argument". > Sub itself is not a Sub object, Sub itself is not *a* Sub object, it is *the* Sub object, just as 42 is *the* object with type int and value forty-two. > it is a type object. "instance" is > implicit in the phrase "foo object". Alas, classes *are* instances, of their metaclass, so "Sub object" could refer to an instance of Sub (using the Javaesque terminology) or Sub itself (using more Pythonistic terminology). -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Devin Jeanpierre <jeanpierreda@gmail.com> |
|---|---|
| Date | 2015-01-27 21:43 -0800 |
| Message-ID | <mailman.18201.1422423875.18130.python-list@python.org> |
| In reply to | #84670 |
On Tue, Jan 27, 2015 at 9:37 PM, <random832@fastmail.us> wrote: > On Tue, Jan 27, 2015, at 16:06, Mario Figueiredo wrote: >> That error message has me start that thread arguing that the error is >> misleading because the Sub object does have the __bases__ attribute. >> It's the Sub instance object that does not have it. > > What do you think "Sub object" means? > > Sub itself is not a Sub object, it is a type object. "instance" is > implicit in the phrase "foo object". Yes. Unfortunately, it's still not really completely clear. "Sub instance" would avoid this confusion for everyone. I think the only reason to avoid "instance" in the past would have been the old-style object confusion, as Ben Finney pointed out. (BTW I agree with literally every single thing he said in this thread, it's really amazing.) -- Devin
[toc] | [prev] | [next] | [standalone]
Page 1 of 4 [1] 2 3 4 Next page →
Back to top | Article view | comp.lang.python
csiph-web