Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

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

 

 

First page Previous page 1 2 Next page Last page  View All Python python RSS feed   Index | Next | Previous | View Threaded


jeandubois314 at gmail

Aug 5, 2012, 5:38 AM

Post #1 of 41 (890 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python

On 5 aug, 02:11, shearich...@gmail.com wrote:
> One reason you may be having difficulty is that unlike some languages (C++/Java) object-orientation is not a be all and end all in Python, in fact you could work with Python for a long time without really 'doing it' at all (well other than calling methods/properties on existing API's). Having said that here's what I would suggest ...
>
> Could do worse than this :
>
> http://www.diveintopython.net/object_oriented_framework/index.html
>
> and this
>
> http://docs.python.org/tutorial/classes.html
>
> read together.
>
> Judging by your question this is a probably a little advanced for now but you could bookmark it for the future:
>
> http://www.catonmat.net/blog/learning-python-design-patterns-through-...
>
> Here's the corresponding PDF to go with the video:
>
> http://assets.en.oreilly.com/1/event/45/Practical%20Python%20Patterns...

Thanks a lot for this information, I'll check it out the following
days

best regards,
Jean
--
http://mail.python.org/mailman/listinfo/python-list


jeandubois314 at gmail

Aug 5, 2012, 11:04 AM

Post #2 of 41 (856 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

On 5 aug, 02:11, shearich...@gmail.com wrote:
> One reason you may be having difficulty is that unlike some languages (C++/Java) object-orientation is not a be all and end all in Python, in fact you could work with Python for a long time without really 'doing it' at all (well other than calling methods/properties on existing API's). Having said that here's what I would suggest ...
>
> Could do worse than this :
>
> http://www.diveintopython.net/object_oriented_framework/index.html
>
This example seems to tell you need the concept of dictionaries to
explain object oriented programming, is this really necessary?
> and this
>
> http://docs.python.org/tutorial/classes.html
Unfortunately, the trouble with this explanation is exactly what made
me ask the original question: it starts from concepts in c++ making it
very hard to understand for someone who does not know that language
already.
>
> read together.
>
> Judging by your question this is a probably a little advanced for now but you could bookmark it for the future:
>
> http://www.catonmat.net/blog/learning-python-design-patterns-through-...
>
> Here's the corresponding PDF to go with the video:
>
> http://assets.en.oreilly.com/1/event/45/Practical%20Python%20Patterns...
Can someone here on this list give a trivial example of what object
oriented programming is, using only Python?

thanks in advance
Jean
--
http://mail.python.org/mailman/listinfo/python-list


breamoreboy at yahoo

Aug 5, 2012, 11:28 AM

Post #3 of 41 (856 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

On 05/08/2012 19:04, Jean Dubois wrote:
> On 5 aug, 02:11, shearich...@gmail.com wrote:
>> One reason you may be having difficulty is that unlike some languages (C++/Java) object-orientation is not a be all and end all in Python, in fact you could work with Python for a long time without really 'doing it' at all (well other than calling methods/properties on existing API's). Having said that here's what I would suggest ...
>>
>> Could do worse than this :
>>
>> http://www.diveintopython.net/object_oriented_framework/index.html
>>
> This example seems to tell you need the concept of dictionaries to
> explain object oriented programming, is this really necessary?
>> and this
>>
>> http://docs.python.org/tutorial/classes.html
> Unfortunately, the trouble with this explanation is exactly what made
> me ask the original question: it starts from concepts in c++ making it
> very hard to understand for someone who does not know that language
> already.
>>
>> read together.
>>
>> Judging by your question this is a probably a little advanced for now but you could bookmark it for the future:
>>
>> http://www.catonmat.net/blog/learning-python-design-patterns-through-...
>>
>> Here's the corresponding PDF to go with the video:
>>
>> http://assets.en.oreilly.com/1/event/45/Practical%20Python%20Patterns...
> Can someone here on this list give a trivial example of what object
> oriented programming is, using only Python?
>
> thanks in advance
> Jean
>

Try this http://www.voidspace.org.uk/python/articles/OOP.shtml ???

--
Cheers.

Mark Lawrence.

--
http://mail.python.org/mailman/listinfo/python-list


roy at panix

Aug 5, 2012, 11:39 AM

Post #4 of 41 (853 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

In article
<8f1b60a5-0411-4aae-9ee6-0025b493ca2d [at] m13g2000vbd>,
Jean Dubois <jeandubois314 [at] gmail> wrote:

> Can someone here on this list give a trivial example of what object
> oriented programming is, using only Python?

OOP seems to mean different things to different people. What OOP means
to you is usually a strong function of whatever OOP language you learned
first. That being said, I think the fundamental, universal, core
principle of OOP is that an object contains some data, and some code
that knows how to do something with that data.

So, to give you a simple (but real-life) example, the system I'm working
in now has User objects. A user is a pretty complicated class, but
here's some simple methods from it:

def __eq__(self, other):
return isinstance(other, (User, AnonymousUser)) \
and self.user_id == other.user_id

def __unicode__(self):
return self.username

def __repr__(self):
return '<User %d: %r>' % (self.user_id, self.username)

This defines a few basic behaviors for User objects.

First, it defines how to tell if something is equal to a given User
object. The something must itself be a User (ignore the minor
complication about AnonymousUser for the moment), and it must have the
same user_id as this one. I could easily imagine lots of other possible
ways two users could be considered equal (same username, for example),
but we're using user_id. This means I can write:

if user1 == user2:
print "they're the same"

and I don't have to worry about (or even know about) the details. In
fact, sometime long after I've written that code, somebody could define
some new kind of HighSecurityUser which tests for equality by comparing
the scanned retina images for both of them. My code wouldn't have to
change; it would magically just start enforcing retina matching.

Likewise, I can write:

print user

or

logger.warning("%r did something interesting", user)

and I don't have to know anything about how to print a User. The User
knows how to print itself.
--
http://mail.python.org/mailman/listinfo/python-list


iftecan2000 at gmail

Aug 5, 2012, 11:43 AM

Post #5 of 41 (853 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

I would recommend Bruce Eckel's Thining in Python. Check it out here
http://www.mindview.net/Books/TIPython/



On Sun, Aug 5, 2012 at 8:28 PM, Mark Lawrence <breamoreboy [at] yahoo>wrote:

> On 05/08/2012 19:04, Jean Dubois wrote:
>
>> On 5 aug, 02:11, shearich...@gmail.com wrote:
>>
>>> One reason you may be having difficulty is that unlike some languages
>>> (C++/Java) object-orientation is not a be all and end all in Python, in
>>> fact you could work with Python for a long time without really 'doing it'
>>> at all (well other than calling methods/properties on existing API's).
>>> Having said that here's what I would suggest ...
>>>
>>> Could do worse than this :
>>>
>>> http://www.diveintopython.net/**object_oriented_framework/**index.html<http://www.diveintopython.net/object_oriented_framework/index.html>
>>>
>>> This example seems to tell you need the concept of dictionaries to
>> explain object oriented programming, is this really necessary?
>>
>>> and this
>>>
>>> http://docs.python.org/**tutorial/classes.html<http://docs.python.org/tutorial/classes.html>
>>>
>> Unfortunately, the trouble with this explanation is exactly what made
>> me ask the original question: it starts from concepts in c++ making it
>> very hard to understand for someone who does not know that language
>> already.
>>
>>>
>>> read together.
>>>
>>> Judging by your question this is a probably a little advanced for now
>>> but you could bookmark it for the future:
>>>
>>> http://www.catonmat.net/blog/**learning-python-design-**
>>> patterns-through-.<http://www.catonmat.net/blog/learning-python-design-patterns-through-.>
>>> ..
>>>
>>> Here's the corresponding PDF to go with the video:
>>>
>>> http://assets.en.oreilly.com/**1/event/45/Practical%20Python%**
>>> 20Patterns.<http://assets.en.oreilly.com/1/event/45/Practical%20Python%20Patterns.>
>>> ..
>>>
>> Can someone here on this list give a trivial example of what object
>> oriented programming is, using only Python?
>>
>> thanks in advance
>> Jean
>>
>>
> Try this http://www.voidspace.org.uk/**python/articles/OOP.shtml<http://www.voidspace.org.uk/python/articles/OOP.shtml>???
>
> --
> Cheers.
>
> Mark Lawrence.
>
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>


breamoreboy at yahoo

Aug 5, 2012, 11:53 AM

Post #6 of 41 (853 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

On 05/08/2012 19:43, Ifthikhan Nazeem wrote:
[top posting fixed]
>
> On Sun, Aug 5, 2012 at 8:28 PM, Mark Lawrence <breamoreboy [at] yahoo>wrote:
>
>> On 05/08/2012 19:04, Jean Dubois wrote:
>>
>>> On 5 aug, 02:11, shearich...@gmail.com wrote:
>>>
>>>> One reason you may be having difficulty is that unlike some languages
>>>> (C++/Java) object-orientation is not a be all and end all in Python, in
>>>> fact you could work with Python for a long time without really 'doing it'
>>>> at all (well other than calling methods/properties on existing API's).
>>>> Having said that here's what I would suggest ...
>>>>
>>>> Could do worse than this :
>>>>
>>>> http://www.diveintopython.net/**object_oriented_framework/**index.html<http://www.diveintopython.net/object_oriented_framework/index.html>
>>>>
>>>> This example seems to tell you need the concept of dictionaries to
>>> explain object oriented programming, is this really necessary?
>>>
>>>> and this
>>>>
>>>> http://docs.python.org/**tutorial/classes.html<http://docs.python.org/tutorial/classes.html>
>>>>
>>> Unfortunately, the trouble with this explanation is exactly what made
>>> me ask the original question: it starts from concepts in c++ making it
>>> very hard to understand for someone who does not know that language
>>> already.
>>>
>>>>
>>>> read together.
>>>>
>>>> Judging by your question this is a probably a little advanced for now
>>>> but you could bookmark it for the future:
>>>>
>>>> http://www.catonmat.net/blog/**learning-python-design-**
>>>> patterns-through-.<http://www.catonmat.net/blog/learning-python-design-patterns-through-.>
>>>> ..
>>>>
>>>> Here's the corresponding PDF to go with the video:
>>>>
>>>> http://assets.en.oreilly.com/**1/event/45/Practical%20Python%**
>>>> 20Patterns.<http://assets.en.oreilly.com/1/event/45/Practical%20Python%20Patterns.>
>>>> ..
>>>>
>>> Can someone here on this list give a trivial example of what object
>>> oriented programming is, using only Python?
>>>
>>> thanks in advance
>>> Jean
>>>
>>>
>> Try this http://www.voidspace.org.uk/**python/articles/OOP.shtml<http://www.voidspace.org.uk/python/articles/OOP.shtml>???
>>
>> --
>> Cheers.
>>
>> Mark Lawrence.
>>
>> --
>> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>>
>
> I would recommend Bruce Eckel's Thining in Python. Check it out here
> http://www.mindview.net/Books/TIPython/
>
>

I'd forgotten about that so thanks for the reminder.

--
Cheers.

Mark Lawrence.

--
http://mail.python.org/mailman/listinfo/python-list


steve+comp.lang.python at pearwood

Aug 5, 2012, 3:51 PM

Post #7 of 41 (856 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

On Sun, 05 Aug 2012 18:45:47 -0400, Dennis Lee Bieber wrote:

> Don't look for Object-Oriented Programming -- since the first widely
> popular OOP language was C++ (Smalltalk was earlier, but rather
> specialized, whereas C++ started as a preprocessor for C).
>
> Rather look for Object-Oriented Analysis and Design (OOAD). An OOAD
> textbook /should/ be language neutral and, these days, likely using the
> constructs/notation of UML [.which derived from a merger of two or three
> separate proposals for OOAD tools]

Good lord. I'd rather read C++ than UML. And I can't read C++.



--
Steven
--
http://mail.python.org/mailman/listinfo/python-list


roy at panix

Aug 5, 2012, 4:12 PM

Post #8 of 41 (855 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

In article <501ef904$0$29867$c3e8da3$5496439d [at] news>,
Steven D'Aprano <steve+comp.lang.python [at] pearwood> wrote:

> On Sun, 05 Aug 2012 18:45:47 -0400, Dennis Lee Bieber wrote:
>
> > Don't look for Object-Oriented Programming -- since the first widely
> > popular OOP language was C++ (Smalltalk was earlier, but rather
> > specialized, whereas C++ started as a preprocessor for C).
> >
> > Rather look for Object-Oriented Analysis and Design (OOAD). An OOAD
> > textbook /should/ be language neutral and, these days, likely using the
> > constructs/notation of UML [.which derived from a merger of two or three
> > separate proposals for OOAD tools]
>
> Good lord. I'd rather read C++ than UML. And I can't read C++.

UML is under-rated. I certainly don't have any love of the 47 different
flavors of diagram, but the basic idea of having a common graphical
language for describing how objects and classes interact is pretty
useful. Just don't ask me to remember which kind of arrowhead I'm
supposed to use in which situation.
--
http://mail.python.org/mailman/listinfo/python-list


breamoreboy at yahoo

Aug 5, 2012, 4:30 PM

Post #9 of 41 (856 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

On 06/08/2012 00:12, Roy Smith wrote:
> In article <501ef904$0$29867$c3e8da3$5496439d [at] news>,
> Steven D'Aprano <steve+comp.lang.python [at] pearwood> wrote:
>
>> On Sun, 05 Aug 2012 18:45:47 -0400, Dennis Lee Bieber wrote:
>>
>>> Don't look for Object-Oriented Programming -- since the first widely
>>> popular OOP language was C++ (Smalltalk was earlier, but rather
>>> specialized, whereas C++ started as a preprocessor for C).
>>>
>>> Rather look for Object-Oriented Analysis and Design (OOAD). An OOAD
>>> textbook /should/ be language neutral and, these days, likely using the
>>> constructs/notation of UML [.which derived from a merger of two or three
>>> separate proposals for OOAD tools]
>>
>> Good lord. I'd rather read C++ than UML. And I can't read C++.
>
> UML is under-rated. I certainly don't have any love of the 47 different
> flavors of diagram, but the basic idea of having a common graphical
> language for describing how objects and classes interact is pretty
> useful. Just don't ask me to remember which kind of arrowhead I'm
> supposed to use in which situation.
>

Ask nicely and I'll lend you my copy of Martin Fowler's UML Distilled
which covers "version 1.2 OMG UML standard". What's it up to now,
version 17.38?

--
Cheers.

Mark Lawrence.

--
http://mail.python.org/mailman/listinfo/python-list


steve+comp.lang.python at pearwood

Aug 5, 2012, 5:27 PM

Post #10 of 41 (856 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

On Sun, 05 Aug 2012 19:12:35 -0400, Roy Smith wrote:

>> Good lord. I'd rather read C++ than UML. And I can't read C++.
>
> UML is under-rated. I certainly don't have any love of the 47 different
> flavors of diagram, but the basic idea of having a common graphical
> language for describing how objects and classes interact is pretty
> useful. Just don't ask me to remember which kind of arrowhead I'm
> supposed to use in which situation.


I frequently draw diagrams to understand the relationships between my
classes and the problem I am trying to solve. I almost invariably use one
type of box and one type of arrowhead. Sometimes if I'm bored I draw
doodles on the diagram. If only I could remember to be consistent about
what doodle I draw where, I too could be an UML guru.


--
Steven
--
http://mail.python.org/mailman/listinfo/python-list


dan at tombstonezero

Aug 5, 2012, 5:50 PM

Post #11 of 41 (854 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

On 2012-08-06 at 00:27:43 +0000,
Steven D'Aprano <steve+comp.lang.python [at] pearwood> wrote:

> I frequently draw diagrams to understand the relationships between my
> classes and the problem I am trying to solve. I almost invariably use one
> type of box and one type of arrowhead. Sometimes if I'm bored I draw
> doodles on the diagram. If only I could remember to be consistent about
> what doodle I draw where, I too could be an UML guru.

+1
--
http://mail.python.org/mailman/listinfo/python-list


wuwei23 at gmail

Aug 5, 2012, 7:44 PM

Post #12 of 41 (855 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

On Aug 6, 10:22 am, Steven D'Aprano <steve
+comp.lang.pyt...@pearwood.info> wrote:
> In my not-so-humble opinion, the popularity of Design Patterns has a lot
> to do with the fact that they are so abstract and jargon-ridden that they
> have become a badge of membership into an elite. Shorn of their excessive
> abstractness, they're not very special. People were writing helper
> functions to assemble complex data long before the Builder pattern was
> named, and a Facade is just an interface layer.

I think you've entirely missed the point of Design Patterns.

No one claims that the Go4 DP book introduced Builders, Singletons,
Facades. The point was to identify _and name_ such patterns, so
programmers could actually talk about repeated behaviour. Design
patterns are an attempt to encapsulate and express experience, that's
it. There's nothing mystical or special about them at all, and to be
honest I never ever such claims come from proponents of them, only
their critics.

Why is it an "elitist" action to want to be able to share experience
and learn from that of others? If anything, I find the problem is with
the insular nature of most developers and the preponderance of NIH
attitudes.
--
http://mail.python.org/mailman/listinfo/python-list


news4 at mystrobl

Aug 5, 2012, 11:18 PM

Post #13 of 41 (856 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

Dennis Lee Bieber <wlfraed [at] ix>:

> Don't look for Object-Oriented Programming -- since the first widely
>popular OOP language was C++ (Smalltalk was earlier, but rather
>specialized, whereas C++ started as a preprocessor for C).

Well, C++ did to C what Simula 67 did to Algol 60, much earlier. Simula
was quite popular at its time.

<http://en.wikipedia.org/wiki/Simula>


--
Thank you for observing all safety precautions
--
http://mail.python.org/mailman/listinfo/python-list


lipskathekat at yahoo

Aug 6, 2012, 12:43 AM

Post #14 of 41 (856 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

On 05/08/12 23:51, Steven D'Aprano wrote:
> On Sun, 05 Aug 2012 18:45:47 -0400, Dennis Lee Bieber wrote:
>
>> Don't look for Object-Oriented Programming -- since the first widely
>> popular OOP language was C++ (Smalltalk was earlier, but rather
>> specialized, whereas C++ started as a preprocessor for C).
>> Rather look for Object-Oriented Analysis and Design (OOAD). An OOAD
>> textbook /should/ be language neutral and, these days, likely using the
>> constructs/notation of UML [.which derived from a merger of two or three
>> separate proposals for OOAD tools]
>
> Good lord. I'd rather read C++ than UML. And I can't read C++.

This reminds me of a consultant I once worked with.
He had worked on government projects for a decade or more and was a
staunch supporter of the 'big bang' approach to software development.
I asked him how many of these had been a success ... deafening silence.

His attitude to UML was 'I'd rather cut my right arm off than waste time
with that new fangled nonsense'

UML works, non technical 'stakeholders' (yuk) can understand it at a
high level and in my HUMBLE opinion the sequence diagram is the single
most important piece of documentation in the entire software project

jeez

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


lipskathekat at yahoo

Aug 6, 2012, 12:48 AM

Post #15 of 41 (856 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

On 06/08/12 01:27, Steven D'Aprano wrote:
> On Sun, 05 Aug 2012 19:12:35 -0400, Roy Smith wrote:
>
>>> Good lord. I'd rather read C++ than UML. And I can't read C++.
>>
>> UML is under-rated. I certainly don't have any love of the 47 different
>> flavors of diagram, but the basic idea of having a common graphical
>> language for describing how objects and classes interact is pretty
>> useful. Just don't ask me to remember which kind of arrowhead I'm
>> supposed to use in which situation.
>
>
> I frequently draw diagrams to understand the relationships between my
> classes and the problem I am trying to solve. I almost invariably use one
> type of box and one type of arrowhead. Sometimes if I'm bored I draw
> doodles on the diagram. If only I could remember to be consistent about
> what doodle I draw where, I too could be an UML guru.
>

Yea, it can be tricky. But if you persevere you will gain enlightenment.
It does take a bit of application though.

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


djc at news

Aug 6, 2012, 2:20 AM

Post #16 of 41 (856 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

On 06/08/12 02:27, Steven D'Aprano wrote:
> On Sun, 05 Aug 2012 19:12:35 -0400, Roy Smith wrote:
>
>>> Good lord. I'd rather read C++ than UML. And I can't read C++.
>>
>> UML is under-rated. I certainly don't have any love of the 47 different
>> flavors of diagram, but the basic idea of having a common graphical
>> language for describing how objects and classes interact is pretty
>> useful. Just don't ask me to remember which kind of arrowhead I'm
>> supposed to use in which situation.
>
>
> I frequently draw diagrams to understand the relationships between my
> classes and the problem I am trying to solve. I almost invariably use one
> type of box and one type of arrowhead. Sometimes if I'm bored I draw
> doodles on the diagram. If only I could remember to be consistent about
> what doodle I draw where, I too could be an UML guru.
>
>
Flow Charts redux
--
http://mail.python.org/mailman/listinfo/python-list


roy at panix

Aug 6, 2012, 6:16 AM

Post #17 of 41 (852 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

In article <w42dnZxoF-IT6ILNnZ2dnUVZ8vydnZ2d [at] bt>,
lipska the kat <lipskathekat [at] yahoo> wrote:

> UML works, non technical 'stakeholders' (yuk) can understand it at a
> high level and in my HUMBLE opinion the sequence diagram is the single
> most important piece of documentation in the entire software project

Yup. Sequence diagrams are the most common one I draw. I'm sure I use
the wrong kinds of arrowheads and such, but the general idea is pretty
powerful.

I find they can be useful for figuring out some horrible piece of code
you've never worked with before. Just sit down and start reading the
code, drawing the diagram as you go. Sometimes things start to make
sense that way when just staring at the code isn't doing it for you.

My most successful experiment with UML was when trying to understand
some big hunk of C++ somebody had thrown at me. I imported the whole
thing into some UML tool, which not only found all the classes, but also
sorted out how they were related. Pushing boxes around in the GUI tool
turned out to be a useful way to get my head around how the code worked.

The problem with UML is that, like so many good ideas, it has developed
a mystique around it. With layers of gurus who know progressively more
and more about the esoteric details. And who make a living writing
books and giving seminars about it. Kind of like patterns, and agile,
and scrum, and XP, and so on.
--
http://mail.python.org/mailman/listinfo/python-list


lipskathekat at yahoo

Aug 6, 2012, 7:27 AM

Post #18 of 41 (856 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

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
--
http://mail.python.org/mailman/listinfo/python-list


jeandubois314 at gmail

Aug 6, 2012, 7:56 AM

Post #19 of 41 (853 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

On 5 aug, 20:28, Mark Lawrence <breamore...@yahoo.co.uk> wrote:
> On 05/08/2012 19:04, Jean Dubois wrote:
>
>
>
>
>
>
>
>
>
> > On 5 aug, 02:11, shearich...@gmail.com wrote:
> >> One reason you may be having difficulty is that unlike some languages (C++/Java) object-orientation is not a be all and end all in Python, in fact you could work with Python for a long time without really 'doing it' at all (well other than calling methods/properties on existing API's). Having said that here's what I would suggest ...
>
> >> Could do worse than this :
>
> >>http://www.diveintopython.net/object_oriented_framework/index.html
>
> > This example seems to tell you need the concept of dictionaries to
> > explain object oriented programming, is this really necessary?
> >> and this
>
> >>http://docs.python.org/tutorial/classes.html
> > Unfortunately, the trouble with this explanation is exactly what made
> > me ask the original question: it starts from concepts in c++ making it
> > very hard to understand for someone who does not know that language
> > already.
>
> >> read together.
>
> >> Judging by your question this is a probably a little advanced for now but you could bookmark it for the future:
>
> >>http://www.catonmat.net/blog/learning-python-design-patterns-through-...
>
> >> Here's the corresponding PDF to go with the video:
>
> >>http://assets.en.oreilly.com/1/event/45/Practical%20Python%20Patterns...
> > Can someone here on this list give a trivial example of what object
> > oriented programming is, using only Python?
>
> > thanks in advance
> > Jean
>
> Try thishttp://www.voidspace.org.uk/python/articles/OOP.shtml???
>
> --
> Cheers.
>
> Mark Lawrence.
Thanks, this one is a lot better. Could you just tell me what the use
is of the following lines:
"""Class docstring."""
"""Method docstring."""
"""Method docstring."""
Taken from the following code fragment (I really want to understand
every bit of code, and the author doesn't mention this)


class OurClass(object):
"""Class docstring."""

def __init__(self, arg1, arg2):
"""Method docstring."""
self.arg1 = arg1
self.arg2 = arg2

def printargs(self):
"""Method docstring."""
print self.arg1
print self.arg2



thanks in advance
jean
--
http://mail.python.org/mailman/listinfo/python-list


maniandram01 at gmail

Aug 6, 2012, 8:38 AM

Post #20 of 41 (853 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

Its a docstring - it documents the function/class
Did you know that docstrings can be used for testing - look at the doctest
standard library module!
try:

class A:
def method(self):
'''Sample method
This method does the difficult task X.
Call this method with no arguments.'''#docstring
pass

then type :

help(A.method)

And viola!
On 6 August 2012 20:26, Jean Dubois <jeandubois314 [at] gmail> wrote:

> On 5 aug, 20:28, Mark Lawrence <breamore...@yahoo.co.uk> wrote:
> > On 05/08/2012 19:04, Jean Dubois wrote:
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > On 5 aug, 02:11, shearich...@gmail.com wrote:
> > >> One reason you may be having difficulty is that unlike some languages
> (C++/Java) object-orientation is not a be all and end all in Python, in
> fact you could work with Python for a long time without really 'doing it'
> at all (well other than calling methods/properties on existing API's).
> Having said that here's what I would suggest ...
> >
> > >> Could do worse than this :
> >
> > >>http://www.diveintopython.net/object_oriented_framework/index.html
> >
> > > This example seems to tell you need the concept of dictionaries to
> > > explain object oriented programming, is this really necessary?
> > >> and this
> >
> > >>http://docs.python.org/tutorial/classes.html
> > > Unfortunately, the trouble with this explanation is exactly what made
> > > me ask the original question: it starts from concepts in c++ making it
> > > very hard to understand for someone who does not know that language
> > > already.
> >
> > >> read together.
> >
> > >> Judging by your question this is a probably a little advanced for now
> but you could bookmark it for the future:
> >
> > >>http://www.catonmat.net/blog/learning-python-design-patterns-through-.
> ..
> >
> > >> Here's the corresponding PDF to go with the video:
> >
> > >>http://assets.en.oreilly.com/1/event/45/Practical%20Python%20Patterns.
> ..
> > > Can someone here on this list give a trivial example of what object
> > > oriented programming is, using only Python?
> >
> > > thanks in advance
> > > Jean
> >
> > Try thishttp://www.voidspace.org.uk/python/articles/OOP.shtml???
> >
> > --
> > Cheers.
> >
> > Mark Lawrence.
> Thanks, this one is a lot better. Could you just tell me what the use
> is of the following lines:
> """Class docstring."""
> """Method docstring."""
> """Method docstring."""
> Taken from the following code fragment (I really want to understand
> every bit of code, and the author doesn't mention this)
>
>
> class OurClass(object):
> """Class docstring."""
>
> def __init__(self, arg1, arg2):
> """Method docstring."""
> self.arg1 = arg1
> self.arg2 = arg2
>
> def printargs(self):
> """Method docstring."""
> print self.arg1
> print self.arg2
>
>
>
> thanks in advance
> jean
> --
> http://mail.python.org/mailman/listinfo/python-list
>


breamoreboy at yahoo

Aug 6, 2012, 9:17 AM

Post #21 of 41 (853 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

Please see my comment at the bottom hint hint :)

On 06/08/2012 16:38, Ramchandra Apte wrote:
> Its a docstring - it documents the function/class
> Did you know that docstrings can be used for testing - look at the doctest
> standard library module!
> try:
>
> class A:
> def method(self):
> '''Sample method
> This method does the difficult task X.
> Call this method with no arguments.'''#docstring
> pass
>
> then type :
>
> help(A.method)
>
> And viola!
> On 6 August 2012 20:26, Jean Dubois <jeandubois314 [at] gmail> wrote:
>
>> On 5 aug, 20:28, Mark Lawrence <breamore...@yahoo.co.uk> wrote:
>>> On 05/08/2012 19:04, Jean Dubois wrote:
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>> On 5 aug, 02:11, shearich...@gmail.com wrote:
>>>>> One reason you may be having difficulty is that unlike some languages
>> (C++/Java) object-orientation is not a be all and end all in Python, in
>> fact you could work with Python for a long time without really 'doing it'
>> at all (well other than calling methods/properties on existing API's).
>> Having said that here's what I would suggest ...
>>>
>>>>> Could do worse than this :
>>>
>>>>> http://www.diveintopython.net/object_oriented_framework/index.html
>>>
>>>> This example seems to tell you need the concept of dictionaries to
>>>> explain object oriented programming, is this really necessary?
>>>>> and this
>>>
>>>>> http://docs.python.org/tutorial/classes.html
>>>> Unfortunately, the trouble with this explanation is exactly what made
>>>> me ask the original question: it starts from concepts in c++ making it
>>>> very hard to understand for someone who does not know that language
>>>> already.
>>>
>>>>> read together.
>>>
>>>>> Judging by your question this is a probably a little advanced for now
>> but you could bookmark it for the future:
>>>
>>>>> http://www.catonmat.net/blog/learning-python-design-patterns-through-.
>> ..
>>>
>>>>> Here's the corresponding PDF to go with the video:
>>>
>>>>> http://assets.en.oreilly.com/1/event/45/Practical%20Python%20Patterns.
>> ..
>>>> Can someone here on this list give a trivial example of what object
>>>> oriented programming is, using only Python?
>>>
>>>> thanks in advance
>>>> Jean
>>>
>>> Try thishttp://www.voidspace.org.uk/python/articles/OOP.shtml???
>>>
>>> --
>>> Cheers.
>>>
>>> Mark Lawrence.
>> Thanks, this one is a lot better. Could you just tell me what the use
>> is of the following lines:
>> """Class docstring."""
>> """Method docstring."""
>> """Method docstring."""
>> Taken from the following code fragment (I really want to understand
>> every bit of code, and the author doesn't mention this)
>>
>>
>> class OurClass(object):
>> """Class docstring."""
>>
>> def __init__(self, arg1, arg2):
>> """Method docstring."""
>> self.arg1 = arg1
>> self.arg2 = arg2
>>
>> def printargs(self):
>> """Method docstring."""
>> print self.arg1
>> print self.arg2
>>
>>
>>
>> thanks in advance
>> jean
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
>
>

Ramchandra Apte will you please stop top posting. In your native
language you may well but from bottom to top, but this news group
prefers reading top to bottom :) Thanks.

--
Cheers.

Mark Lawrence.

--
http://mail.python.org/mailman/listinfo/python-list


rustompmody at gmail

Aug 6, 2012, 9:34 AM

Post #22 of 41 (857 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

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
--
http://mail.python.org/mailman/listinfo/python-list


rosuav at gmail

Aug 6, 2012, 3:44 PM

Post #23 of 41 (856 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

On Tue, Aug 7, 2012 at 2:34 AM, rusi <rustompmody [at] gmail> 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
--
http://mail.python.org/mailman/listinfo/python-list


steve+comp.lang.python at pearwood

Aug 6, 2012, 6:12 PM

Post #24 of 41 (856 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

On Mon, 06 Aug 2012 17:17:33 +0100, Mark Lawrence wrote:

> Please see my comment at the bottom hint hint :)

Please trim unnecessary quoted text.

We don't need to see the entire thread of comment/reply/reply-to-reply
duplicated in *every* email.


--
Steven
--
http://mail.python.org/mailman/listinfo/python-list


ben+python at benfinney

Aug 6, 2012, 6:23 PM

Post #25 of 41 (854 views)
Permalink
Re: Looking for a good introduction to object oriented programming with Python [In reply to]

Steven D'Aprano <steve+comp.lang.python [at] pearwood> writes:

> Please trim unnecessary quoted text.
>
> We don't need to see the entire thread of comment/reply/reply-to-reply
> duplicated in *every* email.

s/every/any/

--
\ “If you make people think they're thinking, they'll love you; |
`\ but if you really make them think, they'll hate you.” —Donald |
_o__) Robert Perry Marquis |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list

First page Previous page 1 2 Next page Last page  View All Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.