Re: Classic OOP in Python

2015-11-12 Thread jongiddy
On Thursday, 18 June 2015 12:21:29 UTC+1, Jason P. wrote: > > I'm aware of duck typing. The point in using interfaces is to be explicit > about the boundaries of a system. > > Quite a red "Growing Object-Oriented Software, Guided by Tests", by the way. > In fact interfaces are key components

Re: Classic OOP in Python

2015-06-21 Thread Laura Creighton
Ah, turns out there was an entry. I updated it. Laura -- https://mail.python.org/mailman/listinfo/python-list

Re: Classic OOP in Python

2015-06-20 Thread Mark Lawrence
On 19/06/2015 00:01, Laura Creighton wrote: In a message of Thu, 18 Jun 2015 11:50:28 +0100, Mark Lawrence writes: Throw in http://clonedigger.sourceforge.net/ as well and you've a really awesome combination. Mark Lawrence I didn't know about that one. Hey thank you, Mark. Looks great. It

Re: Classic OOP in Python

2015-06-18 Thread Jason P.
El miércoles, 17 de junio de 2015, 21:44:51 (UTC+2), Ned Batchelder escribió: On Wednesday, June 17, 2015 at 3:21:32 PM UTC-4, Jason P. wrote: Hello Python community. I come from a classic background in what refers to OOP. Mostly Java and PHP ( 5.3). I'm used to abstract classes,

Re: Classic OOP in Python

2015-06-18 Thread Todd
On Thu, Jun 18, 2015 at 1:03 PM, Fabien fabien.mauss...@gmail.com wrote: On 06/17/2015 11:16 PM, sohcahto...@gmail.com wrote: You don't need interfaces with Python. Duck typing makes that all possible. Yes, but I also like interfaces (or in python: mimicked interfaces with

Re: Classic OOP in Python

2015-06-18 Thread Jason P.
El miércoles, 17 de junio de 2015, 21:44:51 (UTC+2), Ned Batchelder escribió: On Wednesday, June 17, 2015 at 3:21:32 PM UTC-4, Jason P. wrote: Hello Python community. I come from a classic background in what refers to OOP. Mostly Java and PHP ( 5.3). I'm used to abstract classes,

Re: Classic OOP in Python

2015-06-18 Thread Marko Rauhamaa
Todd toddr...@gmail.com: On Thu, Jun 18, 2015 at 1:03 PM, Fabien fabien.mauss...@gmail.com wrote: Would you consider the following kind of program unpythonic? class MovingObject(object): Great doc about what a moving object is def move(self): Great doc about move

Re: Classic OOP in Python

2015-06-18 Thread Jason P.
El miércoles, 17 de junio de 2015, 22:39:31 (UTC+2), Marko Rauhamaa escribió: Ned Batchelder n...@nedbatchelder.com: TDD is about writing tests as a way to design the best system, and putting testing at the center of your development workflow. It works great with Python even without

Re: Classic OOP in Python

2015-06-18 Thread Ned Batchelder
On Thursday, June 18, 2015 at 7:21:29 AM UTC-4, Jason P. wrote: El miércoles, 17 de junio de 2015, 21:44:51 (UTC+2), Ned Batchelder escribió: On Wednesday, June 17, 2015 at 3:21:32 PM UTC-4, Jason P. wrote: Hello Python community. I come from a classic background in what refers to

Re: Classic OOP in Python

2015-06-18 Thread Chris Angelico
On Thu, Jun 18, 2015 at 9:03 PM, Fabien fabien.mauss...@gmail.com wrote: Would you consider the following kind of program unpythonic? class MovingObject(object): Great doc about what a moving object is def move(self): Great doc about move raise NotImplementedError()

Re: Classic OOP in Python

2015-06-18 Thread Fabien
On 06/17/2015 11:16 PM, sohcahto...@gmail.com wrote: You don't need interfaces with Python. Duck typing makes that all possible. Yes, but I also like interfaces (or in python: mimicked interfaces with NotImplementedError) for their clarity and documentation purposes. Would you consider the

Re: Classic OOP in Python

2015-06-18 Thread Cousin Stanley
python -m doctest application.py And from there, I would build up extra doc tests An extra doc test that fails #!/usr/bin/env python NewsGroup comp.lang.python Subject .. Classic OOP in Python Date . 2015-06-17 Post_By

Re: Classic OOP in Python

2015-06-18 Thread Laura Creighton
In a message of Thu, 18 Jun 2015 11:50:28 +0100, Mark Lawrence writes: Throw in http://clonedigger.sourceforge.net/ as well and you've a really awesome combination. Mark Lawrence I didn't know about that one. Hey thank you, Mark. Looks great. It needs its own entry in

Re: Classic OOP in Python

2015-06-18 Thread Marco Buttu
On 17/06/2015 23:33, sohcahto...@gmail.com wrote: I had a Java class where we had to learn TDD, and that's the way TDD was taught to us, and I hated it. We watched a video of this guy explaining TDD with a hat that was red on the front and green on the back. It involved writing a simple

Re: Classic OOP in Python

2015-06-18 Thread Mark Lawrence
On 17/06/2015 23:33, Laura Creighton wrote: In a message of Wed, 17 Jun 2015 14:14:34 -0700, Ned Batchelder writes: TDD is supposed to make you brave, not cowards, and it's Ned's most excellent tool http://nedbatchelder.com/code/coverage/ that I recommend to TDD dogmatic cowards. Even if you

Re: Classic OOP in Python

2015-06-17 Thread Skip Montanaro
On Wed, Jun 17, 2015 at 2:21 PM, Jason P. suscrici...@gmail.com wrote: I'm gonna try to develop a modest application from ground up using TDD. If it had been done in Java for instance, I would made extensive use of interfaces to define the boundaries of my system. How would I do something like

Re: Classic OOP in Python

2015-06-17 Thread Ned Batchelder
On Wednesday, June 17, 2015 at 3:21:32 PM UTC-4, Jason P. wrote: Hello Python community. I come from a classic background in what refers to OOP. Mostly Java and PHP ( 5.3). I'm used to abstract classes, interfaces, access modifiers and so on. Don't get me wrong. I know that despite the

Re: Classic OOP in Python

2015-06-17 Thread Laura Creighton
In a message of Wed, 17 Jun 2015 14:33:43 -0700, sohcahto...@gmail.com writes: I had a Java class where we had to learn TDD, and that's the way TDD was taught to us, and I hated it. We watched a video of this guy explaining TDD with a hat that was red on the front and green on the back. It

Re: Classic OOP in Python

2015-06-17 Thread Laura Creighton
In a message of Wed, 17 Jun 2015 14:14:34 -0700, Ned Batchelder writes: The true TDD acolytes advocate a very idiosyncratic workflow, it's true. I don't do this, but I also don't consider myself a TDD person. I value tests a great deal, and put a lot of effort into them, but I don't write trivial

Re: Classic OOP in Python

2015-06-17 Thread Steven D'Aprano
On Thu, 18 Jun 2015 06:39 am, Marko Rauhamaa wrote: Ned Batchelder n...@nedbatchelder.com: TDD is about writing tests as a way to design the best system, and putting testing at the center of your development workflow. It works great with Python even without interfaces. I wonder how great

Re: Classic OOP in Python

2015-06-17 Thread Ned Batchelder
On Wednesday, June 17, 2015 at 6:34:23 PM UTC-4, Laura Creighton wrote: TDD is supposed to make you brave, not cowards, and it's Ned's most excellent tool http://nedbatchelder.com/code/coverage/ that I recommend to TDD dogmatic cowards. Even if you don't want to use TTD, you will enjoy

Re: Classic OOP in Python

2015-06-17 Thread Terry Reedy
On 6/17/2015 4:39 PM, Marko Rauhamaa wrote: Ned Batchelder n...@nedbatchelder.com: TDD is about writing tests as a way to design the best system, and putting testing at the center of your development workflow. It works great with Python even without interfaces. I use what I might call 'smart

Re: Classic OOP in Python

2015-06-17 Thread Chris Angelico
On Thu, Jun 18, 2015 at 6:39 AM, Marko Rauhamaa ma...@pacujo.net wrote: Another interesting ism I have read about is the idea that the starting point of any software project should be the user manual. The developers should then go and build the product that fits the manual. I've seldom met a

Re: Classic OOP in Python

2015-06-17 Thread Mark Lawrence
On 17/06/2015 23:09, Laura Creighton wrote: ps -- Marko, we have ample evidence that you are an extremely clever person. But the purpose of TTD is not to make clever code, but wise code. TTD in the hands of a fool will never produce that. But how else do you have to check that your design,

Re: Classic OOP in Python

