Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #26490 > unrolled thread

[newbie] Looking for a good introduction to object oriented programming with Python

Started byJean Dubois <jeandubois314@gmail.com>
First post2012-08-04 08:49 -0700
Last post2012-08-07 11:23 +0100
Articles 10 on this page of 70 — 18 participants

Back to article view | Back to comp.lang.python


Contents

  [newbie] Looking for a good introduction to object oriented programming with Python Jean Dubois <jeandubois314@gmail.com> - 2012-08-04 08:49 -0700
    Re: [newbie] Looking for a good introduction to object oriented programming with Python shearichard@gmail.com - 2012-08-04 17:11 -0700
      Re: Looking for a good introduction to object oriented programming with Python Jean Dubois <jeandubois314@gmail.com> - 2012-08-05 05:38 -0700
      Re: Looking for a good introduction to object oriented programming with Python Jean Dubois <jeandubois314@gmail.com> - 2012-08-05 11:04 -0700
        Re: Looking for a good introduction to object oriented programming with Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-05 19:28 +0100
          Re: Looking for a good introduction to object oriented programming with Python Jean Dubois <jeandubois314@gmail.com> - 2012-08-06 07:56 -0700
            Re: Looking for a good introduction to object oriented programming with Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-06 17:17 +0100
              Re: Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-07 01:12 +0000
                Re: Looking for a good introduction to object oriented programming with Python Ben Finney <ben+python@benfinney.id.au> - 2012-08-07 11:23 +1000
                Re: Looking for a good introduction to object oriented programming with Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-07 08:49 +0100
        Re: Looking for a good introduction to object oriented programming with Python Roy Smith <roy@panix.com> - 2012-08-05 14:39 -0400
        Re: Looking for a good introduction to object oriented programming with Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-05 19:53 +0100
        Re: Looking for a good introduction to object oriented programming with Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-05 18:45 -0400
          Re: Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-05 22:51 +0000
            Re: Looking for a good introduction to object oriented programming with Python Roy Smith <roy@panix.com> - 2012-08-05 19:12 -0400
              Re: Looking for a good introduction to object oriented programming with Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-06 00:30 +0100
              Re: Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-06 00:27 +0000
                Re: Looking for a good introduction to object oriented programming with Python Dan Sommers <dan@tombstonezero.net> - 2012-08-05 17:50 -0700
                Re: Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-06 08:48 +0100
                Re: Looking for a good introduction to object oriented programming with Python DJC <djc@news.invalid> - 2012-08-06 11:20 +0200
              Re: Looking for a good introduction to object oriented programming with Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-05 20:57 -0400
            Re: Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-06 08:43 +0100
              Re: Looking for a good introduction to object oriented programming with Python Roy Smith <roy@panix.com> - 2012-08-06 09:16 -0400
          Re: Looking for a good introduction to object oriented programming with Python Wolfgang Strobl <news4@mystrobl.de> - 2012-08-06 08:18 +0200
    Re: [newbie] Looking for a good introduction to object oriented programming with Python dncarac@gmail.com - 2012-08-05 11:59 -0700
    Re: [newbie] Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-05 20:46 +0100
      Re: [newbie] Looking for a good introduction to object oriented programming with Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-05 23:11 +0100
        Re: [newbie] Looking for a good introduction to object oriented programming with Python Roy Smith <roy@panix.com> - 2012-08-05 18:53 -0400
      Re: [newbie] Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-06 00:22 +0000
        Re: [newbie] Looking for a good introduction to object oriented programming with Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-06 02:02 +0100
        Re: [newbie] Looking for a good introduction to object oriented programming with Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-05 21:14 -0400
          Re: [newbie] Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-06 06:08 +0000
            Re: [newbie] Looking for a good introduction to object oriented programming with Python Paul Rubin <no.email@nospam.invalid> - 2012-08-06 00:25 -0700
        Re: Looking for a good introduction to object oriented programming with Python alex23 <wuwei23@gmail.com> - 2012-08-05 19:44 -0700
          Re: Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-07 19:02 +0000
            Re: Looking for a good introduction to object oriented programming with Python Terry Reedy <tjreedy@udel.edu> - 2012-08-07 18:37 -0400
            Re: Looking for a good introduction to object oriented programming with Python alex23 <wuwei23@gmail.com> - 2012-08-07 17:07 -0700
              Re: Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-08 02:14 +0000
                Re: Looking for a good introduction to object oriented programming with Python Chris Angelico <rosuav@gmail.com> - 2012-08-08 12:24 +1000
                Re: Looking for a good introduction to object oriented programming with Python alex23 <wuwei23@gmail.com> - 2012-08-07 20:20 -0700
        Re: [newbie] Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-06 09:55 +0100
          Re: [newbie] Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-06 10:24 +0100
            Re: [newbie] Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-07 05:35 +0000
              Re: [newbie] Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-07 09:16 +0100
          Re: [newbie] Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-07 05:19 +0000
            Re: [newbie] Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-07 10:19 +0100
              Re: [newbie] Looking for a good introduction to object oriented programming with Python Ben Finney <ben+python@benfinney.id.au> - 2012-08-07 23:12 +1000
                Re: [newbie] Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-07 15:13 +0100
              Re: [newbie] Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-07 14:14 +0000
                Re: [newbie] Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-07 15:34 +0100
                  Re: Looking for a good introduction to object oriented programming with Python rusi <rustompmody@gmail.com> - 2012-08-07 08:04 -0700
                    Re: Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-07 18:00 +0100
                      Re: Looking for a good introduction to object oriented programming with Python Chris Angelico <rosuav@gmail.com> - 2012-08-08 07:57 +1000
                        Re: Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-08 10:51 +0100
                          Re: Looking for a good introduction to object oriented programming with Python rusi <rustompmody@gmail.com> - 2012-08-08 09:27 -0700
                            Re: Looking for a good introduction to object oriented programming with Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-08 17:28 +0000
                              Re: Looking for a good introduction to object oriented programming with Python Chris Angelico <rosuav@gmail.com> - 2012-08-09 11:32 +1000
                          Re: Looking for a good introduction to object oriented programming with Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-08 12:42 -0400
                            Re: Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-08 20:31 +0100
                              Re: Looking for a good introduction to object oriented programming with Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-08 22:59 -0400
                                Re: Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-09 08:29 +0100
                              Geneology Packages -- WAS: Looking for a good introduction to object oriented programming with Python Simon Cropper <simoncropper@fossworkflowguides.com> - 2012-08-09 13:51 +1000
                                Re: Geneology Packages Ben Finney <ben+python@benfinney.id.au> - 2012-08-09 14:00 +1000
      Re: Looking for a good introduction to object oriented programming with Python rusi <rustompmody@gmail.com> - 2012-08-06 05:19 -0700
        Re: Looking for a good introduction to object oriented programming with Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-06 15:27 +0100
          Re: Looking for a good introduction to object oriented programming with Python rusi <rustompmody@gmail.com> - 2012-08-06 09:34 -0700
            Re: Looking for a good introduction to object oriented programming with Python Chris Angelico <rosuav@gmail.com> - 2012-08-07 08:44 +1000
        OT probably but still relevant (was Re: Looking for a good introduction to object oriented programming with Python) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-06 17:23 +0100
          Re: OT probably but still relevant (was Re: Looking for a good introduction to object oriented programming with Python) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-07 09:44 +0000
            Re: OT probably but still relevant (was Re: Looking for a good introduction to object oriented programming with Python) lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-07 11:23 +0100

