[Tutor] Apprenticeships

2012-09-29 Thread Malcolm Newsome
my first post was a bit abstract. Have the responses so far been helpful? Oscar -- next part -- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/tutor/attachments/20120929/ac95aa50/attachment-0001.html> -- Message: 2 Date: Sat

Re: [Tutor] generic repr method?

2012-09-29 Thread eryksun
On Sat, Sep 29, 2012 at 7:46 PM, eryksun wrote: > > A class with __slots__ probably lacks a __dict__. That didn't come out clearly. I meant *instances* of a class that defines __slots__. ___ Tutor maillist - Tutor@python.org To unsubscribe or change s

Re: [Tutor] generic repr method?

2012-09-29 Thread eryksun
On Sat, Sep 29, 2012 at 4:15 PM, Albert-Jan Roskam wrote: > > def __repr__(self): > code = self.__class__.__name__ + "(" > for arg in inspect.getargspec(self.__init__).args [1:] : > if isinstance(eval("self." + arg), basestring): > code += ("%(" + a

Re: [Tutor] generic repr method?

2012-09-29 Thread Oscar Benjamin
On 29 September 2012 21:15, Albert-Jan Roskam wrote: > Hi, > > I've written a __repr__ method that is supposed to *always* work. That is, > it returns an eval-able text representation of any class instance. > Will this really always work? No. > I'd find it useful is this is standard behavior

Re: [Tutor] Lotka-Volterra Model Simulation Questions

2012-09-29 Thread Brett Ritter
On Sat, Sep 29, 2012 at 2:16 AM, Alan Gauld wrote: > As to using short names to keep things on a single line, there is a huge > body of research in Comp Science that shows that meaningful names outweigh > single line expressions every time in terms of reliability, comprehension, > ease of maintena

Re: [Tutor] Lotka-Volterra Model Simulation Questions

2012-09-29 Thread Oscar Benjamin
On 29 September 2012 22:57, Alan Gauld wrote: > On 29/09/12 11:42, Steven D'Aprano wrote: > >> On 29/09/12 19:16, Alan Gauld wrote: >> > Totally agree. > My point is that we should not choose short names just to keep an > expression on a single line. The evidence suggests that the advantages of >

Re: [Tutor] Lotka-Volterra Model Simulation Questions

2012-09-29 Thread Alan Gauld
On 29/09/12 11:42, Steven D'Aprano wrote: On 29/09/12 19:16, Alan Gauld wrote: I did say I had no idea about the original algorithm so yes, if the variable names are industry standardised and the people working with the code are familiar with them then it may be better to stick with them,

Re: [Tutor] Lotka-Volterra Model Simulation Questions

2012-09-29 Thread Oscar Benjamin
On 28 September 2012 21:32, Jim Apto wrote: > Hello folks, > > I'm relatively new to python, and was asked to program a lotka-volterra > model (predator and prey relation) simulator. The program basically will > basically have a menu that takes user input, collect data, and then create > a graph

[Tutor] generic repr method?

2012-09-29 Thread Albert-Jan Roskam
Hi, I've written a __repr__ method that is supposed to *always* work. That is, it returns an eval-able text representation of any class instance. Will this really always work? I'd find it useful is this is standard behavior of Python. Or am I overlooking something? import inspect class X (obj

Re: [Tutor] Lotka-Volterra Model Simulation Questions

2012-09-29 Thread Wayne Werner
On Sat, 29 Sep 2012, Wayne Werner wrote: On Sat, 29 Sep 2012, Oscar Benjamin wrote: On Sep 29, 2012 2:25 AM, "Alan Gauld" wrote: > > On 28/09/12 21:32, Jim Apto wrote: > >> I'm relatively new to python, and was asked to program a lotka-volterra >> model (predator and prey relation) simulator.

Re: [Tutor] Lotka-Volterra Model Simulation Questions

2012-09-29 Thread Wayne Werner
On Sat, 29 Sep 2012, Oscar Benjamin wrote: On Sep 29, 2012 2:25 AM, "Alan Gauld" wrote: > > On 28/09/12 21:32, Jim Apto wrote: > >> I'm relatively new to python, and was asked to program a lotka-volterra >> model (predator and prey relation) simulator. > > >> x represents prey population >> y re

Re: [Tutor] Lotka-Volterra Model Simulation Questions

2012-09-29 Thread Oscar Benjamin
On Sep 29, 2012 11:52 AM, "Steven D'Aprano" wrote: > > On 29/09/12 19:16, Alan Gauld wrote: >> >> As to using short names to keep things on a single line, there is a huge >> body of research in Comp Science that shows that meaningful names outweigh >> single line expressions every time in terms of

Re: [Tutor] Lotka-Volterra Model Simulation Questions

2012-09-29 Thread Mark Lawrence
On 29/09/2012 11:42, Steven D'Aprano wrote: On 29/09/12 19:16, Alan Gauld wrote: On 29/09/12 09:41, Oscar Benjamin wrote: Meaningful names are vital. But short names, even single letters, are not necessarily less meaningful than longer, more descriptive names. I suspect that every experienc

Re: [Tutor] Lotka-Volterra Model Simulation Questions

2012-09-29 Thread Steven D'Aprano
On 29/09/12 19:16, Alan Gauld wrote: On 29/09/12 09:41, Oscar Benjamin wrote: > so use names that say so, like preyPop and predatorPop > Its only a few extra letters typing but makes things much more readable. As a mathematician I'd have to disagree with you there Alan. This model already has

Re: [Tutor] Lotka-Volterra Model Simulation Questions

2012-09-29 Thread Alan Gauld
On 29/09/12 09:41, Oscar Benjamin wrote: > so use names that say so, like preyPop and predatorPop > Its only a few extra letters typing but makes things much more readable. As a mathematician I'd have to disagree with you there Alan. This model already has an established notation: I did say

Re: [Tutor] Lotka-Volterra Model Simulation Questions

2012-09-29 Thread Oscar Benjamin
On Sep 29, 2012 9:41 AM, "Oscar Benjamin" wrote: > > > On Sep 29, 2012 2:25 AM, "Alan Gauld" wrote: > > > > On 28/09/12 21:32, Jim Apto wrote: > > > >> I'm relatively new to python, and was asked to program a lotka-volterra > >> model (predator and prey relation) simulator. > > > > > > No idea wh

Re: [Tutor] Lotka-Volterra Model Simulation Questions

2012-09-29 Thread Oscar Benjamin
On Sep 29, 2012 2:25 AM, "Alan Gauld" wrote: > > On 28/09/12 21:32, Jim Apto wrote: > >> I'm relatively new to python, and was asked to program a lotka-volterra >> model (predator and prey relation) simulator. > > > No idea what that means in practice but commenting purely on the code provided...