Re: Thoughts on python classes to represent an ebook reader

2014-10-02 Thread math math
Thanks a lot. It is quite helpful to follow the thought process here. Another person gave the example of 'Calibre', but I've found it overwhelming and I couldn't find any UML diagram there (maybe not searched hard enough). Regards, Felix -- https://mail.python.org/mailman/listinfo/python-list

Re: Thoughts on python classes to represent an ebook reader

2014-10-01 Thread Wolfgang Maier
On 01.10.2014 10:14, math math wrote: Hi, I hope there are people here with strong OOP experience. Which classes would an object-oriented python programmer create for the design of a e-book reader for example? I am not really interested in the code, just the OOP classes that would come to one

Thoughts on python classes to represent an ebook reader

2014-10-01 Thread math math
Hi, I hope there are people here with strong OOP experience. Which classes would an object-oriented python programmer create for the design of a e-book reader for example? I am not really interested in the code, just the OOP classes that would come to one's mind for a task like this. It should

Re: Python Classes

2014-08-05 Thread Chris Angelico
On Wed, Aug 6, 2014 at 1:37 AM, Neil D. Cerutti wrote: > In simple cases like that, functions could do very well by including a > little bundle of data (probably a dict) as one of the parameters for each > related function. And this is exactly how object orientation is done in C. You just have a

Re: Python Classes

2014-08-05 Thread Neil D. Cerutti
On 8/4/2014 6:44 PM, John Gordon wrote: In Shubham Tomar writes: classes. I understand that you define classes to have re-usable methods and procedures, but, don't functions serve the same purpose. Can someone please explain the idea of classes If a function simply accepts some data, does

Re: Python Classes

2014-08-04 Thread dieter
, ...) as a higher level building block -- and this leads to classes. A "class" (in Python) is a collection of related functions (called "method"s) and potentially data definitions (this part is quite weak for Python classes; unlike in other languages, the data part of a class

Re: Python Classes

2014-08-04 Thread Terry Reedy
On 8/4/2014 6:44 PM, John Gordon wrote: __init__() is the initializer method, which is called as one step of creating a class object. In fact, it is the last step and usually is the main step for user-defined classes, and the only step one need be concerned with. Object is the lowest-level

Re: Python Classes

2014-08-04 Thread John Gordon
In Shubham Tomar writes: > classes. I understand that you define classes to have re-usable methods and > procedures, but, don't functions serve the same purpose. > Can someone please explain the idea of classes If a function simply accepts some data, does some calculations on that data and th

Re: Python Classes

2014-08-04 Thread Terry Reedy
On 8/4/2014 4:40 AM, Shubham Tomar wrote: Hi, Python is the first programming language that I'm learning. I'm confused by the idea of classes and intimidated by syntax defining classes. I understand that you define classes to have re-usable methods and procedures, but, don't functions serve the

Python Classes

2014-08-04 Thread Shubham Tomar
Hi, Python is the first programming language that I'm learning. I'm confused by the idea of classes and intimidated by syntax defining classes. I understand that you define classes to have re-usable methods and procedures, but, don't functions serve the same purpose. Can someone please explain the

Re: Python classes for reading/writing/parsing MIDI files

2013-11-19 Thread David
On 20 November 2013 12:57, Steven D'Aprano wrote: > On Wed, 20 Nov 2013 10:32:08 +1000, alex23 wrote: >> >> They appear to be resurrecting a 12 year old thread. > > Wow, that's one slow News server. http://en.wikipedia.org/wiki/Slow_Movement :) -- https://mail.python.org/mailman/listinfo/python

Re: Python classes for reading/writing/parsing MIDI files

2013-11-19 Thread Steven D'Aprano
On Wed, 20 Nov 2013 10:32:08 +1000, alex23 wrote: > On 20/11/2013 12:12 AM, Chris Angelico wrote: >> On Wed, Nov 20, 2013 at 12:50 AM, Annmarina Nagy >> wrote: >>> the command label gets "stuck" >> >> A bit of context would help hugely. Are you replying to someone else's >> post? All we have is a

Re: Python classes for reading/writing/parsing MIDI files

2013-11-19 Thread alex23
On 20/11/2013 12:12 AM, Chris Angelico wrote: On Wed, Nov 20, 2013 at 12:50 AM, Annmarina Nagy wrote: the command label gets "stuck" A bit of context would help hugely. Are you replying to someone else's post? All we have is a subject line. They appear to be resurrecting a 12 year old threa

Re: Python classes for reading/writing/parsing MIDI files

2013-11-19 Thread Chris Angelico
On Wed, Nov 20, 2013 at 12:50 AM, Annmarina Nagy wrote: > the command label gets "stuck" A bit of context would help hugely. Are you replying to someone else's post? All we have is a subject line. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Python classes for reading/writing/parsing MIDI files

2013-11-19 Thread Annmarina Nagy
the command label gets "stuck" -- https://mail.python.org/mailman/listinfo/python-list

Re: Organisation of python classes and their methods

2012-11-02 Thread Steven D'Aprano
On Fri, 02 Nov 2012 09:08:07 +0100, Martin Hewitson wrote: > Even if one takes reasonable numbers: 20 methods, each method has 20 > lines of documentation, then we immediately have 400 lines in the file > before writing a line of code. It would seem much more natural to me to > have these methods

Re: Organisation of python classes and their methods

2012-11-02 Thread Steven D'Aprano
On Sat, 03 Nov 2012 01:06:45 +, Steven D'Aprano wrote: > 100 lines is approximately and a half pages using a 10pt font size > (depending on the font and the platform, of course). Crap. I meant approx *one* and a half pages. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Organisation of python classes and their methods

2012-11-02 Thread Steven D'Aprano
On Fri, 02 Nov 2012 07:16:09 +0100, Martin Hewitson wrote: > I'm beginning a large Python project which contains many packages, > modules and classes. The organisation of those is clear to me. [...] > I don't like having source files with > 100's of lines of code in, let alone 1000's. Why? Do you

Re: Organisation of python classes and their methods

2012-11-02 Thread Paul Rubin
Martin Hewitson writes: >> you want just ONE method, something like "map"... > Well, because one of the features that the framework will have is to > capture history steps (in a tree structure) so that each processing > step the user does is tracked. So while methods such as abs(), cos(), > etc wi

Re: Organisation of python classes and their methods

2012-11-02 Thread Martin Hewitson
On 2, Nov, 2012, at 06:24 PM, Paul Rubin wrote: > Martin Hewitson writes: >> Well, here we disagree. Suppose I have a class which encapsulates >> time-series data. Below is a list of the absolute minimum methods one >> would have to process that data. ... >> 'abs' >> 'acos' >> 'asin' >>

Re: Organisation of python classes and their methods

2012-11-02 Thread Paul Rubin
Martin Hewitson writes: > Well, here we disagree. Suppose I have a class which encapsulates > time-series data. Below is a list of the absolute minimum methods one > would have to process that data. ... > 'abs' > 'acos' > 'asin' > ... Ok, THERE is your problem. Why do you have separ

Re: Organisation of python classes and their methods

2012-11-02 Thread Mark Lawrence
On 02/11/2012 14:49, Martin Hewitson wrote: [Top posting fixed] BTW: If you told us which language(s) you have a background in, it could be easier to help you with identifying the idioms in that language that turn into misconceptions when applied to Python. Greetings! Uli [1] Actual

Re: Organisation of python classes and their methods

2012-11-02 Thread Martin Hewitson
> > > BTW: If you told us which language(s) you have a background in, it could be > easier to help you with identifying the idioms in that language that turn > into misconceptions when applied to Python. I'm considering porting some MATLAB code to python to move away from commercial software

Re: Organisation of python classes and their methods

2012-11-02 Thread Martin Hewitson
On 2, Nov, 2012, at 11:49 AM, Ulrich Eckhardt wrote: > Am 02.11.2012 09:20, schrieb Martin Hewitson: >> Well, here we disagree. Suppose I have a class which encapsulates >> time-series data. Below is a list of the absolute minimum methods one >> would have to process that data. > [...] > > 'abs

Re: Organisation of python classes and their methods

2012-11-02 Thread Ulrich Eckhardt
Am 02.11.2012 09:08, schrieb Martin Hewitson: On 2, Nov, 2012, at 08:38 AM, Paul Rubin wrote: Martin Hewitson writes: So, is there a way to put these methods in their own files and have them 'included' in the class somehow? ... Is there an official python way to do this? I don't like having s

Re: Organisation of python classes and their methods

2012-11-02 Thread Ulrich Eckhardt
Am 02.11.2012 09:20, schrieb Martin Hewitson: Well, here we disagree. Suppose I have a class which encapsulates time-series data. Below is a list of the absolute minimum methods one would have to process that data. [...] > 'abs' 'acos' 'asin' 'atan' 'atan2' 'average' 'cohere' 'conv' 'corr' > 'co

Re: Organisation of python classes and their methods

2012-11-02 Thread Robert Kern
On 11/2/12 10:48 AM, Mark Lawrence wrote: On 02/11/2012 08:45, Martin Hewitson wrote: On 2, Nov, 2012, at 09:40 AM, Mark Lawrence wrote: On 02/11/2012 08:08, Martin Hewitson wrote: Even if one takes reasonable numbers: 20 methods, each method has 20 lines of documentation, then we immediat

Re: Organisation of python classes and their methods

2012-11-02 Thread Robert Kern
On 11/2/12 10:21 AM, Peter Otten wrote: Martin Hewitson wrote: On 2, Nov, 2012, at 09:40 AM, Mark Lawrence wrote: 20 lines of documentation per method? As far as I'm concerned that's not a smell, that's a stink. Wow, I don't think I've ever been criticised before for writing too much doc

Re: Organisation of python classes and their methods

2012-11-02 Thread Mark Lawrence
On 02/11/2012 08:45, Martin Hewitson wrote: On 2, Nov, 2012, at 09:40 AM, Mark Lawrence wrote: On 02/11/2012 08:08, Martin Hewitson wrote: Even if one takes reasonable numbers: 20 methods, each method has 20 lines of documentation, then we immediately have 400 lines in the file before writ

Re: Organisation of python classes and their methods

2012-11-02 Thread Steven D'Aprano
On Fri, 02 Nov 2012 08:40:06 +, Mark Lawrence wrote: > On 02/11/2012 08:08, Martin Hewitson wrote: >> >> Even if one takes reasonable numbers: 20 methods, each method has 20 >> lines of documentation, then we immediately have 400 lines in the file >> before writing a line of code. It would see

Re: Organisation of python classes and their methods

2012-11-02 Thread Peter Otten
Martin Hewitson wrote: > On 2, Nov, 2012, at 09:40 AM, Mark Lawrence > wrote: >> 20 lines of documentation per method? As far as I'm concerned that's not >> a smell, that's a stink. > > Wow, I don't think I've ever been criticised before for writing too much > documentation :) > > I guess we

Re: Organisation of python classes and their methods

2012-11-02 Thread Frank Millman
On 02/11/2012 08:16, Martin Hewitson wrote: Dear list, I'm relatively new to Python and have googled and googled but haven't found a reasonable answer to this question, so I thought I'd ask it here. I'm beginning a large Python project which contains many packages, modules and classes. The or

Re: Organisation of python classes and their methods

2012-11-02 Thread Martin Hewitson
On 2, Nov, 2012, at 09:40 AM, Mark Lawrence wrote: > On 02/11/2012 08:08, Martin Hewitson wrote: >> >> Even if one takes reasonable numbers: 20 methods, each method has 20 lines >> of documentation, then we immediately have 400 lines in the file before >> writing a line of code. It would seem

Re: Organisation of python classes and their methods

2012-11-02 Thread Chris Angelico
On Fri, Nov 2, 2012 at 7:08 PM, Martin Hewitson wrote: > > On 2, Nov, 2012, at 08:38 AM, Paul Rubin wrote: > >> Martin Hewitson writes: >>> So, is there a way to put these methods in their own files and have >>> them 'included' in the class somehow? ... Is there an official python >>> way to do

Re: Organisation of python classes and their methods

2012-11-02 Thread Peter Otten
Martin Hewitson wrote: > > On 2, Nov, 2012, at 09:00 AM, Peter Otten <__pete...@web.de> wrote: > >> Martin Hewitson wrote: >> >>> Dear list, >>> >>> I'm relatively new to Python and have googled and googled but haven't >>> found a reasonable answer to this question, so I thought I'd ask it >>>

Re: Organisation of python classes and their methods

2012-11-02 Thread Robert Kern
On 11/2/12 8:20 AM, Martin Hewitson wrote: On 2, Nov, 2012, at 09:00 AM, Peter Otten <__pete...@web.de> wrote: Martin Hewitson wrote: Dear list, I'm relatively new to Python and have googled and googled but haven't found a reasonable answer to this question, so I thought I'd ask it here. I

Re: Organisation of python classes and their methods

2012-11-02 Thread Mark Lawrence
On 02/11/2012 08:08, Martin Hewitson wrote: Even if one takes reasonable numbers: 20 methods, each method has 20 lines of documentation, then we immediately have 400 lines in the file before writing a line of code. It would seem much more natural to me to have these methods in their own file,

Re: Organisation of python classes and their methods

2012-11-02 Thread Martin Hewitson
On 2, Nov, 2012, at 09:00 AM, Peter Otten <__pete...@web.de> wrote: > Martin Hewitson wrote: > >> Dear list, >> >> I'm relatively new to Python and have googled and googled but haven't >> found a reasonable answer to this question, so I thought I'd ask it here. >> >> I'm beginning a large Pyth

Re: Organisation of python classes and their methods

2012-11-02 Thread Martin Hewitson
On 2, Nov, 2012, at 08:38 AM, Paul Rubin wrote: > Martin Hewitson writes: >> So, is there a way to put these methods in their own files and have >> them 'included' in the class somehow? ... Is there an official python >> way to do this? I don't like having source files with 100's of lines >> of

Re: Organisation of python classes and their methods

2012-11-02 Thread Peter Otten
Martin Hewitson wrote: > Dear list, > > I'm relatively new to Python and have googled and googled but haven't > found a reasonable answer to this question, so I thought I'd ask it here. > > I'm beginning a large Python project which contains many packages, modules > and classes. The organisation

Re: Organisation of python classes and their methods

2012-11-02 Thread Paul Rubin
Martin Hewitson writes: > So, is there a way to put these methods in their own files and have > them 'included' in the class somehow? ... Is there an official python > way to do this? I don't like having source files with 100's of lines > of code in, let alone 1000's. That code sounds kind of sme

Organisation of python classes and their methods

2012-11-02 Thread Martin Hewitson
Dear list, I'm relatively new to Python and have googled and googled but haven't found a reasonable answer to this question, so I thought I'd ask it here. I'm beginning a large Python project which contains many packages, modules and classes. The organisation of those is clear to me. Now, the

Re: Python classes: Simplify?

2012-03-23 Thread Steven Lehar
Many thanks to all who responded to my "Python Classes: Simplify?" thread. There seem to be several good reasons for this particular syntactical choice, I am all the wiser for your kind explanations. My faith in the simplicity and elegance of this beautiful language is reinforced.

Re: Python classes: Simplify?

2012-03-23 Thread Jean-Michel Pichavant
Steven Lehar wrote: It seems to me that the Python class system is needlessly confusing. Am I missing something? For example in the class Complex given in the documentation *class Complex:* *def __init__(self, realpart, imagpart):* *self.r = realpart* *self.i = imagpart* *

Re: Python classes: Simplify?

2012-03-22 Thread J. Cliff Dyer
The issue of explicitly naming a "self" parameter has been discussed in depth on a number of occasions. I recommend a google search for "python implicit self" for some of the reasons why it exists. Here's what Guido has to say about it: http://neopythonic.blogspot.com/2008/10/why-explicit-self-h

Re: Python classes: Simplify?

2012-03-22 Thread Andrea Crotti
On 03/22/2012 10:51 AM, Steven Lehar wrote: It seems to me that the Python class system is needlessly confusing. Am I missing something? For example in the class Complex given in the documentation *class Complex:* *def __init__(self, realpart, imagpart):* *self.r = realpart* *

Re: Python classes: Simplify?

2012-03-22 Thread Chris Rebert
On Thu, Mar 22, 2012 at 3:51 AM, Steven Lehar wrote: > It seems to me that the Python class system is needlessly confusing. Am I > missing something? Explicit `self` is slightly annoying, but you'll get over it quickly (trust me). > For example in the class Complex given in the documentation > >

Re: Python classes: Simplify?

2012-03-22 Thread Chris Angelico
On Thu, Mar 22, 2012 at 9:51 PM, Steven Lehar wrote: > It seems to me that the Python class system is needlessly confusing. Am I > missing something? > > For example in the class Complex given in the documentation > > class Complex: >     def __init__(self, realpart, imagpart): >         self.r =

Python classes: Simplify?

2012-03-22 Thread Steven Lehar
It seems to me that the Python class system is needlessly confusing. Am I missing something? For example in the class Complex given in the documentation *class Complex:* *def __init__(self, realpart, imagpart):* *self.r = realpart* *self.i = imagpart* * * *x = Complex(3.0, -4.

Re: A question about Python Classes

2011-04-23 Thread Steven D'Aprano
On Sat, 23 Apr 2011 13:30:02 -0700, chad wrote: > On Apr 22, 12:47 pm, Carl Banks wrote: >> On Thursday, April 21, 2011 11:00:08 AM UTC-7, MRAB wrote: >> > On 21/04/2011 18:12, Pascal J. Bourguignon wrote: >> > > chad  writes: >> >> > >> Let's say I have the following >> >> > >> class BaseHan

Re: A question about Python Classes

2011-04-23 Thread chad
On Apr 22, 12:47 pm, Carl Banks wrote: > On Thursday, April 21, 2011 11:00:08 AM UTC-7, MRAB wrote: > > On 21/04/2011 18:12, Pascal J. Bourguignon wrote: > > > chad  writes: > > > >> Let's say I have the following > > > >> class BaseHandler: > > >>      def foo(self): > > >>          print "He

Re: A question about Python Classes

2011-04-22 Thread Carl Banks
On Thursday, April 21, 2011 11:00:08 AM UTC-7, MRAB wrote: > On 21/04/2011 18:12, Pascal J. Bourguignon wrote: > > chad writes: > > > >> Let's say I have the following > >> > >> class BaseHandler: > >> def foo(self): > >> print "Hello" > >> > >> class HomeHandler(BaseHandler): >

Re: A question about Python Classes

2011-04-22 Thread Ian Kelly
On Fri, Apr 22, 2011 at 7:49 AM, Kyle T. Jones wrote: >> You don't need to create an instance of BaseHandler.  You have the >> class, Python knows you have the class -- Python will look there if the >> subclasses lack an attribute. >> >> ~Ethan~ >> > > Really?  That's not at all how I thought it w

Re: A question about Python Classes

2011-04-22 Thread Ethan Furman
Kyle T. Jones wrote: Ethan Furman wrote: chad wrote: Let's say I have the following class BaseHandler: def foo(self): print "Hello" class HomeHandler(BaseHandler): pass Then I do the following... test = HomeHandler() test.foo() How can HomeHandler call foo() when I nev

Re: A question about Python Classes

2011-04-22 Thread Kyle T. Jones
Ethan Furman wrote: chad wrote: Let's say I have the following class BaseHandler: def foo(self): print "Hello" class HomeHandler(BaseHandler): pass Then I do the following... test = HomeHandler() test.foo() How can HomeHandler call foo() when I never created an instance

Re: A question about Python Classes

2011-04-22 Thread Jean-Michel Pichavant
MRAB wrote: On 21/04/2011 18:12, Pascal J. Bourguignon wrote: chad writes: Let's say I have the following class BaseHandler: def foo(self): print "Hello" class HomeHandler(BaseHandler): pass Then I do the following... test = HomeHandler() test.foo() How can HomeHa

Re: A question about Python Classes

2011-04-21 Thread Steven D'Aprano
On Thu, 21 Apr 2011 19:00:08 +0100, MRAB wrote: >>> How can HomeHandler call foo() when I never created an instance of >>> BaseHandler? >> >> But you created one! >> > No, he didn't, he created an instance of HomeHandler. > >> test is an instance of HomeHandler, which is a subclass of BaseHandler

Re: A question about Python Classes

2011-04-21 Thread Ethan Furman
chad wrote: Let's say I have the following class BaseHandler: def foo(self): print "Hello" class HomeHandler(BaseHandler): pass Then I do the following... test = HomeHandler() test.foo() How can HomeHandler call foo() when I never created an instance of BaseHandler? Yo

Re: A question about Python Classes

2011-04-21 Thread MRAB
On 21/04/2011 18:12, Pascal J. Bourguignon wrote: chad writes: Let's say I have the following class BaseHandler: def foo(self): print "Hello" class HomeHandler(BaseHandler): pass Then I do the following... test = HomeHandler() test.foo() How can HomeHandler call fo

Re: A question about Python Classes

2011-04-21 Thread Terry Reedy
On 4/21/2011 11:43 AM, chad wrote: Let's say I have the following class BaseHandler: def foo(self): print "Hello" class HomeHandler(BaseHandler): pass Then I do the following... test = HomeHandler() test.foo() How can HomeHandler call foo() when I never created an ins

Re: A question about Python Classes

2011-04-21 Thread Pascal J. Bourguignon
chad writes: > Let's say I have the following > > class BaseHandler: > def foo(self): > print "Hello" > > class HomeHandler(BaseHandler): > pass > > > Then I do the following... > > test = HomeHandler() > test.foo() > > How can HomeHandler call foo() when I never created an in

Re: A question about Python Classes

2011-04-21 Thread Benjamin Kaplan
On Apr 21, 2011 12:55 PM, "chad" wrote: > > On Apr 21, 9:30 am, Jean-Michel Pichavant > wrote: > > chad wrote: > > > Let's say I have the following > > > > > class BaseHandler: > > > def foo(self): > > > print "Hello" > > > > > class HomeHandler(BaseHandler): > > > pass > > >

Re: A question about Python Classes

2011-04-21 Thread chad
On Apr 21, 9:30 am, Jean-Michel Pichavant wrote: > chad wrote: > > Let's say I have the following > > > class BaseHandler: > >     def foo(self): > >         print "Hello" > > > class HomeHandler(BaseHandler): > >     pass > > > Then I do the following... > > > test = HomeHandler() > > test.fo

Re: A question about Python Classes

2011-04-21 Thread Jean-Michel Pichavant
chad wrote: Let's say I have the following class BaseHandler: def foo(self): print "Hello" class HomeHandler(BaseHandler): pass Then I do the following... test = HomeHandler() test.foo() How can HomeHandler call foo() when I never created an instance of BaseHandler? Cha

Re: A question about Python Classes

2011-04-21 Thread Rafael Durán Castañeda
You did: >>> class BaseHandler: ... def foo(self): ... print "Hello" ... >>> class HomerHandler(BaseHandler): ... pass ... >>> test = HomerHandler() >>> test.foo() Hello >>> isinstance(test, BaseHandler) True >>> isinstance(test, HomerHandler) True >>> You could say test is a

A question about Python Classes

2011-04-21 Thread chad
Let's say I have the following class BaseHandler: def foo(self): print "Hello" class HomeHandler(BaseHandler): pass Then I do the following... test = HomeHandler() test.foo() How can HomeHandler call foo() when I never created an instance of BaseHandler? Chad -- http://m

class in c subclasses python classes, called in python

2010-11-25 Thread alex goretoy
. One task that I need to do is create a class in c++ that subclasses 3 python classes and calls the base class constructor as super would call in python. I need this in c++. How can I do this please? class ABC(a,b,c): def __init__(self, *args, **kwargs): super(ABC, self).__init__(

Upcoming Python Classes in New York

2009-12-08 Thread Steve Holden
Holden Web is pleased to announce three upcoming classes in New York city the week of January 18. Jan 18-20Introduction to Python (3 days) - Steve Holden http://holdenweb.com/py/introclass/ Jan 21 .NET: IronPython from the Ground Up (1 day) - Michael Foord http://holdenweb.com/py/ironpython/

Re: Python Classes

2007-08-28 Thread Lamonte Harris
Ok thanks I'll try remembering it. On 8/28/07, Erik Jones <[EMAIL PROTECTED]> wrote: > > On Aug 28, 2007, at 12:04 AM, Lamonte Harris wrote: > > > How come you have to set the initialized created variables to equal > > the parameters, shouldn't that be default? > > > > class testing: > >

Re: Python Classes

2007-08-28 Thread Erik Jones
On Aug 28, 2007, at 12:04 AM, Lamonte Harris wrote: > How come you have to set the initialized created variables to equal > the parameters, shouldn't that be default? > > class testing: > def __init__(self,testing): >self.testing = testing > x = testing("testing") >

Python Classes

2007-08-27 Thread Lamonte Harris
How come you have to set the initialized created variables to equal the parameters, shouldn't that be default? class testing: def __init__(self,testing): self.testing = testing x = testing("testing") print x.testing How come self.testing = testing Can someone explain

Re: static python classes ?

2007-06-20 Thread Neil Cerutti
On 2007-06-20, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-06-20, Alex Martelli <[EMAIL PROTECTED]> wrote: >> Neil Cerutti <[EMAIL PROTECTED]> wrote: >>> In C++ they are used most often for factory functions, since >>> they conveniently have access to the class's private members, >>> and don'

Re: static python classes ?

2007-06-20 Thread Neil Cerutti
On 2007-06-20, Alex Martelli <[EMAIL PROTECTED]> wrote: > Neil Cerutti <[EMAIL PROTECTED]> wrote: > >> In C++ they are used most often for factory functions, since they >> conveniently have access to the class's private members, and >> don't want or need an existing instance. Python seems to have >

Re: static python classes ?

2007-06-20 Thread Alex Martelli
Neil Cerutti <[EMAIL PROTECTED]> wrote: > In C++ they are used most often for factory functions, since they > conveniently have access to the class's private members, and > don't want or need an existing instance. Python seems to have > adopted this use-case (ConfigParser, for example), but withou

Re: static python classes ?

2007-06-20 Thread Neil Cerutti
On 2007-06-19, Bjoern Schliessmann <[EMAIL PROTECTED]> wrote: > Diez B. Roggisch wrote: >> With other OOP languages you mean Java. Which does have static >> methods because they lack the notion of a function by its own, >> so the shoehorned them into their "everything is inside a >> class"-paradigm

Re: static python classes ?

2007-06-20 Thread Diez B. Roggisch
Bjoern Schliessmann wrote: > Diez B. Roggisch wrote: > >> With other OOP languages you mean Java. Which does have static >> methods because they lack the notion of a function by its own, so >> the shoehorned them into their "everything is inside a >> class"-paradigm. > > ACK, but doesn't C++ hav

Re: static python classes ?

2007-06-20 Thread Bruno Desthuilliers
Tom Gur a écrit : >> Look for @staticmethod inhttp://docs.python.org/lib/built-in-funcs.html >> >> Example: >> class C: >> @staticmethod >> def f(arg1, arg2, ...): ... > > > Oops, sorry for the confusion - I've actually meant a static method, > and Gerald's answer works fine. FWIW, stati

Re: static python classes ?

2007-06-19 Thread Bjoern Schliessmann
Diez B. Roggisch wrote: > With other OOP languages you mean Java. Which does have static > methods because they lack the notion of a function by its own, so > the shoehorned them into their "everything is inside a > class"-paradigm. ACK, but doesn't C++ have static methods too? Regards, Björn

Re: static python classes ?

2007-06-19 Thread Diez B. Roggisch
Tom Gur wrote: > Hi, > > I'm new to python, and I can't seem to find in the docs how to create > the python equivalent of what's called in most OOP languages "static > classes", can you give me a hint ? With other OOP languages you mean Java. Which does have static methods because they lack the

Re: static python classes ?

2007-06-19 Thread Ben Finney
Tom Gur <[EMAIL PROTECTED]> writes: > I'm new to python, and I can't seem to find in the docs how to > create the python equivalent of what's called in most OOP languages > "static classes", can you give me a hint ? Can you give us a hint of what a "static class" would do? That is, what features

Re: static python classes ?

2007-06-19 Thread Tom Gur
> Look for @staticmethod inhttp://docs.python.org/lib/built-in-funcs.html > > Example: > class C: > @staticmethod > def f(arg1, arg2, ...): ... Oops, sorry for the confusion - I've actually meant a static method, and Gerald's answer works fine. Thanks alot -- http://mail.python.org/mai

Re: static python classes ?

2007-06-19 Thread Ant
It's not clear what you mean here. If you mean something like static inner classes in Java, then you can simply nest classes in Python: >>> class A(object): ... class B(object): ... def aaa(self): ... print "AA" ... >>> z = A.B() >>> z.aaa() AA (In c

Re: static python classes ?

2007-06-19 Thread Carsten Haese
On Tue, 2007-06-19 at 12:00 +, Tom Gur wrote: > Hi, > > I'm new to python, and I can't seem to find in the docs how to create > the python equivalent of what's called in most OOP languages "static > classes", can you give me a hint ? If I had to guess, which apparently I have to because you'r

Re: static python classes ?

2007-06-19 Thread google
> > the python equivalent of what's called in most OOP languages "static > > classes", can you give me a hint ? > > Look for @staticmethod inhttp://docs.python.org/lib/built-in-funcs.html Woops... I misread... -- Gerald Kaszuba http://geraldkaszuba.com -- http://mail.python.org/mailman/listinfo

Re: static python classes ?

2007-06-19 Thread google
On Jun 19, 10:00 pm, Tom Gur <[EMAIL PROTECTED]> wrote: > Hi, > > I'm new to python, and I can't seem to find in the docs how to create > the python equivalent of what's called in most OOP languages "static > classes", can you give me a hint ? Look for @staticmethod in http://docs.python.org/lib/b

static python classes ?

2007-06-19 Thread Tom Gur
Hi, I'm new to python, and I can't seem to find in the docs how to create the python equivalent of what's called in most OOP languages "static classes", can you give me a hint ? -- http://mail.python.org/mailman/listinfo/python-list

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-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 -- http://mail.python

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 t

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

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 so

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 mi

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 shou

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

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

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 o

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 heigh

  1   2   >