Page 4 of 4 — ← Prev page 1 2 3 [4]


#26781 — Re: Looking for a good introduction to object oriented programming with Python

Fromlipska the kat <lipskathekat@yahoo.co.uk>
Date2012-08-09 08:29 +0100
SubjectRe: Looking for a good introduction to object oriented programming with Python
Message-ID<iZCdnT2NNY9--77NnZ2dnUVZ8oCdnZ2d@bt.com>
In reply to#26775
On 09/08/12 03:59, Dennis Lee Bieber wrote:
> On Wed, 08 Aug 2012 20:31:57 +0100, lipska the kat
> <lipskathekat@yahoo.co.uk>  declaimed the following in
> gmane.comp.python.general:
>

[snip]

>
> 	If a "node" is a father or mother, and it takes one of each to
> produce a "leaf", your "tree" has just collapsed.

This would come out in the iterative wash and I'm sure it could be 
resolved without resorting to a Person class

People are starting to get annoyed by this thread now (I'm surprised it 
has taken so long) so it's probably best to move on.

lipska

-- 
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

[toc] | [prev] | [next] | [standalone]


#26776 — Geneology Packages -- WAS: Looking for a good introduction to object oriented programming with Python

FromSimon Cropper <simoncropper@fossworkflowguides.com>
Date2012-08-09 13:51 +1000
SubjectGeneology Packages -- WAS: Looking for a good introduction to object oriented programming with Python
Message-ID<mailman.3092.1344484291.4697.python-list@python.org>
In reply to#26766
On 09/08/12 12:59, Dennis Lee Bieber wrote:
> On Wed, 08 Aug 2012 20:31:57 +0100, lipska the kat
> <lipskathekat@yahoo.co.uk> declaimed the following in
> gmane.comp.python.general:
>
>> A Tree consists of Node(s) and Leaf(s), relationships are modelled by
>> following the Line(s) in the Tree diagram and that is it. Line may be a
>> class as in 'the patriarchal line' I'm not sure, it would come out in
>> the iterative wash.
>>
>> We can infer whatever we want from this simple model. A Leaf is a child,
>> until it becomes a parent when it becomes a Node. To anthropomorphize a
>> bit more (I love that word) and introduce non species specific words and
>> concepts, a Node can be a father or mother (simple to implement by
>
> 	If a "node" is a father or mother, and it takes one of each to
> produce a "leaf", your "tree" has just collapsed.
>
> 	In genealogy, a "tree" is merely the representation -- in one
> direction -- of relationships from a single Person to either all
> ancestors, or to all descendents.
>
> 	"Father", "mother", "son", "daughter" (or to simplify, "parent",
> "child") are merely roles taken on by a person in relationship to
> another person. A Person can exist even if we do not know who the
> parents were, nor if there are any children.
>
>> But what of all the ephemeral data that goes with a sentient existance
>> on this planet such as birth certificates, newspaper articles,
>> christenings, death certificates, photographs etc etc, what about
>> pegigree certificates, innoculation records and any other trivia,
>> information and flotsam that goes with a pedigree Dog or Horse or indeed
>> Parrot.
>>
> 	Those documents are the /evidence/ used to prove the linkages of the
> Person.
>
> 	Granted, the most popular genealogy program tends to be the least
> capable -- it won't let one add a person without creating a "family"
> first; and most all evidence is recorded as just a text memo.
>
> 	In contrast, TMG, provides for "Sources" (the documents),
> "Citations" (references to sources, used in the events in the person's
> life), "Repositories" (where the source can be found). Events cover
> things like "Birth", "Marriage", "Death", "Graduation", etc. [one can
> create custom events too]. Events have a date, a location, and can have
> multiple citations to the source the provides evidence that the event
> took place and involved the person to which it is linked. In TMG, there
> is no "family" as such -- only the linkages from relationship events (a
> "birth" event does not link a child to its parents; that is done via a
> pair of parent-child relationships [father-relationship,
> mother-relationship] and TMG supports having multiples -- only the pair
> marked a "primary" is used to produce "tree-like" reports, but the
> system supports having birth-parents and adoptive-parents at the same
> time in the data). It even supports having multiple "Birth" events too,
> if one finds conflicting evidence and can not determine if some is
> invalid.
>
> 	I'm not going to go into depth, but the TMG (v8) database consists
> of 29 tables, and the user interface centers on displaying a list of
> events for a person. Oh, and the person can have more than one name too,
> though only one can be listed as primary (shows at the top of the page)
> -- the others appear as name events.
>
> 	The absolute minimum to define a person in TMG is an ID number (the
> internal primary key) and preferably a "primary" name (and the name
> could be all blanks -- though having multiple people with no names, just
> ID numbers, makes for difficulty when later adding relationships: does
> this person connect to "(---unknown---)(---unknown---)" #2718 or to
> "(---unknown---)(---unknown---)" #3145 <G>)
>

Since we have graduated to a completely different topic I have renamed 
the thread.

If people are interested in a totally python-based open source FREE (as 
in no $$) package that can do all the above try gramps...

http://gramps-project.org/

I have used this package for a few years now and it is fantastic. Check 
out the features page to see what I mean.

http://gramps-project.org/features/

-- 
Cheers Simon

    Simon Cropper - Open Content Creator

    Free and Open Source Software Workflow Guides
    ------------------------------------------------------------
    Introduction               http://www.fossworkflowguides.com
    GIS Packages           http://www.fossworkflowguides.com/gis
    bash / Python    http://www.fossworkflowguides.com/scripting

[toc] | [prev] | [next] | [standalone]


#26777 — Re: Geneology Packages

FromBen Finney <ben+python@benfinney.id.au>
Date2012-08-09 14:00 +1000
SubjectRe: Geneology Packages
Message-ID<87lihohfza.fsf_-_@benfinney.id.au>
In reply to#26776
Simon Cropper <simoncropper@fossworkflowguides.com> writes:

> Since we have graduated to a completely different topic I have renamed
> the thread.

Thank you.

> If people are interested in a totally python-based open source FREE
> (as in no $$) package that can do all the above try gramps...
>
> http://gramps-project.org/

In addition to being open source and zero-cost, more importantly it is
free software.

> I have used this package for a few years now and it is fantastic.

I'm glad to hear this; I have seen Gramps mentioned for many years and
it's great to see a mature (> 10 years) Python project that's still
going strong and meeting a specialised need with free software.

-- 
 \     “I object to doing things that computers can do.” —Olin Shivers |
  `\                                                                   |
_o__)                                                                  |
Ben Finney

[toc] | [prev] | [next] | [standalone]


#26619 — Re: Looking for a good introduction to object oriented programming with Python

Fromrusi <rustompmody@gmail.com>
Date2012-08-06 05:19 -0700
SubjectRe: Looking for a good introduction to object oriented programming with Python
Message-ID<ff834c6e-4ccc-41f7-bfa8-5c189c2deebe@sn4g2000pbc.googlegroups.com>
In reply to#26550
On Aug 6, 12:46 am, lipska the kat <lipskathe...@yahoo.co.uk> wrote:
> On 04/08/12 16:49, Jean Dubois wrote:
>
> > I'm looking for a good introduction to object oriented programming
> > with Python.
>

> Object Oriented programming is a mindset, a way of looking at that
> particular part of our world that you are trying to encapsulate
> in computer language. The language you use is (should be) irrelevant.
>
> Actually it should really be called Class Oriented programming as
> classes are the units of encapsulation.
> I really don't think python is a good language to learn OO programming,
> the problem is that Python doesn't enforce OO so you are never going to
> learn what is 'OO' and what isn't.
>

> Learn Python by all means, the interactive mode is particularly fun,just
> try and get a good idea of what OO is all about before you start.

I suggest this
http://steve-yegge.blogspot.in/2006/03/execution-in-kingdom-of-nouns.html

Particularly useful if you are a bit drunk on snake-oil

[toc] | [prev] | [next] | [standalone]


#26622 — Re: Looking for a good introduction to object oriented programming with Python

Fromlipska the kat <lipskathekat@yahoo.co.uk>
Date2012-08-06 15:27 +0100
SubjectRe: Looking for a good introduction to object oriented programming with Python
Message-ID<Wb6dnUtmVZjWSYLNnZ2dnUVZ8r-dnZ2d@bt.com>
In reply to#26619
On 06/08/12 13:19, rusi wrote:
> On Aug 6, 12:46 am, lipska the kat<lipskathe...@yahoo.co.uk>  wrote:
>> On 04/08/12 16:49, Jean Dubois wrote:
>>
>>> I'm looking for a good introduction to object oriented programming
>>> with Python.
>>
>
>> Object Oriented programming is a mindset, a way of looking at that
>> particular part of our world that you are trying to encapsulate
>> in computer language. The language you use is (should be) irrelevant.

snip

>> Learn Python by all means, the interactive mode is particularly fun,just
>> try and get a good idea of what OO is all about before you start.
>
> I suggest this
> http://steve-yegge.blogspot.in/2006/03/execution-in-kingdom-of-nouns.html
>
> Particularly useful if you are a bit drunk on snake-oil

You take out the garbage.
I've got automatic garbage collection

lipska

-- 
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

[toc] | [prev] | [next] | [standalone]


#26636 — Re: Looking for a good introduction to object oriented programming with Python

Fromrusi <rustompmody@gmail.com>
Date2012-08-06 09:34 -0700
SubjectRe: Looking for a good introduction to object oriented programming with Python
Message-ID<bb58d679-dbf3-461b-b329-3d66d01f6941@w8g2000vbx.googlegroups.com>
In reply to#26622
On Aug 6, 7:27 pm, lipska the kat <lipskathe...@yahoo.co.uk> wrote:
> You take out the garbage.
> I've got automatic garbage collection

:-)


BTW in "automatic garbage collection" which of the three words is most
important? Least?

Heres another take on nouns (and therefore OO): http://hilgart.org/enformy/dma-verb.htm

[toc] | [prev] | [next] | [standalone]


#26667 — Re: Looking for a good introduction to object oriented programming with Python

FromChris Angelico <rosuav@gmail.com>
Date2012-08-07 08:44 +1000
SubjectRe: Looking for a good introduction to object oriented programming with Python
Message-ID<mailman.3037.1344293058.4697.python-list@python.org>
In reply to#26636
On Tue, Aug 7, 2012 at 2:34 AM, rusi <rustompmody@gmail.com> wrote:
> BTW in "automatic garbage collection" which of the three words is most
> important? Least?

Most important is "garbage". I sure don't want any language I use to
automatically collect non-garbage!!

But in seriousness, the definition of "garbage" is one of the trickier
things to work out, hence the variety of schemes (mark/sweep,
refcount, various forms of cycle detection, etc).

ChrisA

[toc] | [prev] | [next] | [standalone]


#26635 — OT probably but still relevant (was Re: Looking for a good introduction to object oriented programming with Python)

Fromlipska the kat <lipskathekat@yahoo.co.uk>
Date2012-08-06 17:23 +0100
SubjectOT probably but still relevant (was Re: Looking for a good introduction to object oriented programming with Python)
Message-ID<v-udneEnmZzkcoLNnZ2dnUVZ8uidnZ2d@bt.com>
In reply to#26619
On 06/08/12 13:19, rusi wrote:
> On Aug 6, 12:46 am, lipska the kat<lipskathe...@yahoo.co.uk>  wrote:
>> On 04/08/12 16:49, Jean Dubois wrote:
>>
>>> I'm looking for a good introduction to object oriented programming
>>> with Python.
>>

snip

>
> I suggest this
> http://steve-yegge.blogspot.in/2006/03/execution-in-kingdom-of-nouns.html

http://bpfurtado.livejournal.com/2006/10/21/

lipska

-- 
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

[toc] | [prev] | [next] | [standalone]


#26696 — Re: OT probably but still relevant (was Re: Looking for a good introduction to object oriented programming with Python)

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2012-08-07 09:44 +0000
SubjectRe: OT probably but still relevant (was Re: Looking for a good introduction to object oriented programming with Python)
Message-ID<5020e376$0$29867$c3e8da3$5496439d@news.astraweb.com>
In reply to#26635
On Mon, 06 Aug 2012 17:23:19 +0100, lipska the kat wrote:

> On 06/08/12 13:19, rusi wrote:

>> I suggest this
>> http://steve-yegge.blogspot.in/2006/03/execution-in-kingdom-of-
nouns.html
> 
> http://bpfurtado.livejournal.com/2006/10/21/

Unfortunately the author (Bruno Furtado) has missed the point. He seems 
to think that Kingdom of Nouns ("the Rant") is an anti-OO screed. It is 
not. There is more to OO than Java, and criticism of Java does not mean 
"objects are bad".


Nor is it that Kingdom of Nouns believes the problem is "Two lines per 
source code file!!!". It isn't just that two extra lines when you declare 
a function. It is the extraneous, unnecessary extra layer each time you 
read (or write, but mostly read) the method, and the ever-more abstract, 
deep layers of Builders, Getters, Setters, Doers and so forth.

In Python, occasionally you will come across code like this:

value = time.time()

which is the time function in the time module. Pretty skanky, right? It's 
not likely that you have a whole bunch of spam.time, foo.time, 
physics.time etc. in your code base, right? If you do, then maybe this is 
justified, but how often does that happen?

Having that duplicated time.time is a code smell that says "you might 
have too many code layers here, better look at this a bit more closely".

Now imagine if this was a more Java-ish language:

value = time.time.time()

where you have method time of class time in module time. And you have to 
call it that way *all the time* (pun not intended).

That's not so much a "might" have too many layers, as "almost certainly".

In Java, all those dot look-ups happen at compile time and are fast. In 
Python, they happen at runtime, and while they're still often fast, 
sometimes they can be slow. But that's not the real problem. The real 
problem is reading and writing it.

Python solves that two ways:

1) Modules, classes, methods and functions are first-class objects, so 
you can do this:

from time import time
# or if you prefer, "import time; time = time.time"
value = time()


2) It doesn't force you to use the same number of layers for 
*everything*. If you have code that will benefit from two, or three, or 
seventeen, layers, you are free to do so:

value = (time.time() + spacetime.Time.time() - Spam.time.flavour()
        + Cube.time())

And if not, then don't:

value = time() + spacetime.time() - flavour() + Cube.time()


It is this which is the point of Kingdom of Nouns. It is not an anti-OO 
screed. It is not an argument against namespaces, or encapsulation, or 
especially not that Java methods take an extra "Two lines per source 
file". It is that Java forces a single mental model on you, all the time, 
whether it makes for better, more readable code or not.



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#26698 — Re: OT probably but still relevant (was Re: Looking for a good introduction to object oriented programming with Python)

Fromlipska the kat <lipskathekat@yahoo.co.uk>
Date2012-08-07 11:23 +0100
SubjectRe: OT probably but still relevant (was Re: Looking for a good introduction to object oriented programming with Python)
Message-ID<p_WdnQ0Ci5o0cb3NnZ2dnUVZ7vSdnZ2d@bt.com>
In reply to#26696
On 07/08/12 10:44, Steven D'Aprano wrote:
> On Mon, 06 Aug 2012 17:23:19 +0100, lipska the kat wrote:
>
>> On 06/08/12 13:19, rusi wrote:
>
>>> I suggest this
>>> http://steve-yegge.blogspot.in/2006/03/execution-in-kingdom-of-
> nouns.html
>>
>> http://bpfurtado.livejournal.com/2006/10/21/
>
> Unfortunately the author (Bruno Furtado) has missed the point. He seems

Steve, chill out, you seem to have this whole Javahate thing going at 
the moment. It's just a language, like Python. You can write crap code 
in Java just like you can write crap code in any language. Just for the 
record 'Time' is way too complex a concept to encapsulate in a single 
class (we can debate that if you like although it all gets a bit 
philosophical) If you MUST have a Time Object in Java you can 
instantiate java.sql.Time, not really that complicated is it ?

I do enjoy debating with you but really, lighten up a bit, it really 
isn't that important, mankind existed for millenia before computers and 
programming languages. If we want to exist for millenia after their 
invention then we need to get off this planet. If you want to get 
excited about something then get excited about our apparent inability to 
exceed the speed of light. Until we solve that one we are doomed.

<waits for rant about how Java has destroyed the space program>

I'm thinking of adding a line to my sig for this group that says

"I don't hate Python, I like it for it's differences"

;-)

lipska

-- 
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

[toc] | [prev] | [standalone]


Page 4 of 4 — ← Prev page 1 2 3 [4]

Back to top | Article view | comp.lang.python


csiph-web