[program-l] Re: Thinking About Objects Again

  • From: Soronel Haetir <soronel.haetir@xxxxxxxxx>
  • To: program-l@xxxxxxxxxxxxx
  • Date: Wed, 3 Oct 2012 09:31:51 -0800

The reason to not use dot notation for everything is syntactic simplicity.

For instance, I would think most people would agree that something
like "if (x < y) ..." is easier to understand than "if
(some_type.__les__(x, y) ...", yet what the python interpreter does is
very close to translating the former into the latter when it goes
looking for how to actually perform the operation.  Other operators
and a few non-operator actions are given similar treatment.

When you see the statement "in python everything is an object" it is
really meant much more as a comparison with other languages where such
a statement is not true.

As an example, python gives you access to the names that are available
in any particular scope.  You can add to that list (I'm not saying it
is a python list object, just using list in the generic sense here),
delete from it, change the values (and even the types) that have been
stored.

In a language like c++ as a contrast, the names that are available in
any particular scope are entirely static and there isn't
any way to get a comprehensive list of them from within a program
(some compilers and libraries might give you means to generate such a
list externally but that is not the same thing).

On 10/3/12, Homme, James <james.homme@xxxxxxxxxxxx> wrote:
> Hi Richard, and who ever else wants to chime in,
> I feel like you were talking to me about objects, because I seem to have a
> hang up about them. When you said what you did, I thought about Cobol sub
> programs. This was before Cobol had objects. I think it has them now.
> Anyway, a sub program was self contained. It had its own data and
> procedures. Where I work, we used to have sub programs that would perform
> limited functions, like if the main programs in the system we worked on
> wanted to use a certain file and go after that data, they wouldn't have the
> code for that all scattered throughout dozens of programs. They'd put it in
> a sub program and just use it. That's not exactly what happened. I'm
> simplifying the example to make a point. I'm pretty sure that we didn't have
> the notion of sub programs that used sub programs, but I would think that we
> could have built the system that way.
>
> So when I start to think about Python, I'm getting used to the idea that in
> stead of a function being part of the Python language, it's actually part of
> a list. And the list can do things to itself, like add members and delete
> them. That's probably a bad example, because I don't have a Python reference
> right in front of me. And when you query if something is in this list,
> behind the scenes, somehow, Python is running the code in the list object
> and maybe getting some sort of return code, or true/false something that
> tells it that yes, there is this thing in the list that you are looking
> for.
>
> Another thing that seems to keep me from understanding some of this stuff is
> that people will write their descriptions in code before they explain it in
> words, but maybe that's just my learning style.
>
> One thing I don't understand at all, so far, and I've read this, is that
> they say that everything in Python is an object. So I'm really having
> trouble wrapping my brain around how something can look like a keyword or
> function call when I code it, and actually be a method, because when I start
> to read about how to write code for classes, the code looks different, so I
> feel kind of wierded out. I want to ask myself "Why don't we either code as
> though everything is made up of objects with dot notation, or simply not use
> dot notation, or both, so we can keep it all straight?" I'm sure that I'm
> totally missing something here with my thinking. But it feels better to
> attempt to talk about it.
>
> I hope that made some sort of sense.
>
> Thanks.
>
> Jim
>
>
>
>
> ________________________________
>
> This e-mail and any attachments to it are confidential and are intended
> solely for use of the individual or entity to whom they are addressed. If
> you have received this e-mail in error, please notify the sender immediately
> and then delete it. If you are not the intended recipient, you must not
> keep, use, disclose, copy or distribute this e-mail without the author's
> prior permission. The views expressed in this e-mail message do not
> necessarily represent the views of Highmark Inc., its subsidiaries, or
> affiliates.
>


-- 
Soronel Haetir
soronel.haetir@xxxxxxxxx
** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

Other related posts: