Re: Translating some Java to Python

2007-05-21 Thread Gabriel Genellina
En Mon, 21 May 2007 09:26:19 -0300, Unknown <[EMAIL PROTECTED]> escribió: > One example that comes to mind is a class that is a proxy for a database > class, say Person. > The Person.Load(id) method doesn't use any instance or class data, it > instantiates a Person and populates it from the data

Re: Translating some Java to Python

2007-05-21 Thread Herman Slagman
"Gabriel Genellina" <[EMAIL PROTECTED]> schreef in bericht news:[EMAIL PROTECTED] > En Mon, 21 May 2007 07:39:09 -0300, Unknown <[EMAIL PROTECTED]> > escribió: > >> "Ant" <[EMAIL PROTECTED]> schreef in bericht >> news:[EMAIL PROTECTED] >> >>> Herman has shown you *how* to do static methods in Py

Re: Translating some Java to Python

2007-05-21 Thread Gabriel Genellina
En Mon, 21 May 2007 07:39:09 -0300, Unknown <[EMAIL PROTECTED]> escribió: > "Ant" <[EMAIL PROTECTED]> schreef in bericht > news:[EMAIL PROTECTED] > >> Herman has shown you *how* to do static methods in Python, but >> typically they are not used. Since Python has first class functions, >> and the

Re: Translating some Java to Python

2007-05-21 Thread Diez B. Roggisch
> > Hmm, > > As an experienced developer I'm rather new to Python, so please forgive me > any non-Pythonic babbling. > From a language point you're probably right, but from a design point I'd > like to have methods that are clearly associated with a class as methods > of that class, even if they

Re: Translating some Java to Python

2007-05-21 Thread Herman Slagman
"Ant" <[EMAIL PROTECTED]> schreef in bericht news:[EMAIL PROTECTED] > Herman has shown you *how* to do static methods in Python, but > typically they are not used. Since Python has first class functions, > and they can be defined at the module level, there is no need to use > static methods. Hm

Re: Translating some Java to Python

2007-05-21 Thread Ant
On May 20, 9:24 pm, Daniel Gee <[EMAIL PROTECTED]> wrote: ... > The Java version has static methods for common roll styles (XdY and XdY > +Z) for classes that just want a result but don't want to bother > keeping an object around for later. > > So the question is, assuming that I wanted to keep the

Re: Translating some Java to Python

2007-05-21 Thread Herman Slagman
"Daniel Gee" <[EMAIL PROTECTED]> schreef in bericht news:[EMAIL PROTECTED] > class Foo: > def statAdd(self,a): >return a+5 > > or do you drop the 'self' bit and just use a 1 variable parameter list? class Foo: @staticmethod def statAdd(a): return a+5 HTH Herman -- http://mail.pyth

Re: Translating some Java to Python

2007-05-20 Thread Daniel Gee
Alright, sounds good. I'm just not as familiar with the preferred designs of python. As to wanting to have them in a class, sometimes I do. Persisting a roll in a class is only for the slightly more complicated rolls such as 3d6+5d4-1d12 or "4d6 (drop the lowest and re-roll ones)", things of that

Re: Translating some Java to Python

2007-05-20 Thread Arnaud Delobelle
On May 20, 9:24 pm, Daniel Gee <[EMAIL PROTECTED]> wrote: > A while ago I wrote a class in Java for all kinds of dice rolling > methods, as many sides as you want, as many dice as you want, only > count values above or below some number in the total, things like > that. Now I'm writing a project in

Translating some Java to Python

2007-05-20 Thread Daniel Gee
A while ago I wrote a class in Java for all kinds of dice rolling methods, as many sides as you want, as many dice as you want, only count values above or below some number in the total, things like that. Now I'm writing a project in Python that needs to be able to make use of that kind of a class.