Re: oop issue

2022-05-23 Thread Avi Gross via Python-list
invest_crypto.client_list.append(self) I am wondering about the phrasing above. When you are in the dunder init function, you normally create and change items in YOURSELF so why is your code not changing self.crypto_client_list? And what are you appending to before ever creating it? Would it k

Re: oop issue

2022-05-23 Thread Peter Otten
On 23/05/2022 22:54, Tola Oj wrote: i just finished learning oop as a beginner and trying to practice with it but i ran into this typeerror issue, help please. Traceback (most recent call last): File "c:\Users\ojomo\OneDrive\Desktop\myexcel\oop_learn.py\myExperiment.py\mainMain.py", line 36,

Re: oop issue

2022-05-23 Thread MRAB
On 2022-05-23 20:36, Tola Oj wrote: i am trying to print this code but it keeps giving me this typeerror, please help. the csv file format i am trying to change into a list is in a different module. class invest_crypto: crypto_current_rate = 0.05 client_list = [] def __init__(self

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-07 Thread Gregory Ewing
Oscar Benjamin wrote: In Python the original exception message plus traceback is often very informative (to a programmer!) about the problem. That's okay, exception chaining preserves the whole traceback if you want to dig down that far. Catching and reraising can mean that you end up craftin

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-06 Thread Oscar Benjamin
On Tue, 5 Nov 2019 at 21:52, Gregory Ewing wrote: > > Peter J. Holzer wrote: > > On 2019-11-04 18:18:39 -0300, Luciano Ramalho wrote: > > > > Or maybe don't catch it here at all but just let it bubble up until it > > hits a level where dealing with it makes sense from the user's point of > > view

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-05 Thread Gregory Ewing
Peter J. Holzer wrote: On 2019-11-04 18:18:39 -0300, Luciano Ramalho wrote: In addition, as Rob said, it is usually a bad idea to wrap several lines of code in a single try/except block I disagree with this. While it is sometimes useful to wrap a single line, in my experience it rarely is. T

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-05 Thread Rob Gaddi
On 11/5/19 11:52 AM, Peter J. Holzer wrote: On 2019-11-04 18:18:39 -0300, Luciano Ramalho wrote: In addition, as Rob said, it is usually a bad idea to wrap several lines of code in a single try/except block I disagree with this. While it is sometimes useful to wrap a single line, in my experie

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-05 Thread Peter J. Holzer
On 2019-11-04 18:18:39 -0300, Luciano Ramalho wrote: > In addition, as Rob said, it is usually a bad idea to wrap several > lines of code in a single try/except block I disagree with this. While it is sometimes useful to wrap a single line, in my experience it rarely is. The scope of the try ... e

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-05 Thread Chris Angelico
On Tue, Nov 5, 2019 at 8:46 PM R.Wieser wrote: > > Chris, > > > "Control flow" is anything that changes the order that your code runs. > > My apologies, I should have said "a control flow mechanism" /in this > context/ (though I assumed that as implicite, as I quoted the text from the > OP). > > C

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-05 Thread R.Wieser
Chris, > "Control flow" is anything that changes the order that your code runs. My apologies, I should have said "a control flow mechanism" /in this context/ (though I assumed that as implicite, as I quoted the text from the OP). Case in point, the __init__ code (of a class object) can result

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-04 Thread Chris Angelico
On Tue, Nov 5, 2019 at 6:26 PM R.Wieser wrote: > > It is considered totally OK to use exception handling as a control > > flow mechanism in Python. > > I'm not sure what exactly you mean with "a control flow mechanism", but as > several methods throw exceptions themselves I will have no choice in

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-04 Thread R.Wieser
Luciano, > In this context, what I mean by that quote is to say that Python > never forces you to wrap anything in try/except blocks. True. But /not/ doing it means that the casted exeption in the __init__ block will just abort the whole program - in a user unfriendly way. And thats normally

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-04 Thread Luciano Ramalho
On Mon, Nov 4, 2019 at 5:52 PM R.Wieser wrote: > I was thinking of (the needed) wrapping of the "newObject = classObject()" > line in such a try..except block (to capture the re-casted exception). I > take it that that that means that the full contents of the __init__ block > are wrapped too. P

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-04 Thread R.Wieser
Rob, > That's why if you for instance, open a serial port in an __init__ routine, > and something fails, you want to catch the exception there in __init__, > explicitly close that serial port, and reraise the exception. Otherwise > that port still has an object open against it until Python gets

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-04 Thread Rob Gaddi
On 11/4/19 10:59 AM, R.Wieser wrote: Rob, Returning None will specifically NOT accomplish the thing you want; nothing ever checks the return value of __init__. I thought to have read that when you return a none from it the object itself would return a placeholder singleton. Raise an excepti

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-04 Thread R.Wieser
Luciano, > """A failed __init__ should raise an appropriate exception. A bare > return or returning None is what any __init__ is expected to do in the > normal case, so it signals success.""" Ah, that settles it than. Somehow I thought that a return (of "none") there indicated an error result,

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-04 Thread R.Wieser
Rob, > Returning None will specifically NOT accomplish the thing you want; > nothing ever checks the return value of __init__. I thought to have read that when you return a none from it the object itself would return a placeholder singleton. > Raise an exception. Yeah, that was what I was thi

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-04 Thread Rob Gaddi
On 11/4/19 10:36 AM, Luciano Ramalho wrote: Sorry, I responded only to the OP. My response: """A failed __init__ should raise an appropriate exception. A bare return or returning None is what any __init__ is expected to do in the normal case, so it signals success.""" Actually, the Python inter

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-04 Thread Luciano Ramalho
Sorry, I responded only to the OP. My response: """A failed __init__ should raise an appropriate exception. A bare return or returning None is what any __init__ is expected to do in the normal case, so it signals success.""" Actually, the Python interpreter *does* check the return of __init__. If

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-04 Thread Rob Gaddi
On 11/4/19 7:32 AM, R.Wieser wrote: Hello all, The whole question: How should I handle failed initialisation code inside the __init__ of an object ? I've seen an example doing a plain "return" (of the value "none""), but have no idea if that is all it takes. Also, I wonder what happens to the

Re: OOP - iterable class: how to delete one of its objects ?

2019-11-04 Thread R.Wieser
Rhodri, > Yes, it can. That's why you want to create a finalizer to tidy up. AFAIKS in my case there is nothing to cleanup. As far as I understood the WeakSet will automagically purge the reference whe the object it references is destroyed. I could also try to do it in in the __del__ method

Re: OOP - iterable class: how to delete one of its objects ?

2019-11-04 Thread Rhodri James
On 02/11/2019 06:30, R.Wieser wrote: Rhodri, Use weak references. A WeakSet (https://docs.python.org/3/library/weakref.html#weakref.WeakSet) is probably what you want. Most likely!As a fresh freshling in regard to python I was not even aware that a "copy object, but do not increment the

Re: OOP - iterable class: how to delete one of its objects ?

2019-11-01 Thread R.Wieser
Rhodri, > Use weak references. A WeakSet > (https://docs.python.org/3/library/weakref.html#weakref.WeakSet) is > probably what you want. Most likely!As a fresh freshling in regard to python I was not even aware that a "copy object, but do not increment the reference count" existed.Th

Re: OOP - iterable class: how to delete one of its objects ?

2019-11-01 Thread R.Wieser
Dennis, > In __init__() you are adding "self" to a classwide list. So in > your __del__() you need to remove the instance from the > same list. Something :-) Thats the problem: __del__ only gets called when the object is destroyed - which will never happen when the "instances" list still contain

Re: OOP - iterable class: how to delete one of its objects ?

2019-11-01 Thread R.Wieser
Chris, > Have a method to explicitly purge the instance. I was thinking of that too but decided against it, as it would mean that my objects would need to be handled specially - which is not quite what I'm looking for. To be honest, I was thinking of/hoping that there would be a method which

Re: OOP - iterable class: how to delete one of its objects ?

2019-11-01 Thread Chris Angelico
On Sat, Nov 2, 2019 at 6:21 AM R.Wieser wrote: > > Hello all, > > I've created a class from which I can iterate all its instanciated objects > (using an "instances" list).The problem is that I now cannot seem to > delete an object anymore, AFAIK as a copy of its "self" is still inside the > "i

Re: OOP - iterable class: how to delete one of its objects ?

2019-11-01 Thread Rhodri James
On 01/11/2019 19:15, R.Wieser wrote: Hello all, I've created a class from which I can iterate all its instanciated objects (using an "instances" list).The problem is that I now cannot seem to delete an object anymore, AFAIK as a copy of its "self" is still inside the "instances" list. Objec

Re: OOP for System Administrator

2015-04-06 Thread pankaj sharma
Yes Michael, your guess is right. I once was a Java Programmer :) Thanks for the advice and link. Regards, -- https://mail.python.org/mailman/listinfo/python-list

Re: OOP for System Administrator

2015-04-04 Thread Emile van Sebille
On 4/4/2015 8:56 AM, pankaj sharma wrote: Hi, I'm a Linux system administrator and my work requires me to write bash scripts (100-500 lines) for process monitoring, server health check and automate some manual processes. Now I've started to learn python as I want to write scripts in python ra

Re: OOP for System Administrator

2015-04-04 Thread Michael Torrie
On 04/04/2015 09:56 AM, pankaj sharma wrote: > I'm a Linux system administrator and my work requires me to write > bash scripts (100-500 lines) for process monitoring, server health > check and automate some manual processes. Now I've started to learn > python as I want to write scripts in python r

Re: OOP with MyTime

2014-07-03 Thread Mark Lawrence
On 03/07/2014 16:21, kjaku...@gmail.com wrote: On Thursday, July 3, 2014 9:11:49 AM UTC-4, MRAB wrote: I'm pleased to see that you have answers. In return would you please use the mailing list https://mail.python.org/mailman/listinfo/python-list or read and action this https://wiki.python.o

Re: OOP with MyTime

2014-07-03 Thread Chris Angelico
On Fri, Jul 4, 2014 at 1:21 AM, wrote: > I keep getting an invalid syntax on the t1 = (9, 59, 59) line, not sure why? > > t1 = (9, 59, 59) Two points. Firstly, as I said before, posting the entire exception helps us enormously. Secondly, with most computerized parsers, the file is processed top-

Re: OOP with MyTime

2014-07-03 Thread kjakupak
On Thursday, July 3, 2014 9:11:49 AM UTC-4, MRAB wrote: > On 2014-07-03 13:51, kjaku...@gmail.com wrote: > > > On Wednesday, July 2, 2014 4:02:00 PM UTC-4, MRAB wrote: > > >> > > > >> > > >> If you want 'between' to be an instance method of the MyTime class, it > > >> > > >> needs 'self' as w

Re: OOP with MyTime

2014-07-03 Thread Chris Angelico
On Thu, Jul 3, 2014 at 11:08 PM, wrote: > Altered the code. But yes a nameerror came up When that sort of thing happens, you have three basic approaches to solving the problem. 1) Read the traceback, look at the line of code it points to, and see if you can figure out what it means. 2) Post her

Re: OOP with MyTime

2014-07-03 Thread MRAB
On 2014-07-03 13:51, kjaku...@gmail.com wrote: On Wednesday, July 2, 2014 4:02:00 PM UTC-4, MRAB wrote: > If you want 'between' to be an instance method of the MyTime class, it needs 'self' as well as the 2 arguments 't1' and 't2'. You can then compare the hours, minutes and seconds of self

Re: OOP with MyTime

2014-07-03 Thread kjakupak
On Thursday, July 3, 2014 9:01:09 AM UTC-4, Chris Angelico wrote: > > > > And what happens when you run this code? A NameError, I would expect. > > Do you understand how to define and call methods? > > > > ChrisA Altered the code. But yes a nameerror came up class MyTime: def __init__

Re: OOP with MyTime

2014-07-03 Thread Chris Angelico
On Thu, Jul 3, 2014 at 10:51 PM, wrote: > So I've now gotten this: > class MyTime: > def between(self, t1, t2): > return (t1.hours, t1.minutes, t1.seconds) <= (self.hours, > self.minutes, self.seconds) and (self.hours, self.minutes, self.seconds) <= > (t2.hours, t2.minutes, t2.secon

Re: OOP with MyTime

2014-07-03 Thread kjakupak
On Wednesday, July 2, 2014 4:02:00 PM UTC-4, MRAB wrote: > > > > If you want 'between' to be an instance method of the MyTime class, it > > needs 'self' as well as the 2 arguments 't1' and 't2'. > > > > You can then compare the hours, minutes and seconds of self against > > those of t1 and t2

Re: OOP with MyTime

2014-07-02 Thread MRAB
On 2014-07-02 20:20, kjaku...@gmail.com wrote: I'm trying to write a boolean function that takes two Mytime objects, t1 and t2 as arguments, and returns True if the object falls inbetween the two times. This is a question from the How to Think Like a Computer Scientist book, and I need help.

Re: OOP with MyTime

2014-07-02 Thread Akira Li
kjaku...@gmail.com writes: > I'm trying to write a boolean function that takes two Mytime objects, t1 and > t2 as arguments, and returns True if the object falls inbetween the two times. > > This is a question from the How to Think Like a Computer Scientist book, and > I need help. > > What I've

Re: OOP no Python

2014-06-26 Thread Guilherme Rezende
Samuel, http://groups.google.com/group/python-brasil On Thu, Jun 26, 2014 at 12:18 PM, Chris Angelico wrote: > 2014-06-27 0:16 GMT+10:00 Samuel David : > > Mas estou com uma dúvida referente ao tópico “Por que eu deveria usar > Python > > e não ?”. > > Google Translate tells me you're asking "

Re: OOP no Python

2014-06-26 Thread Chris Angelico
2014-06-27 0:16 GMT+10:00 Samuel David : > Mas estou com uma dúvida referente ao tópico “Por que eu deveria usar Python > e não ?”. Google Translate tells me you're asking "Why use Python instead of ?". (I'm going to respond only in English, as my Portuguese is basically nil. Sorry.) Well, there a

Re: OOP no Python

2014-06-26 Thread Mark Lawrence
On 26/06/2014 15:16, Samuel David wrote: Olá, python.pt https://www.facebook.com/python.pt IRC freenode #python-pt channel I think :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruse

Re: OOP no Python

2014-06-26 Thread Stéphane Wirtel
In English, Sorry On 26 Jun 2014, at 16:16, Samuel David wrote: Olá, Estou analisando algumas necessidades de nossa empresa e fiquei bastante interessado em resolve-las utilizando Python, lendo o FAQ do site de vcs percebo que está é uma linguagem bastante completa. Mas estou com uma dúv

Re: OOP noob question: Mixin properties

2012-12-14 Thread Micky Hulse
Hi Steven!!! Thanks so much for the pro help, I really do appreciate it. :) On Thu, Dec 13, 2012 at 4:53 PM, Steven D'Aprano wrote: > Indentation is important. Please don't remove it. I've added it back in > below: Yikes! Sorry about that. I won't do that again in the future. :( Thanks for addi

Re: OOP noob question: Mixin properties

2012-12-13 Thread Steven D'Aprano
On Thu, 13 Dec 2012 16:20:51 -0800, Micky Hulse wrote: > Learning things here... > > In my mixin class (a version I wrote for Django) I had this (indentation > removed for better list readability): Indentation is important. Please don't remove it. I've added it back in below: > class JSONRespo

Re: OOP noob question: Mixin properties

2012-12-13 Thread Micky Hulse
On Wed, Dec 12, 2012 at 7:49 PM, Micky Hulse wrote: > I hope you don't mind that this question involves Django... I'm just > looking to improve my core Python skills (so, generic Python examples > would be cool). Just experimenting: I think that will help me ac

Re: OOP only in modules

2011-04-12 Thread Andrea Crotti
newpyth writes: > Hi Andrea, > excuse my beeing criptic (you wrote: "I have some troubles > understanding what you mean") but I coudn't to go on too long. > Now I can conclude my speech... > When I was younger I transformed a big Clipper program in > simil-C in order to apply cflow... and I succe

Re: OOP only in modules

2011-04-12 Thread Adam Tauno Williams
On Tue, 2011-04-12 at 08:33 -0700, newpyth wrote: > """ call tree w/o classes and objects: > E() #~15 called from #~35 > +-- F() #~1816 > |+-- raw_input('Addressed to ') # called from 19 > +-- G()

Re: OOP only in modules

2011-04-12 Thread newpyth
Hi Andrea, excuse my beeing criptic (you wrote: "I have some troubles understanding what you mean") but I coudn't to go on too long. Now I can conclude my speech... When I was younger I transformed a big Clipper program in simil-C in order to apply cflow... and I succeeded... but Clipper wasn't OO!

Re: OOP only in modules

2011-04-10 Thread Andrea Crotti
newpyth writes: [...] > My main goal is to arrange OO in a paradigmatic manner in order to > apply to it the > procedural scheme. especially to the caller or called modules. > Bye. I have some troubles understanding what you mean. Can you write an example of code that it's for you annoying and

Re: OOP only in modules

2011-04-10 Thread newpyth
Hi all, I must thank before Andrea Crotti and Steven D'Aprano, which kindly replayed to my post... they deserve an answer. To Andrea Crotti's "OOP makes life easier also to the user"... that is NOT my experience... I'm not pretending that everyone else thinks like me (also if many people do... load

Re: OOP only in modules

2011-04-10 Thread Steven D'Aprano
On Sun, 10 Apr 2011 03:35:48 -0700, newpyth wrote: > Hi all, > from the subject of my post, you can see I do not like very much OOP... > and I am not the only one... Knowing that python is intrinsecally OO, I > propose to move all OOP stuff (classes, instances and so on) to modules. Python is bas

Re: OOP only in modules

2011-04-10 Thread Andrea Crotti
newpyth writes: > Hi all, > from the subject of my post, you can see I do not > like very much OOP... and I am not the only one... > Knowing that python is intrinsecally OO, I propose > to move all OOP stuff (classes, instances and so on) > to modules. > In this way the OOP fan can keep on using

Re: OOP & Abstract Classes

2009-05-11 Thread alex23
On May 12, 1:22 am, Mike Driscoll wrote: > I've never used (or heard of) the Abstract type...and the guy who > wrote the FAQ was being a jerk. It looks like he was just throwing in > an undefined variable name just to make his Python program break while > taking a pot shot at people who use that s

Re: OOP & Abstract Classes

2009-05-11 Thread Terry Reedy
Adam Gaskins wrote: Wow, thanks Nick! This is just what I was looking for! I agree that Nick's semi-abstract class is what you need. After doing some subclasses, you may discover that there is more common code that you can factor out and push to the base class. You may also find it convenien

Re: OOP & Abstract Classes

2009-05-11 Thread Adam Gaskins
Wow, thanks Nick! This is just what I was looking for! Thanks to Peter as well. And as for your suggestion that I probably shouldn't mess with things I don't understand and learn the basics first... well, that is probably sound advice, but I figured out years ago that I learn things best by a)

Re: OOP & Abstract Classes

2009-05-11 Thread Peter Otten
Adam Gaskins wrote: > So I was beginning to learn OOP for PHP, and it seemed to me that abstract > classes were just right for my application. In my application I must > communicate with several peices of test equipment that communicate via > RS-232. Most use SCPI instructions, some do not and req

Re: OOP & Abstract Classes

2009-05-11 Thread Nick Craig-Wood
Adam Gaskins wrote: > I am a fairly seasoned PHP developer (don't shoot, I'm changing teams!:) who > is admittedly behind the curve with OOP. Like most who learned PHP, I > started doing web app backend stuff, but I have moved to full blown windows > apps in the last 6 months using Winbinde

Re: OOP & Abstract Classes

2009-05-11 Thread Adam Gaskins
Any idea why I didn't see this reply on my ng? I only see the reply from Marco. Can't help but wonder if there is more that is not getting through here. Would someone mind forwarding me any other replies? FWIW I'm using news.east.cox.net. Thanks, -Adam > Mike Driscoll wrote: > >> I've never u

Re: OOP & Abstract Classes

2009-05-11 Thread Marco Mariani
Mike Driscoll wrote: I've never used (or heard of) the Abstract type...and the guy who wrote the FAQ was being a jerk. Who, Peter Norvig? (from wikipedia) Peter Norvig is an American computer scientist. He is currently the Director of Research (formerly Director of Search Quality) at Google

Re: OOP & Abstract Classes

2009-05-11 Thread Ulrich Eckhardt
Adam Gaskins wrote: > Long story short, I'm tired of doing things in such a hackish manner > and want to write applications that are cross platform (I'd like to > get our production dept on linux eventually) and truely object > oriented. Adam, there is one notion here that I seriously dislike: yo

Re: OOP & Abstract Classes

2009-05-11 Thread Mike Driscoll
On May 11, 9:53 am, "Adam Gaskins" wrote: > Hi all, > > -- Non critical info-- > I am a fairly seasoned PHP developer (don't shoot, I'm changing teams!:) who > is admittedly behind the curve with OOP. Like most who learned PHP, I > started doing web app backend stuff, but I have moved to full blow

Re: OOP books?

2008-10-16 Thread Bruno Desthuilliers
Asun Friere a écrit : On Oct 16, 7:12 am, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: [snip] Not a word about Python in it, but:http://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-... A must-read if you want to understand OO (MHO of course). Yes, if only to see how many

Re: OOP books?

2008-10-15 Thread Asun Friere
On Oct 16, 7:12 am, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: [snip] > Not a word about Python in it, > but:http://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-... > > A must-read if you want to understand OO (MHO of course). Yes, if only to see how many of the design patt

Re: OOP books?

2008-10-15 Thread Bruno Desthuilliers
Ken D'Ambrosio a écrit : Hi, all. Over the years, I've programmed in a fair number of languages; the ones with which I became most familiar were assembler, BASIC, Pascal, and "lately" (the last fifteen years or so) Perl. Now I'm trying my hand at Python. While I don't have any problems with

Re: OOP books?

2008-10-15 Thread Alan G Isaac
On 10/15/2008 4:07 PM Mike Driscoll apparently wrote: Wow! That's a pricey book! Have you read it? Is it good? Per page the price is right: it runs nearly 1300 pages! I have not read it, but I have read a chunk of his previous http://www.amazon.com/Programming-Objects-Comparative-Presentation-O

Re: OOP books?

2008-10-15 Thread Mike Driscoll
On Oct 15, 1:57 pm, Alan G Isaac <[EMAIL PROTECTED]> wrote: > Mike Driscoll wrote: > > I have yet to read a Python book that only focuses on the OOP part, > > http://www.amazon.com/Scripting-Objects-Comparative-Presentation-Obje... > > fwiw, > Alan Isaac Wow! That's a pricey book! Have you read it

Re: OOP books?

2008-10-15 Thread Rob Wolfe
Ken D'Ambrosio <[EMAIL PROTECTED]> writes: > Is there an intro-to-Python book where the emphasis isn't so > much on the language, but on OOP, itself? Or, failing that, at least > a Python book which doesn't just introduce the language, but gives > equal billing to OOP practices, etc. Take a look

Re: OOP books?

2008-10-15 Thread Alan G Isaac
Mike Driscoll wrote: I have yet to read a Python book that only focuses on the OOP part, http://www.amazon.com/Scripting-Objects-Comparative-Presentation-Object-Oriented/dp/047039725X fwiw, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: OOP books?

2008-10-15 Thread Mike Driscoll
On Oct 15, 1:02 pm, Ken D'Ambrosio <[EMAIL PROTECTED]> wrote: > Hi, all.  Over the years, I've programmed in a fair number of languages; > the ones with which I became most familiar were assembler, BASIC, > Pascal, and "lately" (the last fifteen years or so) Perl.  Now I'm > trying my hand at Pytho

Re: OOP: How to implement listing al 'Employees'.

2007-12-31 Thread Mike Orr
On Dec 29, 1:53 am, Petar <[EMAIL PROTECTED]> wrote: > Let me explain how I got to this question. I had written een Article > class which handled the articles that I had. On a certain page I > wanted to show all the articles. That got me wondering about what to > do. Should I make a method in my A

Re: OOP: How to implement listing al 'Employees'.

2007-12-29 Thread Marc 'BlackJack' Rintsch
On Sat, 29 Dec 2007 01:53:38 -0800, Petar wrote: > The post of Dennis made me realize of another solution though. To > create another class called Articles which return multiple articles. > The only problem I forsee with this that's it's gonna be a very empty > class. Then maybe it should not be

Re: OOP: How to implement listing al 'Employees'.

2007-12-29 Thread Petar
On 28 dec, 19:42, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Fri, 28 Dec 2007 04:05:59 -0800 (PST), Petar <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > I was just wondering. > > > What if you have a 'Employees' class and you want to list all the > > employees. Curr

Re: OOP: How to implement listing al 'Employees'.

2007-12-28 Thread Bruno Desthuilliers
Petar a écrit : (snip) > should a class always > reference only on 'item'? ??? I'm afraid I didn't get this part of the question. -- http://mail.python.org/mailman/listinfo/python-list

Re: OOP: How to implement listing al 'Employees'.

2007-12-28 Thread Bruno Desthuilliers
Petar a écrit : > On 28 dec, 13:40, Bjoern Schliessmann [EMAIL PROTECTED]> wrote: > >>Petar wrote: >> >>>What is the better way of doing this? And should a class always >>>reference only on 'item'? >> >>It fully depends on what you want to do in your program. If you just >>want to have a list of

Re: OOP: How to implement listing al 'Employees'.

2007-12-28 Thread Bruno Desthuilliers
Bjoern Schliessmann a écrit : > Petar wrote: >> What is the better way of doing this? And should a class always >> reference only on 'item'? > > It fully depends on what you want to do in your program. If you just > want to have a list of employees, a list or dict will suffice. If > you need a ful

Re: OOP: How to implement listing al 'Employees'.

2007-12-28 Thread Petar
On 28 dec, 13:40, Bjoern Schliessmann wrote: > Petar wrote: > > What is the better way of doing this? And should a class always > > reference only on 'item'? > > It fully depends on what you want to do in your program. If you just > want to have a list of employees, a list or dict will suffice. If

Re: OOP: How to implement listing al 'Employees'.

2007-12-28 Thread Bjoern Schliessmann
Petar wrote: > What is the better way of doing this? And should a class always > reference only on 'item'? It fully depends on what you want to do in your program. If you just want to have a list of employees, a list or dict will suffice. If you need a full-fledged employee database, an "Employees

Re: OOP in Python book?

2007-07-30 Thread Steve Holden
James Stroud wrote: > Dick Moores wrote: >> At 01:27 PM 7/28/2007, Dennis Lee Bieber wrote: >> >>> On Fri, 27 Jul 2007 16:27:57 -0700, Dick Moores <[EMAIL PROTECTED]> >>> declaimed the following in comp.lang.python: >>> >>> Well, the publisher is Prentice Hall, "The world's leading educat

Re: OOP in Python book?

2007-07-30 Thread James Stroud
Dick Moores wrote: > At 01:27 PM 7/28/2007, Dennis Lee Bieber wrote: > >> On Fri, 27 Jul 2007 16:27:57 -0700, Dick Moores <[EMAIL PROTECTED]> >> declaimed the following in comp.lang.python: >> >> >> > Well, the publisher is Prentice Hall, "The world's leading >> > educational publisher". Textbooks

Re: OOP in Python book?

2007-07-28 Thread Dick Moores
At 01:27 PM 7/28/2007, Dennis Lee Bieber wrote: >On Fri, 27 Jul 2007 16:27:57 -0700, Dick Moores <[EMAIL PROTECTED]> >declaimed the following in comp.lang.python: > > > > Well, the publisher is Prentice Hall, "The world's leading > > educational publisher". Textbooks are typically expensive. > > >

Re: OOP in Python book?

2007-07-27 Thread Dick Moores
At 08:41 AM 7/27/2007, Bill wrote: >Does anyone out there have any information about this book. It's >listed on Amazon to be published in November of this year. A simple >Google search (1st page only) doesn't show anything useful, and I >can't find a reference on the web sites of the authors. Neith

Re: OOP and Tkinter

2006-05-15 Thread Diez B. Roggisch
Ronny Mandal schrieb: > Thanks, but the problem was my undentation, after making one indent, > it worked as expected. :) I seriously doubt that. I guess you didn't show us the real code. But there is no way that an instance variable can be accessed on type-level in a derived class (or from anywh

Re: OOP and Tkinter

2006-05-15 Thread Kent Johnson
Ronny Mandal wrote: > file front_ui.py: > > class Front(object): > _images = [] # Holds image refs to prevent GC > def __init__(self, root): > # Widget Initialization > self._listbox_1 = Tkinter.Listbox(root, > height = 0, > width = 0, > ... >

Re: OOP and Tkinter

2006-05-15 Thread Ronny Mandal
Thanks, but the problem was my undentation, after making one indent, it worked as expected. :) -Ronny M -- http://mail.python.org/mailman/listinfo/python-list

Re: OOP and Tkinter

2006-05-15 Thread Diez B. Roggisch
Ronny Mandal schrieb: > Hello. > > I am stuck; provided is the code and error-msg: > > file front_ui.py: > > class Front(object): > _images = [] # Holds image refs to prevent GC > def __init__(self, root): > > > # Widget Initialization > self._listbox_1 = Tkinter.Listbo

Re: OOP techniques in Python

2006-05-01 Thread Philippe Martin
Thanks, Did not know that. Philippe Dennis Lee Bieber wrote: > On Thu, 27 Apr 2006 14:32:15 -0500, Philippe Martin > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > >> >> What then is the point of the double underscore (if any) ?: > > To prevent masking/shadowing of inhe

Re: OOP techniques in Python

2006-04-28 Thread Steven Bethard
Dennis Lee Bieber wrote: > On Thu, 27 Apr 2006 14:32:15 -0500, Philippe Martin > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > >> What then is the point of the double underscore (if any) ?: > > To prevent masking/shadowing of inherited attributes... Note that it can fa

Re: OOP techniques in Python

2006-04-27 Thread Panos Laganakos
Thanks for all the useful answers :) Alot of stuff to take into consideration/chew on. I come up with similar drawbacks now and then, 'cause some OOP techniques can be made in Python relatively simpler or plainly different (still simpler though). Though I am hesitant on how to act on certain occas

Re: OOP techniques in Python

2006-04-27 Thread Edward Elliott
Philippe Martin wrote: > I'm not sure I understand what you mean ... I did get a strange new > message from my email client and disabled the signature. Look again at the post I replied to (great-grandparent of this one). It's not your sig quote that was the problem. -- http://mail.python.org/ma

Re: OOP techniques in Python

2006-04-27 Thread Philippe Martin
Duncan Booth wrote: > Philippe Martin wrote: >> Steven Bethard wrote: >>> [Please don't top-post] >> >> OK I won't, is that a general rule? (I've been top posting for quite some >> time now and it is the first time I see that warning) > > Yes. Other suggestions you might get are not to bottom po

Re: OOP techniques in Python

2006-04-27 Thread Philippe Martin
Edward Elliott wrote: > Philippe Martin wrote: > '' > > On the other hand, foo.__doc__ and foo.__name__ work fine. > > (I was going to quote your post but my reader interprets everything after > the two dashes as your sig and ignores it. And I won't bother to fix it.) I'm not sure I understan

Re: OOP techniques in Python

2006-04-27 Thread Edward Elliott
Philippe Martin wrote: '' On the other hand, foo.__doc__ and foo.__name__ work fine. (I was going to quote your post but my reader interprets everything after the two dashes as your sig and ignores it. And I won't bother to fix it.) -- http://mail.python.org/mailman/listinfo/python-list

Re: OOP techniques in Python

2006-04-27 Thread Duncan Booth
Philippe Martin wrote: > Steven Bethard wrote: >> [Please don't top-post] > > OK I won't, is that a general rule? (I've been top posting for quite some > time now and it is the first time I see that warning) Yes. Other suggestions you might get are not to bottom post, and certainly not (as you d

Re: OOP techniques in Python

2006-04-27 Thread Philippe Martin
Edward Elliott wrote: > Panos Laganakos wrote: >> i.e. we usually define private properties and provide public functions >> to access them, in the form of: >> get { ... } set { ... } >> >> Should we do the same in Python: >> Or there's no point in doing so? >> >> Some other techniques come to mi

Re: OOP techniques in Python

2006-04-27 Thread Edward Elliott
Panos Laganakos wrote: > i.e. we usually define private properties and provide public functions > to access them, in the form of: > get { ... } set { ... } > > Should we do the same in Python: > Or there's no point in doing so? > > Some other techniques come to mind, but I think that Python tends

Re: OOP techniques in Python

2006-04-27 Thread Philippe Martin
Steven Bethard wrote: > [Please don't top-post] > > Steven Bethard wrote: > > Panos Laganakos wrote: > >> we usually define private properties and provide public functions > >> to access them, in the form of: > >> get { ... } set { ... } > >> > >> Should we do the same in Python: > >> > >

Re: OOP techniques in Python

2006-04-27 Thread bruno at modulix
Panos Laganakos wrote: > I've been thinking if there's a point in applying some specific OOP > techniques in Python as we do in other languages. Yes - but some of these techniques are somewhat python-specific. > i.e. we usually define private properties and provide public functions > to access th

Re: OOP techniques in Python

2006-04-27 Thread Steven Bethard
[Please don't top-post] Steven Bethard wrote: > Panos Laganakos wrote: >> we usually define private properties and provide public functions >> to access them, in the form of: >> get { ... } set { ... } >> >> Should we do the same in Python: >> >> self.__privateAttr = 'some val' >> >> def

  1   2   >