2015-06-17 Thread Ned Batchelder
On Wednesday, June 17, 2015 at 4:39:31 PM UTC-4, Marko Rauhamaa wrote: The way it was explained to me was that in TDD you actually don't write code to any requirements or design: you simply do the least to pass the tests. Thus, say you need to write a program that inputs a string and outputs

Re: Classic OOP in Python

2015-06-17 Thread sohcahtoa82
On Wednesday, June 17, 2015 at 1:39:31 PM UTC-7, Marko Rauhamaa wrote: Ned Batchelder n...@nedbatchelder.com: TDD is about writing tests as a way to design the best system, and putting testing at the center of your development workflow. It works great with Python even without interfaces.

Classic OOP in Python

2015-06-17 Thread Jason P.
Hello Python community. I come from a classic background in what refers to OOP. Mostly Java and PHP ( 5.3). I'm used to abstract classes, interfaces, access modifiers and so on. Don't get me wrong. I know that despite the differences Python is fully object oriented. My point is, do you know

Re: Classic OOP in Python

2015-06-17 Thread sohcahtoa82
On Wednesday, June 17, 2015 at 12:21:32 PM UTC-7, Jason P. wrote: Hello Python community. I come from a classic background in what refers to OOP. Mostly Java and PHP ( 5.3). I'm used to abstract classes, interfaces, access modifiers and so on. Don't get me wrong. I know that despite the

Re: Classic OOP in Python

2015-06-17 Thread Mark Lawrence
On 17/06/2015 21:39, Marko Rauhamaa wrote: Ned Batchelder n...@nedbatchelder.com: TDD is about writing tests as a way to design the best system, and putting testing at the center of your development workflow. It works great with Python even without interfaces. I wonder how great it really

Re: Classic OOP in Python

2015-06-17 Thread Mark Lawrence
On 17/06/2015 22:33, sohcahto...@gmail.com wrote: On Wednesday, June 17, 2015 at 1:39:31 PM UTC-7, Marko Rauhamaa wrote: Ned Batchelder n...@nedbatchelder.com: TDD is about writing tests as a way to design the best system, and putting testing at the center of your development workflow. It

Re: Classic OOP in Python

2015-06-17 Thread Laura Creighton
In a message of Wed, 17 Jun 2015 23:39:17 +0300, Marko Rauhamaa writes: Ned Batchelder n...@nedbatchelder.com: TDD is about writing tests as a way to design the best system, and putting testing at the center of your development workflow. It works great with Python even without interfaces. I

Re: Classic OOP in Python

2015-06-17 Thread Marko Rauhamaa
Ned Batchelder n...@nedbatchelder.com: TDD is about writing tests as a way to design the best system, and putting testing at the center of your development workflow. It works great with Python even without interfaces. I wonder how great it really is. Testing is important, that's for sure, but

OOP no Python

2014-06-26 Thread Samuel David
conceitos da OOP o Python implementa que não é suportado pelo Delphi? A pergunta pode parecer um pouco capciosa, mas temos uma vertente forte de Delphi na empresa e preciso de argumentos sólidos para expor a área de desenvolvimento antes de decidirmos qual linguagem iremos adotar para este novo projeto

Re: OOP no Python

2014-06-26 Thread Stéphane Wirtel
dos conceitos da OOP. Fiquei bastante curioso referente a quais conceitos da OOP o Python implementa que não é suportado pelo Delphi? A pergunta pode parecer um pouco capciosa, mas temos uma vertente forte de Delphi na empresa e preciso de argumentos sólidos para expor a área de desenvolvimento

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

Re: OOP no Python

2014-06-26 Thread Chris Angelico
2014-06-27 0:16 GMT+10:00 Samuel David samuel.co...@eos-hoepers.com: Mas estou com uma dúvida referente ao tópico “Por que eu deveria usar Python e não insira aqui a sua linguagem favorita?”. Google Translate tells me you're asking Why use Python instead of some other language?. (I'm going to

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 ros...@gmail.com wrote: 2014-06-27 0:16 GMT+10:00 Samuel David samuel.co...@eos-hoepers.com: Mas estou com uma dúvida referente ao tópico “Por que eu deveria usar Python e não insira

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 are typically

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 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.

OOP in Python book?

2007-07-27 Thread Bill
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. Neither of the authors appears to be

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. Neither

Re: Questions about app design - OOP with python classes

2007-03-04 Thread greg
Paul Rubin wrote: Maybe we can concoct a cross between Python and Haskell, and call it Paskell after the philosopher Blaise ;-). No, we name it after Pascall's confectionery: http://www.homesick-kiwi.com/productpage.php?id=51 Lots of syntactic sugar. :-) -- Greg --

Re: Questions about app design - OOP with python classes

2007-03-04 Thread greg
John Nagle wrote: The Pascal/Ada/Modula family of languages all had type systems with restrictions on conversion. Unlike C, types in Pascal are not simply abbreviations of the type; they're unique types. Ada is the only one of those that would let you define things like a new kind of

Re: Questions about app design - OOP with python classes

2007-03-03 Thread Steven D'Aprano
On Fri, 02 Mar 2007 09:30:20 +0100, Diez B. Roggisch wrote: A type system doesn't help. So what if they're both floats? The test is still bogus, your code will still wait too long to engage the retro-rockets, and the billion dollar space craft will still be travelling at hundreds of miles an

Re: Questions about app design - OOP with python classes

2007-03-03 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes: Multi-Level-Specification allows you to express physical quantities with their respective unit, and operations on them to yield the combined unit at compile-time. There are some rather complicated cases where simple unification won't solve the

Re: Questions about app design - OOP with python classes

2007-03-03 Thread Steven D'Aprano
On Thu, 01 Mar 2007 21:53:09 -0800, Paul Rubin wrote: Steven D'Aprano [EMAIL PROTECTED] writes: That still sounds like an unreliable manual type system, It's unreliable in the sense that the coder has to follow the naming convention, and must have some bare minimum of sense. If your coders

Re: Questions about app design - OOP with python classes

2007-03-03 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes: Unless there is a type system that can automatically deal with the semantic difference between (say) screen coordinates and window coordinates, or between height and width, or safe and unsafe strings, the coder still has to deal with it themselves.

Re: Questions about app design - OOP with python classes

2007-03-03 Thread John Nagle
Steven D'Aprano wrote: On Fri, 02 Mar 2007 09:30:20 +0100, Diez B. Roggisch wrote: A type system doesn't help. So what if they're both floats? The test is still bogus, your code will still wait too long to engage the retro-rockets, and the billion dollar space craft will still be travelling

Re: Questions about app design - OOP with python classes

2007-03-02 Thread Diez B. Roggisch
A type system doesn't help. So what if they're both floats? The test is still bogus, your code will still wait too long to engage the retro-rockets, and the billion dollar space craft will still be travelling at hundreds of miles an hour when it reaches the surface of Mars. A type system

Re: Questions about app design - OOP with python classes

2007-03-02 Thread [EMAIL PROTECTED]
On 2 mar, 05:14, Steven D'Aprano [EMAIL PROTECTED] wrote: On Thu, 01 Mar 2007 21:45:55 +0100, Bruno Desthuilliers wrote: As a side note : hungarian notation is usually considered bad form here. Look here for usual naming conventions: http://www.python.org/dev/peps/pep-0008/ Which Hungarian

Re: Questions about app design - OOP with python classes

2007-03-02 Thread GHUM
if hmmCurrentHeight = hinCriticalHeight: then you should instantly recognise that there's a problem. all civilized nations but one use metric systems. Of course there is a problem if you spot inches somewhere. Harald -- http://mail.python.org/mailman/listinfo/python-list

Re: Questions about app design - OOP with python classes

2007-03-02 Thread MRAB
On Mar 2, 4:47 am, Steven D'Aprano [EMAIL PROTECTED] wrote: On Thu, 01 Mar 2007 20:24:33 -0800, Paul Rubin wrote: Steven D'Aprano [EMAIL PROTECTED] writes: But if you used Apps Hungarian, and saw this line of code: if hmmCurrentHeight = hinCriticalHeight: then you should instantly

Questions about app design - OOP with python classes

2007-03-01 Thread adriancico
Hi I am working on a python app, an outliner(a window with a TreeCtrl on the left to select a document, and a RichTextBox at the right to edit the current doc). I am familiarized with OOP concepts and terms but I lack practical experience , so any comment/tip/pointer to docs will be

Re: Questions about app design - OOP with python classes

2007-03-01 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : Hi I am working on a python app, an outliner(a window with a TreeCtrl on the left to select a document, and a RichTextBox at the right to edit the current doc). I am familiarized with OOP concepts and terms but I lack practical experience , so any

Re: Questions about app design - OOP with python classes

2007-03-01 Thread adriancico
On Mar 1, 9:45 pm, Bruno Desthuilliers [EMAIL PROTECTED] wrote: As a side note : hungarian notation is usually considered bad form here. Look here for usual naming conventions:http://www.python.org/dev/peps/pep-0008/ Thanks for the tip. It's been too many years of VB6, and its difficult to

Re: Questions about app design - OOP with python classes

2007-03-01 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : On Mar 1, 9:45 pm, Bruno Desthuilliers [EMAIL PROTECTED] wrote: I understand (I've been in wikipedia :-) ). Right now the Frame is the controller as well as the view. Yeps. Note that this is a common simplification of the MVC - Microsoft labelled it

Re: Questions about app design - OOP with python classes

2007-03-01 Thread Steven D'Aprano
On Thu, 01 Mar 2007 21:45:55 +0100, Bruno Desthuilliers wrote: As a side note : hungarian notation is usually considered bad form here. Look here for usual naming conventions: http://www.python.org/dev/peps/pep-0008/ Which Hungarian notation do you mean? If you mean the Windows Systems

Re: Questions about app design - OOP with python classes

2007-03-01 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes: But if you used Apps Hungarian, and saw this line of code: if hmmCurrentHeight = hinCriticalHeight: then you should instantly recognise that there's a problem. Comparing a height in millimetres to a height in inches is not a good thing to do, no

Re: Questions about app design - OOP with python classes

2007-03-01 Thread Steven D'Aprano
On Thu, 01 Mar 2007 20:24:33 -0800, Paul Rubin wrote: Steven D'Aprano [EMAIL PROTECTED] writes: But if you used Apps Hungarian, and saw this line of code: if hmmCurrentHeight = hinCriticalHeight: then you should instantly recognise that there's a problem. Comparing a height in

Re: Questions about app design - OOP with python classes

2007-03-01 Thread Erik Max Francis
Steven D'Aprano wrote: A type system doesn't help. So what if they're both floats? The test is still bogus, your code will still wait too long to engage the retro-rockets, and the billion dollar space craft will still be travelling at hundreds of miles an hour when it reaches the surface of

Re: Questions about app design - OOP with python classes

2007-03-01 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes: That still sounds like an unreliable manual type system, It's unreliable in the sense that the coder has to follow the naming convention, and must have some bare minimum of sense. If your coders are morons, no naming convention will save you. (For

Re: About classes and OOP in Python

2006-04-12 Thread bruno at modulix
Ben C wrote: On 2006-04-11, Michele Simionato [EMAIL PROTECTED] wrote: Roy Smith wrote: snip That being said, you can indeed have private data in Python. Just prefix your variable names with two underscores (i.e. __foo), and they effectively become private. Yes, you can bypass this if you

Re: About classes and OOP in Python

2006-04-12 Thread bruno at modulix
Casey Hawthorne wrote: I think it's important not to wrongly confuse 'OOP' with ''data hiding' or any other aspect you may be familiar with from Java or C++. The primary concept behind OOP is not buzzwords such as abstraction, encapsulation, polymorphism, etc etc, but the fact that your program

Re: About classes and OOP in Python

2006-04-12 Thread Magnus Lycka
Michele Simionato wrote: Roy Smith wrote: snip That being said, you can indeed have private data in Python. Just prefix your variable names with two underscores (i.e. __foo), and they effectively become private. Yes, you can bypass this if you really want to, but then again, you can bypass

Re: About classes and OOP in Python

2006-04-12 Thread bruno at modulix
Gregor Horvath wrote: Steven D'Aprano schrieb: I don't know of many other OO languages that didn't/don't have inheritance, VB4 - VB6 VB6 has a kind of inheritance via interface/delegation. The interface part is for subtyping, the delegation part (which has to be done manually - yuck)

Re: About classes and OOP in Python

2006-04-11 Thread Ben Sizer
fyhuang wrote: It seems to me that it is difficult to use OOP to a wide extent in Python code because these features of the language introduce many inadvertant bugs. For example, if the programmer typos a variable name in an assignment, the assignment will probably not do what the programmer

Re: About classes and OOP in Python

2006-04-11 Thread Fredrik Lundh
Ben Sizer wrote: I think it's important not to wrongly confuse 'OOP' with ''data hiding' or any other aspect you may be familiar with from Java or C++. The primary concept behind OOP is not buzzwords such as abstraction, encapsulation, polymorphism, etc etc, but the fact that your program

Re: About classes and OOP in Python

2006-04-11 Thread Michele Simionato
Roy Smith wrote: snip That being said, you can indeed have private data in Python. Just prefix your variable names with two underscores (i.e. __foo), and they effectively become private. Yes, you can bypass this if you really want to, but then again, you can bypass private in C++ too.

Re: About classes and OOP in Python

2006-04-11 Thread bruno at modulix
fyhuang wrote: Hello all, I've been wondering a lot about why Python handles classes and OOP the way it does. From what I understand, there is no concept of class encapsulation in Python, i.e. no such thing as a private variable. Seems you're confusing encapsulation with data hiding. Any

Re: About classes and OOP in Python

2006-04-11 Thread Casey Hawthorne
I think it's important not to wrongly confuse 'OOP' with ''data hiding' or any other aspect you may be familiar with from Java or C++. The primary concept behind OOP is not buzzwords such as abstraction, encapsulation, polymorphism, etc etc, but the fact that your program consists of objects

Re: About classes and OOP in Python

2006-04-11 Thread Ben C
On 2006-04-11, Michele Simionato [EMAIL PROTECTED] wrote: Roy Smith wrote: snip That being said, you can indeed have private data in Python. Just prefix your variable names with two underscores (i.e. __foo), and they effectively become private. Yes, you can bypass this if you really want to,

Re: About classes and OOP in Python

2006-04-11 Thread Steven D'Aprano
On Tue, 11 Apr 2006 18:20:13 +, Casey Hawthorne wrote: I think it's important not to wrongly confuse 'OOP' with ''data hiding' or any other aspect you may be familiar with from Java or C++. The primary concept behind OOP is not buzzwords such as abstraction, encapsulation, polymorphism, etc

Re: About classes and OOP in Python

2006-04-11 Thread Ben Cartwright
Michele Simionato wrote: Roy Smith wrote: snip That being said, you can indeed have private data in Python. Just prefix your variable names with two underscores (i.e. __foo), and they effectively become private. Yes, you can bypass this if you really want to, but then again, you can

Re: About classes and OOP in Python

2006-04-11 Thread Gregor Horvath
Steven D'Aprano schrieb: I don't know of many other OO languages that didn't/don't have inheritance, VB4 - VB6 -- Mit freundlichen Grüßen, Ing. Gregor Horvath, Industrieberatung Softwareentwicklung http://www.gregor-horvath.com -- http://mail.python.org/mailman/listinfo/python-list

About classes and OOP in Python

2006-04-10 Thread fyhuang
Hello all, I've been wondering a lot about why Python handles classes and OOP the way it does. From what I understand, there is no concept of class encapsulation in Python, i.e. no such thing as a private variable. Any part of the code is allowed access to any variable in any class, and even

Re: About classes and OOP in Python

2006-04-10 Thread [EMAIL PROTECTED]
You can do this in Python as well. Check out the property built-in function. One can declare a property with a get, set, and delete method. Here's a small example of a read-only property. class Test(object): def getProperty(self): return 0; prop = property(fget = getProperty)

Re: About classes and OOP in Python

2006-04-10 Thread Roy Smith
fyhuang [EMAIL PROTECTED] wrote: I've been wondering a lot about why Python handles classes and OOP the way it does. From what I understand, there is no concept of class encapsulation in Python, i.e. no such thing as a private variable. Any part of the code is allowed access to any variable in

Re: About classes and OOP in Python

2006-04-10 Thread Felipe Almeida Lessa
Em Seg, 2006-04-10 às 07:19 -0700, fyhuang escreveu: class PythonClass: private foo = bar private var = 42 allow_readwrite( [ foo, var ] ) You are aware that foo and var would become class-variables, not instance-variables, right? But you can always do: class PythonClass(object):

Re: About classes and OOP in Python

2006-04-10 Thread Sion Arrowsmith
fyhuang [EMAIL PROTECTED] wrote: [ ... ] no such thing as a private variable. Any part of the code is allowed access to any variable in any class, and even non-existant variables can be accessed: they are simply created. You're confusing two issues: encapsulation and dynamic name binding. You

Re: About classes and OOP in Python

2006-04-10 Thread Gregor Horvath
Hi, fyhuang schrieb: I've been wondering a lot about why Python handles classes and OOP the way it does. From what I understand, there is no concept of class encapsulation in Python, i.e. no such thing as a private variable. Any the answer is here: http://tinyurl.com/obgho -- Mit

Re: Global Variables in OOP and Python

2006-01-01 Thread Kay Schluehr
Steven D'Aprano wrote: On Fri, 30 Dec 2005 20:00:51 -0500, Mike Meyer wrote: The other way I thought of is to create a separate class that consists of the variables and to use the from file name import * in all of the files (namespaces) where it is needed. Except for one

Re: Global Variables in OOP and Python

2006-01-01 Thread Steven D'Aprano
On Sun, 01 Jan 2006 06:48:48 -0800, Kay Schluehr wrote: Agree about from module import * being bad, but it is still generally poor practice for the same reason using global variables is generally poor practice. No, I don't think so. The general wisdom is that global variables are bad not

Re: Global Variables in OOP and Python

2005-12-31 Thread Steven D'Aprano
On Sat, 31 Dec 2005 21:21:29 +, Dennis Lee Bieber wrote: On Sat, 31 Dec 2005 11:37:38 +1100, Steven D'Aprano [EMAIL PROTECTED] declaimed the following in comp.lang.python: Do you mean something like this? # Module care_and_feeding import birds import foods def feed_my_pet():

Re: oop in python

2005-12-30 Thread Larry Bates
novice wrote: hello over there! I have the following question: Suppose I created a class: class Point: pass then instanciated an instance: new = Point() So now how to get the instance new as a string: like ' new ' ;

Re: oop in python

2005-12-30 Thread jmdeschamps
Larry Bates wrote: novice wrote: hello over there! I have the following question: Suppose I created a class: class Point: pass then instanciated an instance: new = Point() So now how to get the instance new as a

Re: oop in python

2005-12-30 Thread jmdeschamps
(addendum) ... And even ... eval(t).max() 12 -- http://mail.python.org/mailman/listinfo/python-list

Global Variables in OOP and Python

2005-12-30 Thread newbie
Hello, I have questions about global variables in OOP (in general) and Python (in specific). I understand (I think) that global variables are generally not a good idea. However, if there are variables that need to be accessed by a number of classes that exists in separate namespaces (files),

Re: Global Variables in OOP and Python

2005-12-30 Thread Steven D'Aprano
On Fri, 30 Dec 2005 15:03:54 -0800, newbie wrote: Hello, I have questions about global variables in OOP (in general) and Python (in specific). I understand (I think) that global variables are generally not a good idea. However, if there are variables that need to be accessed by a number

Re: Global Variables in OOP and Python

2005-12-30 Thread Mike Meyer
newbie [EMAIL PROTECTED] writes: So far, I have approached the problem by making the variables attributes of one class and passing instances of the class as variables to the other class' methods. That's the standard way to do it in OO languages. The other way I thought of is to create a

Re: Global Variables in OOP and Python

2005-12-30 Thread Gary Herron
newbie wrote: Hello, I have questions about global variables in OOP (in general) and Python (in specific). I understand (I think) that global variables are generally not a good idea. However, if there are variables that need to be accessed by a number of classes that exists in separate

Re: Global Variables in OOP and Python

2005-12-30 Thread Brian van den Broek
Gary Herron said unto the world upon 30/12/05 08:03 PM: newbie wrote: Hello, I have questions about global variables in OOP (in general) and Python (in specific). I understand (I think) that global variables are generally not a good idea. However, if there are variables that need to be

Re: Global Variables in OOP and Python

2005-12-30 Thread Steven D'Aprano
On Fri, 30 Dec 2005 20:00:51 -0500, Mike Meyer wrote: The other way I thought of is to create a separate class that consists of the variables and to use the from file name import * in all of the files (namespaces) where it is needed. Except for one detail, this is a Pythonesque method.

oop in python

2005-12-27 Thread novice
hello over there! I have the following question: Suppose I created a class: class Point: pass then instanciated an instance: new = Point() So now how to get the instance new as a string: like ' new ' ; Is there any built

Re: oop in python

2005-12-27 Thread Uwe Hoffmann
novice schrieb: class Point: def _func_that_we_want_(self): return ... return self.__class__.__name__ http://docs.python.org/ref/types.html#l2h-109 -- http://mail.python.org/mailman/listinfo/python-list

Re: oop in python

2005-12-27 Thread Steven D'Aprano
On Tue, 27 Dec 2005 02:42:18 -0800, novice wrote: hello over there! I have the following question: Suppose I created a class: class Point: pass then instanciated an instance: new = Point() So now how to get the