Message from discussion
Objects in Python
Received: by 10.66.77.39 with SMTP id p7mr150006paw.0.1345713577844;
Thu, 23 Aug 2012 02:19:37 -0700 (PDT)
Received: by 10.180.107.167 with SMTP id hd7mr184874wib.0.1345713577458;
Thu, 23 Aug 2012 02:19:37 -0700 (PDT)
Path: a5ni4922pbv.0!nntp.google.com!news2.google.com!yt1no41234672wib.1!news-out.google.com!n2ni273067741win.0!nntp.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!217.73.144.45.MISMATCH!feeder2.ecngs.de!ecngs!feeder.ecngs.de!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail
NNTP-Posting-Date: Thu, 23 Aug 2012 04:19:37 -0500
Date: Thu, 23 Aug 2012 10:19:36 +0100
From: lipska the kat <lipskathe...@yahoo.co.uk>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120410 Thunderbird/11.0.1
MIME-Version: 1.0
Newsgroups: comp.lang.python
Subject: Re: Objects in Python
References: <18409992-1e28-4721-8e64-60c69668da4e@googlegroups.com> <w7adnXiWqoJSbqnNnZ2dnUVZ7o2dnZ2d@bt.com> <mailman.3668.1345654939.4697.python-list@python.org> <gsSdnaYuqqabhqjNnZ2dnUVZ8jmdnZ2d@bt.com> <mailman.3680.1345662881.4697.python-list@python.org> <OY6dnY9Al8N3q6jNnZ2dnUVZ8hGdnZ2d@bt.com> <mailman.3689.1345671073.4697.python-list@python.org>
In-Reply-To: <mailman.3689.1345671073.4697.python-list@python.org>
Message-ID: <n_idndav2J80aKjNnZ2dnUVZ8mSdnZ2d@bt.com>
Lines: 65
X-Usenet-Provider: http://www.giganews.com
X-AuthenticatedUsername: NoAuthUser
X-Trace: sv3-WdBLo5beILeRwf/obt/ry2GXgouDA7jm185PoFFx6oiKsb6IgaDfk+MeszjLF2P5eJLwcGJ08TNYGrZ!uBvGjHriwx6/Dz+oDGCUSMTvE3dIEW6PlkmpszDy0J07kMVevUCCY2paV4QR/TG5qwiu7QuMIYj8
X-Complaints-To: abuse@btinternet.com
X-DMCA-Complaints-To: ab...@btinternet.com
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 4167
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
On 22/08/12 22:31, Evan Driscoll wrote:
> On 08/22/2012 02:45 PM, lipska the kat wrote:
>> On 22/08/12 20:03, Evan Driscoll wrote:
>>> Second, this concept isn't *so* unfamiliar to you. If I give you the
>>> following Java code:
>>>
>>> void foo(Object o) { ... }
>>>
>> looking at this method declaration I can see that the method takes an
>> argument of type Object (and just FYI class Object is not abstract and
>> you can do Object o = new Object()) and does not return a value.
>> I know that for the lifetime of this JVM, whatever o turns out to be it
>> will always be an Object. I can't assign a primitive to o as ints chars
>> floats etc are certainly not Objects. There are certain invariants that
>> give me a warm and comfortable feeling inside.
>
> I'm not saying it's nothing, but "can't assign a primitive" isn't much
> of an invariant in the broad scheme of things
Well we don't want to turn this into a language comparison thread do we,
that might upset too many people but I can't remember ever writing a
method that took an Object as argument, you just can't do that much with
an Object. I do however often write methods that take an interface as
argument knowing that in future, any classes I write that implement this
interface would just work thanks to subtype polymorphism
A method 'declaration' such as this in an interface
Product getProductByBarcode(Barcode b) throws CrappyProductException;
tells me a whole lot about what the 'definition' in an implementing
class might do, in fact I might well get away with just reading the
interface and using the method without having to delve into the code.
And I think this is the nub of the problem at the moment. I'm in a
particular mindset, almost 'locked in' you might say and when I see a
Python function that doesn't give me what I need straight away I get
annoyed.
I will get over it.
> when you can pass items as
> diverse as lists, GUI buttons, files, etc. I would say it's more like if
> you see 'int x' then *that* imposes a pretty big invariant, but passing
> 'Object' imposes almost nothing.
Well you may be able to pass them in but you couldn't really do anything
meaningful with them as you are restricted to operations on Object, I
suppose you could pepper your code with tests to check the runtime type
of a reference but it all gets a bit messy.
[snip]
> Thus *all*
> Python variables are essentially references.)
That makes sense
Thanks for taking the time to reply. It really is most valuable to me.
lipska
--
Lipska the Kat�: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun