Re: [Tutor] OOP help needed

2016-07-27 Thread Jim Byrnes
On 07/27/2016 04:04 AM, Alan Gauld via Tutor wrote: On 27/07/16 04:44, Jim Byrnes wrote: OOP has always driven me crazy. I read the material and follow the examples until I feel I understand them, but when I try to implement it I end up with an error filled mess. That suggests that its not th

Re: [Tutor] OOP help needed

2016-07-27 Thread Jim Byrnes
On 07/27/2016 03:12 AM, Peter Otten wrote: Jim Byrnes wrote: OOP has always driven me crazy. I read the material and follow the examples until I feel I understand them, but when I try to implement it I end up with an error filled mess. So I decided to give it another try. When I got to the c

Re: [Tutor] OOP help needed

2016-07-27 Thread Jim Byrnes
On 07/26/2016 11:38 PM, Ben Finney wrote: Jim Byrnes writes: So I decided to give it another try. When I got to the chapter on tkinter I decided to solve all the exercises using OOP even though the book solutions did not use OOP. Hmm, that sounds ill advised. OOP is one tool among many; try

Re: [Tutor] OOP help needed

2016-07-27 Thread Alan Gauld via Tutor
On 27/07/16 04:44, Jim Byrnes wrote: > OOP has always driven me crazy. I read the material and follow the > examples until I feel I understand them, but when I try to implement it > I end up with an error filled mess. That suggests that its not the OOP concept thats confusing you but the langua

Re: [Tutor] OOP help needed

2016-07-27 Thread Peter Otten
Jim Byrnes wrote: > OOP has always driven me crazy. I read the material and follow the > examples until I feel I understand them, but when I try to implement it > I end up with an error filled mess. > > So I decided to give it another try. When I got to the chapter on > tkinter I decided to sol

Re: [Tutor] OOP help needed

2016-07-26 Thread Ben Finney
Jim Byrnes writes: > So I decided to give it another try. When I got to the chapter on > tkinter I decided to solve all the exercises using OOP even though the > book solutions did not use OOP. Hmm, that sounds ill advised. OOP is one tool among many; trying to apply it where it's a poor fit wi

[Tutor] OOP help needed

2016-07-26 Thread Jim Byrnes
OOP has always driven me crazy. I read the material and follow the examples until I feel I understand them, but when I try to implement it I end up with an error filled mess. So I decided to give it another try. When I got to the chapter on tkinter I decided to solve all the exercises using

Re: [Tutor] OOP question

2011-01-19 Thread Nick Stinemates
If you want to test if one outcome is equal to another, you probably want to know if The name of the outcome is the same The odds of the outcome is the same So, you'd implement it like so class Outcome: def __eq__(self, other): if self.name == other.name and self.odds == other.odds:

Re: [Tutor] OOP question

2011-01-18 Thread Steven D'Aprano
Ben Ganzfried wrote: Hey guys, I'm trying to get a version of Roulette working and I had a quick question. There's a quick answer and long answer. The quick answer is, you have to refer to self.odds, not just odds. The long answer is below: Here is my code: [...] Now whenever I try to ca

Re: [Tutor] OOP question

2011-01-18 Thread Nick Stinemates
Updated inline. Check the updated definiton of winAmount. Nick On Tue, Jan 18, 2011 at 9:25 AM, Ben Ganzfried wrote: > Hey guys, > > I'm trying to get a version of Roulette working and I had a quick > question. Here is my code: > > class Outcome: > > def __init__(self, name, odds): >

[Tutor] OOP question

2011-01-18 Thread Ben Ganzfried
Hey guys, I'm trying to get a version of Roulette working and I had a quick question. Here is my code: class Outcome: def __init__(self, name, odds): self.name = name self.odds = odds def winAmount(self, amount): return odds*amount def __eq__(self, other):

Re: [Tutor] OOP clarification needed

2010-06-03 Thread Lie Ryan
On 06/03/10 01:37, Jim Byrnes wrote: > >>> some older procedural languages I always end up becoming confused by >>> the large number of built in methods. >> >> C is one of the simplest procedural languages around >> and yet it comes with a huge library of functions (several >> hundred in some case

Re: [Tutor] OOP clarification needed

2010-06-02 Thread Jim Byrnes
Steven D'Aprano wrote: Case in point is this code snippet from a chapter on Tkinter. def viewer(imgdir, kind=Toplevel, cols=None): """ make thumb links window for an image directory: one thumb button per image; use kind=Tk to show in main app window, or Frame container

Re: [Tutor] OOP clarification needed

2010-06-02 Thread Jim Byrnes
Alan Gauld wrote: "Jim Byrnes" wrote Whenever I teach myself a new language I have great difficulty understanding the nuts and bolts of it's OO implementation. Do you understand the OO concepts OK? Is it only the language semantics you struggle with or the underlying OO concepts? I believe

Re: [Tutor] OOP clarification needed

2010-06-02 Thread Jim Byrnes
Steve Willoughby wrote: On Tue, Jun 01, 2010 at 03:19:17PM -0500, Jim Byrnes wrote: def viewer(imgdir, kind=Toplevel, cols=None): win = kind() What is the relationship between kind=Toplevel in the first line and win=kind() further down. Isn't "kind" a variable and "kind()" a method? kin

Re: [Tutor] OOP clarification needed

2010-06-01 Thread Steven D'Aprano
On Wed, 2 Jun 2010 06:19:17 am Jim Byrnes wrote: > Whenever I teach myself a new language I have great difficulty > understanding the nuts and bolts of it's OO implementation. Compared > to some older procedural languages I always end up becoming confused > by the large number of built in methods.

Re: [Tutor] OOP clarification needed

2010-06-01 Thread Alan Gauld
"Jim Byrnes" wrote Whenever I teach myself a new language I have great difficulty understanding the nuts and bolts of it's OO implementation. Do you understand the OO concepts OK? Is it only the language semantics you struggle with or the underlying OO concepts? some older procedural languag

Re: [Tutor] OOP clarification needed

2010-06-01 Thread Steve Willoughby
On Tue, Jun 01, 2010 at 03:19:17PM -0500, Jim Byrnes wrote: > def viewer(imgdir, kind=Toplevel, cols=None): > win = kind() > > What is the relationship between kind=Toplevel in the first line and > win=kind() further down. Isn't "kind" a variable and "kind()" a method? kind is a variable.

[Tutor] OOP clarification needed

2010-06-01 Thread Jim Byrnes
Whenever I teach myself a new language I have great difficulty understanding the nuts and bolts of it's OO implementation. Compared to some older procedural languages I always end up becoming confused by the large number of built in methods. When reading through code examples I many times get

Re: [Tutor] OOP

2009-04-15 Thread Kent Johnson
On Wed, Apr 15, 2009 at 3:43 AM, mbikinyi brat wrote: > Dear ALL, > I am a python beginner and has never programmed and has been struggling to > understand how to create objects or classes in python. Can anyone help with > any concrete example. I have read most recommended textbooks but still have

Re: [Tutor] OOP

2009-04-15 Thread Alan Gauld
"mbikinyi brat" wrote I am a python beginner and has never programmed Welcome to the tutor list. and has been struggling to understand how to create objects or classes in python. Can anyone help with any concrete example. Most tutorials have examples of classes and objects. Certainly

[Tutor] OOP

2009-04-15 Thread mbikinyi brat
Dear ALL, I am a python beginner and has never programmed and has been struggling to understand how to create objects or classes in python. Can anyone help with any concrete example. I have read most recommended textbooks but still have difficulties figuring what it is all about.   Thanks, Henry

Re: [Tutor] OOP / Classes questions

2009-04-10 Thread Alan Gauld
"Stefan Lesicnik" wrote I am a relative newbie to python and OOP concepts and am trying to work through wxpython. I've seen understanding classes is essential to this and have been trying to work through them. Steve gave you the basic explanation, I'll try a slightly different tack - which ma

Re: [Tutor] OOP / Classes questions

2009-04-10 Thread Alan Gauld
"Skipper Seabold" wrote tutorial or documentation re OOP and classes? I've found Alan Gauld's tutorials to be very useful when just getting started in both OOP and Python. http://www.freenetpages.co.uk/hp/alan.gauld/ Thanks for the plug :-) However the URL has changed since freenetpages

Re: [Tutor] OOP / Classes questions

2009-04-10 Thread Steve Willoughby
On Fri, Apr 10, 2009 at 08:44:37PM +0200, Stefan Lesicnik wrote: > I am a relative newbie to python and OOP concepts and am trying to > work through wxpython. I've seen understanding classes is essential to > this and have been trying to work through them. Welcome! If you're really new, wxpython

Re: [Tutor] OOP / Classes questions

2009-04-10 Thread Skipper Seabold
On Fri, Apr 10, 2009 at 2:44 PM, Stefan Lesicnik wrote: > I guess as a general kind of question, can anyone recommend some > tutorial or documentation re OOP and classes? I've found Alan Gauld's tutorials to be very useful when just getting started in both OOP and Python. http://www.freenetpages

[Tutor] OOP / Classes questions

2009-04-10 Thread Stefan Lesicnik
Hi guys, I am a relative newbie to python and OOP concepts and am trying to work through wxpython. I've seen understanding classes is essential to this and have been trying to work through them. I have a few questions re the below code (i suspect its due to a lack of my understanding of classes)

Re: [Tutor] OOP - have I done it right or could it be better?

2007-01-24 Thread Kent Johnson
Original Brownster wrote: > --- Kent Johnson <[EMAIL PROTECTED]> wrote: >> This all sounds good. You have a module, Streamrip, that implements >> the >> core functionality you need. From your description, this module >> doesn't >> know about the GUI so it could be reused by another kind of client

Re: [Tutor] OOP - have I done it right or could it be better?

2007-01-24 Thread Original Brownster
--- Kent Johnson <[EMAIL PROTECTED]> wrote: > Original Brownster wrote: > > Hi, > > I'm fairly new to using OOP and very new to Python, my first > program is > > coming along well and I have split the code into 2 modules. > > > > The program finds stream urls, downloads them, re-encodes them to

Re: [Tutor] OOP - have I done it right or could it be better?

2007-01-23 Thread Alan Gauld
"Original Brownster" <[EMAIL PROTECTED]> wrote > The program finds stream urls, downloads them, re-encodes them to > othe > formats, all this functionality I have created in one module with > one > class called Streamrip and methods to handle this. Good so far. One nitpick is that class names

Re: [Tutor] OOP - have I done it right or could it be better?

2007-01-23 Thread Kent Johnson
Original Brownster wrote: > Hi, > I'm fairly new to using OOP and very new to Python, my first program is > coming along well and I have split the code into 2 modules. > > The program finds stream urls, downloads them, re-encodes them to othe > formats, all this functionality I have created in one

[Tutor] OOP - have I done it right or could it be better?

2007-01-23 Thread Original Brownster
Hi, I'm fairly new to using OOP and very new to Python, my first program is coming along well and I have split the code into 2 modules. The program finds stream urls, downloads them, re-encodes them to othe formats, all this functionality I have created in one module with one class called Streamri

Re: [Tutor] OOP and Python.. a gentle remark

2006-10-25 Thread wesley chun
on a related topic, if you're concerned about security, esp. of your instance attributes, new-style classes offer you significantly more control over them using descriptors (including properties [and to a lesser extent, slots]). there is plenty of docs available on those, so i'll defer describing t

Re: [Tutor] OOP and Python.. a gentle remark

2006-10-25 Thread Asrarahmed Kadri
Chris, you are right. He (Alan) hits the bull's eye, always !!   Cheers...   Asrarahmed  On 10/25/06, Chris Hengge <[EMAIL PROTECTED]> wrote: I dont know about the rest of you, but this thread posting from Alan cleared up some fuzzyness I've had about classes. /me is happier using this. instead of

Re: [Tutor] OOP and Python.. a gentle remark

2006-10-25 Thread Asrarahmed Kadri
  Thanks a lot for explanation.   Regards, Asrarahmed  On 10/25/06, Alan Gauld <[EMAIL PROTECTED]> wrote: "Asrarahmed Kadri" <[EMAIL PROTECTED]> wrote > Why is it necessary to explicity use self argument in the class> functionsBecause Guido made it that way. :-)But he did it for good reasons which

Re: [Tutor] OOP and Python.. a gentle remark

2006-10-25 Thread Chris Hengge
I dont know about the rest of you, but this thread posting from Alan cleared up some fuzzyness I've had about classes. /me is happier using this. instead of self. =DGreat post! On 10/25/06, Alan Gauld <[EMAIL PROTECTED]> wrote: "Asrarahmed Kadri" <[EMAIL PROTECTED]> wrote> Why is it necessary to ex

Re: [Tutor] OOP and Python.. a gentle remark

2006-10-25 Thread Alan Gauld
"Asrarahmed Kadri" <[EMAIL PROTECTED]> wrote > Why is it necessary to explicity use self argument in the class > functions Because Guido made it that way. :-) But he did it for good reasons which others have pointed out already. Although languages like C++ and Java use implicit object reference

Re: [Tutor] OOP and Python.. a gentle remark

2006-10-25 Thread Andrei
Asrarahmed Kadri googlemail.com> writes: > the use of 'self' keyword really confuses me. I see how it can annoy you, but not how it can *confuse* you - if anything, "self" removes any confusion about whether you're looking at a local variable or an object property. By the way, the use of specia

Re: [Tutor] OOP and Python.. a gentle remark

2006-10-25 Thread euoar
Asrarahmed Kadri escribió: > > > Folks... > > Please dont take it in a wrong sense. But I have a point to make > regarding OOP and the way it is implemented in Python. > > Why is it necessary to explicity use self argument in the class > functions ?? I feel the language/interpreter shoul

Re: [Tutor] OOP and Python.. a gentle remark

2006-10-25 Thread Simon Brunning
On 10/25/06, Asrarahmed Kadri <[EMAIL PROTECTED]> wrote: > Why is it necessary to explicity use self argument in the class functions > ?? I feel the language/interpreter should figure out which object has called > the function? Isnt it ? (the use of 'self' keyword really confuses me. and > to make

[Tutor] OOP and Python.. a gentle remark

2006-10-25 Thread Asrarahmed Kadri
    Folks...   Please dont take it in a wrong sense. But I have a point to make regarding OOP and the way it is implemented in Python.    Why is it necessary to explicity use self argument in the class functions ?? I feel the language/interpreter should figure out which object has called the functi

Re: [Tutor] OOP fundamentals

2005-09-20 Thread Ed Hotchkiss
s sincerely,__János Juhász> Message: 5> Date: Mon, 19 Sep 2005 17:01:30 -0400 > From: Ed Hotchkiss <[EMAIL PROTECTED]>> Subject: Re: [Tutor] OOP fundamentals> To: Danny Yoo <[EMAIL PROTECTED] >> Cc: Tutor <tutor@python.org>> Message-ID: <[EMAIL PROTEC

Re: [Tutor] OOP fundamentals

2005-09-19 Thread János Juhász
From: Ed Hotchkiss <[EMAIL PROTECTED]> > Subject: Re: [Tutor] OOP fundamentals > To: Danny Yoo <[EMAIL PROTECTED]> > Cc: Tutor > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset="iso-8859-1" > Thanks Danny! Tommorrow I am off t

Re: [Tutor] OOP fundamentals

2005-09-19 Thread Ed Hotchkiss
Excellent, I'll be getting that book tomorrow! Thanks again, I'm doing a tutorial as we speak!   On 9/19/05, Danny Yoo <[EMAIL PROTECTED]> wrote: On Mon, 19 Sep 2005, Ed Hotchkiss wrote:> Thanks Danny! Tommorrow I am off to get "Programming for Python, 2nd > edition" and learn everything - all of i

Re: [Tutor] OOP fundamentals

2005-09-19 Thread Danny Yoo
On Mon, 19 Sep 2005, Ed Hotchkiss wrote: > Thanks Danny! Tommorrow I am off to get "Programming for Python, 2nd > edition" and learn everything - all of it, before I even bother with > Sockets. Hi Ed, I'd disrecommend Programming Python if you're a beginner. Programming Python is really more

Re: [Tutor] OOP fundamentals

2005-09-19 Thread Ed Hotchkiss
Thanks Danny! Tommorrow I am off to get "Programming for Python, 2nd edition" and learn everything - all of it, before I even bother with Sockets. Afterall, I want python for EVERYTHING not just sockets and inet based scripts/applications.   I realized that I need to take a step back, make port s

[Tutor] OOP fundamentals

2005-09-19 Thread Danny Yoo
On Mon, 19 Sep 2005, Ed Hotchkiss wrote: > Thanks for the link! It is EXACTLY what I have been looking for. When I > used to use Flash a bit, and did some actionscript they had a similiar > setup for OOP (Do all languages use OOP so similiarly?) which I never > learned. Hi Ed, I believe that