Re: design question

2011-04-10 Thread Andrea Crotti
Andrea Crotti writes: [...] I left the Timeline as before, but tried to rewrite some more classes. This is the abstract class for a metric, and below another class for the metric which involve only counting things. In the end an example on how to use this. I need to see synthetic values during

Re: design question

2010-05-04 Thread Tim Arnold
On May 4, 3:39 am, Bruno Desthuilliers wrote: > Alf P. Steinbach a écrit : > (snip) > > > Re efficiency it seems to be a complete non-issue, but correctness is > > much more important: is there any way that the config details can be > > (inadvertently) changed while the build is going on? > > +1

Re: design question

2010-05-04 Thread Bruno Desthuilliers
Alf P. Steinbach a écrit : (snip) Re efficiency it seems to be a complete non-issue, but correctness is much more important: is there any way that the config details can be (inadvertently) changed while the build is going on? +1 -- http://mail.python.org/mailman/listinfo/python-list

Re: design question

2010-05-03 Thread Alf P. Steinbach
* Tim Arnold: This is a question about system design I guess. I have a django website that allows users to change/view configuration details for documentation builds. The database is very small. The reason I'm using a database in the first place is to make it easy for users to change the configur

Re: design question

2010-05-03 Thread Kev
Tim Arnold wrote: > This is a question about system design I guess. I have a django > website that allows users to change/view configuration details for > documentation builds. The database is very small. The reason I'm using > a database in the first place is to make it easy for users to change >

Re: Design question about pretree classifier

2010-01-04 Thread Aahz
In article , Steve Holden wrote: >Julian wrote: >> >> But: >> >> - none classification: return an exception or None? I think None is >> better, hence its not an exception that there is no classification but >> a defined state. What do you think? >> - many classifications: what to do? retun a se

Re: Design question about pretree classifier

2009-12-18 Thread Julian
On 18 Dez., 18:59, Steve Holden wrote: > Julian wrote: > > Hello, > > > I've got a design problem for a classifier. To make it short: it maps > > strings on strings. > > > Some strings have exactly one classification, some none and some more > > than one. > > > There's a method classify(self, word

Re: Design question about pretree classifier

2009-12-18 Thread Steve Holden
Julian wrote: > Hello, > > I've got a design problem for a classifier. To make it short: it maps > strings on strings. > > Some strings have exactly one classification, some none and some more > than one. > > There's a method classify(self, word) wich classifies a word. For the > first case ther

Re: Design question.

2009-07-20 Thread Dave Angel
Lacrima wrote: On Jul 20, 4:05 pm, Jean-Michel Pichavant wrote: Lacrima wrote: Hello! I am newbie in python and I have really simple question, but I need your advice to know how to do best. I need to store a number of dictionaries in certain place. I've decided to store them in

Re: Design question.

2009-07-20 Thread Marcus Wanner
On 7/20/2009 9:42 AM, Lacrima wrote: On Jul 20, 4:05 pm, Jean-Michel Pichavant wrote: Lacrima wrote: Hello! I am newbie in python and I have really simple question, but I need your advice to know how to do best. I need to store a number of dictionaries in certain place. I've decided to store t

Re: Design question.

2009-07-20 Thread Lacrima
On Jul 20, 4:05 pm, Jean-Michel Pichavant wrote: > Lacrima wrote: > > Hello! > > > I am newbie in python and I have really simple question, but I need > > your advice to know how to do best. > > I need to store a number of dictionaries in certain place. I've > > decided to store them in a separate

Re: Design question.

2009-07-20 Thread Jean-Michel Pichavant
Lacrima wrote: Hello! I am newbie in python and I have really simple question, but I need your advice to know how to do best. I need to store a number of dictionaries in certain place. I've decided to store them in a separate module. Like this: dicts.py --- dict1 = {} dic

Re: Design question.

2009-07-20 Thread Lacrima
On Jul 20, 3:31 pm, "Diez B. Roggisch" wrote: > Lacrima wrote: > > Hello! > > > I am newbie in python and I have really simple question, but I need > > your advice to know how to do best. > > I need to store a number of dictionaries in certain place. I've > > decided to store them in a separate mo

Re: Design question.

2009-07-20 Thread Diez B. Roggisch
Lacrima wrote: > Hello! > > I am newbie in python and I have really simple question, but I need > your advice to know how to do best. > I need to store a number of dictionaries in certain place. I've > decided to store them in a separate module. > Like this: > dicts.py > --- >

Re: design question, metaclasses?

2009-04-14 Thread Piet van Oostrum
> Darren Dale (DD) wrote: >DD> On Apr 11, 2:15 pm, Darren Dale wrote: >>> I am working on a project that provides a high level interface to hdf5 >>> files by implementing a thin wrapper around h5py. I would like to >>> generalize the project so the same API can be used with other formats, >>

Re: design question, metaclasses?

2009-04-12 Thread Aaron Brady
On Apr 12, 4:53 pm, Darren Dale wrote: > On Apr 12, 4:50 pm, Kay Schluehr wrote: > > > > > On 11 Apr., 20:15, Darren Dale wrote: > > > > I am working on a project that provides a high level interface to hdf5 > > > files by implementing a thin wrapper around h5py. > > > I would like to > > > gene

Re: design question, metaclasses?

2009-04-12 Thread Darren Dale
On Apr 12, 4:50 pm, Kay Schluehr wrote: > On 11 Apr., 20:15, Darren Dale wrote: > > > I am working on a project that provides a high level interface to hdf5 > > files by implementing a thin wrapper around h5py. > > I would like to > > generalize the project so the same API can be used with other

Re: design question, metaclasses?

2009-04-12 Thread Kay Schluehr
On 11 Apr., 20:15, Darren Dale wrote: > I am working on a project that provides a high level interface to hdf5 > files by implementing a thin wrapper around h5py. > I would like to > generalize the project so the same API can be used with other formats, > like netcdf or ascii files. The format sp

Re: design question, metaclasses?

2009-04-12 Thread Darren Dale
On Apr 12, 3:23 pm, Aaron Brady wrote: > On Apr 12, 1:30 pm, Darren Dale wrote: > > > > > On Apr 11, 2:15 pm, Darren Dale wrote: > > _ > > > > format1.Group # implementation of group in format1 > > > format2.Group # ... > > > Base.DerivedGroup # base implementation of DerivedGroup, not directly

Re: design question, metaclasses?

2009-04-12 Thread Aaron Brady
On Apr 12, 1:30 pm, Darren Dale wrote: > On Apr 11, 2:15 pm, Darren Dale wrote: > > _ > > > format1.Group # implementation of group in format1 > > format2.Group # ... > > Base.DerivedGroup # base implementation of DerivedGroup, not directly > > useful > > format1.DerivedGroup = Base.DerivedGroup(

Re: design question, metaclasses?

2009-04-12 Thread Darren Dale
On Apr 11, 2:15 pm, Darren Dale wrote: > I am working on a project that provides a high level interface to hdf5 > files by implementing a thin wrapper around h5py. I would like to > generalize the project so the same API can be used with other formats, > like netcdf or ascii files. The format spec

Re: Design question - Sharing of single object by multiple processes

2008-01-31 Thread Steve Holden
Mike D wrote: > Steve, > > You raise some very good (and obvious) issues I did'nt consider. I'll > look further into this sort of implementation as I'm quite interested. > > I suppose a compromise could be to load the objects from a pickle, that > may have issues in terms of updating the pickle

Re: Design question - Sharing of single object by multiple processes

2008-01-31 Thread Mike D
Steve, You raise some very good (and obvious) issues I did'nt consider. I'll look further into this sort of implementation as I'm quite interested. I suppose a compromise could be to load the objects from a pickle, that may have issues in terms of updating the pickle perhaps, though it would be m

Re: Design question - Sharing of single object by multiple processes

2008-01-31 Thread Steve Holden
Mike D wrote: > Steve, > > Thanks for the response. My question really comes down to, as you > suggested, premature optimization. > > It is more for my own understanding than a current practical use. > > If an object is loaded into memory and other threads(or processes) can > recieve a pointer

RE: Design question - Sharing of single object by multiple processes

2008-01-31 Thread Mike D
Steve, Thanks for the response. My question really comes down to, as you suggested, premature optimization. It is more for my own understanding than a current practical use. If an object is loaded into memory and other threads(or processes) can recieve a pointer to this location, would this not

Re: Design question - Sharing of single object by multiple processes

2008-01-31 Thread Steve Holden
Mike D wrote: > Hello, I've just picked up the Python language and am really enjoying it. > > I've just signed up to this mailing list and I'm looking forward to > taking part in some discussions. > > My first post is a question I've been pondering for the last couple of days: > > For relativel

Re: Design question regarding exceptions.

2007-07-18 Thread Bruno Desthuilliers
asincero a écrit : > I have a class called Users that provides a higher level of > abstraction to an underlying "users" table in a pgsql database. It > has methods like "addUser()" and "deleteUser()" which, obviously, wrap > the corresponding SQL statements. My question is would it better to > le

Re: Design question regarding exceptions.

2007-07-17 Thread James Stroud
asincero wrote: > I have a class called Users that provides a higher level of > abstraction to an underlying "users" table in a pgsql database. It > has methods like "addUser()" and "deleteUser()" which, obviously, wrap > the corresponding SQL statements. My question is would it better to > let a

Re: design question

2007-05-13 Thread Gabriel Genellina
En Sun, 13 May 2007 11:40:16 -0300, Bruno Desthuilliers <[EMAIL PROTECTED]> escribió: > It's alas pretty common to see OO taught by persons who'd rather do some > other job - preferably not related to computers. If I had to name my worst class at university, it was the first one about OO. The

Re: design question

2007-05-13 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > On May 12, 9:34 pm, Bjoern Schliessmann [EMAIL PROTECTED]> wrote: > > >>In principle, this is legal. >> >>But OTOH, how could a ShoppingCart "buy" something? In my world, >>Buyers "buy" when using ShoppingCarts. > > > Yes, I don't know either. I got this assignme

Re: design question

2007-05-12 Thread idaku2
On May 12, 9:34 pm, Bjoern Schliessmann wrote: > In principle, this is legal. > > But OTOH, how could a ShoppingCart "buy" something? In my world, > Buyers "buy" when using ShoppingCarts. Yes, I don't know either. I got this assignment for my homework, and in UML diagram class ShoppingCart has

Re: design question: generator object with other attributes

2007-03-22 Thread Alex Martelli
Alan Isaac <[EMAIL PROTECTED]> wrote: > Essentially I want a generator that I can query about > its characteristics. (E.g., a random number generator > that I want to be able to ask about is distributional > parameters.) > > I am thinking of a class that wraps a generator. > An object of this cl

Re: design question: generator object with other attributes

2007-03-22 Thread James Stroud
Alan Isaac wrote: > Essentially I want a generator that I can query about > its characteristics. (E.g., a random number generator > that I want to be able to ask about is distributional > parameters.) > > I am thinking of a class that wraps a generator. > An object of this class will have a ``nex

Re: design question: generator object with other attributes

2007-03-22 Thread Robert Kern
Alan Isaac wrote: > Essentially I want a generator that I can query about > its characteristics. (E.g., a random number generator > that I want to be able to ask about is distributional > parameters.) > > I am thinking of a class that wraps a generator. > An object of this class will have a ``nex

Re: design question: no new attributes

2007-03-14 Thread Harold Fellermann
Hi Alan, > One last point. While I remain interested in examples of how > "late" addition ofattributesto class instances is useful, > I must note that everyone who responded agreed that it > has been a source of bugs. This seems to argue against a > general ban on "locking" objects in some way, i

Re: design question: no new attributes

2007-03-04 Thread Arnaud Delobelle
On Feb 26, 9:48 pm, "Alan Isaac" <[EMAIL PROTECTED]> wrote: > I have a class whose instances should only receive attribute > assignments for attributes that were created at inititialization. > If slots are not appropriate, what is the Pythonic design for this? Hi ! Even though a lot of people hav

Re: design question: no new attributes

2007-03-01 Thread Diez B. Roggisch
> > One last point. While I remain interested in examples of how > "late" addition of attributes to class instances is useful, > I must note that everyone who responded agreed that it > has been a source of bugs. This seems to argue against a > general ban on "locking" objects in some way, in som

Re: design question: no new attributes

2007-03-01 Thread Bruno Desthuilliers
Alan Isaac a écrit : > The security application seems to call for roles. Considering that a role is a set of permissions in a context. The application doesn't want to say "you need this role", but "you need to have a role that has this permission" (nb : this is based on Zope's security model).

Re: design question: no new attributes

2007-03-01 Thread Alan Isaac
The security application seems to call for roles. I'll have to think about the schema example. But in any case, my question was poorly stated. I started out wanting to trap was the dynamic addition of attributes to class instances after initialization. While you responded to my later question as as

Re: design question: no new attributes

2007-03-01 Thread Bruno Desthuilliers
Alan Isaac a écrit : > "Bruno Desthuilliers" <[EMAIL PROTECTED]> wrote in > message news:[EMAIL PROTECTED] > >>I don't share your definition of "reasonable". But you should have >>guessed by now > > > My view may be shaped by a different experience. > I have found dynamic attribute creation conv

Re: design question: no new attributes

2007-03-01 Thread Paul Boddie
On 28 Feb, 15:39, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > However I will observe that > > - entire languages are structured on the premise that dynamic > > attribute creation can be hazardous > > Yup, and you are free to use one of them. And as an additional benefit, they > will be more p

Re: design question: no new attributes

2007-03-01 Thread Alan Isaac
"greg" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > There's a problem with that when you want to subclass: Agreed. The following addresses that and, I think, some of the other objections that have been raised. Alan class Lockable: a = 0 def __init__(self, lock=False):

Re: design question: no new attributes

2007-03-01 Thread Alan Isaac
"Bruno Desthuilliers" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I don't share your definition of "reasonable". But you should have > guessed by now My view may be shaped by a different experience. I have found dynamic attribute creation convenient when doing something "quick a

Re: design question: no new attributes

2007-03-01 Thread Michele Simionato
On Feb 26, 10:48 pm, "Alan Isaac" <[EMAIL PROTECTED]> wrote: > I have a class whose instances should only receive attribute > assignments for attributes that were created at inititialization. > If slots are not appropriate, what is the Pythonic design for this? > > Thanks, > Alan Isaac There is a

Re: design question: no new attributes

2007-03-01 Thread greg
Alan Isaac wrote: > class NothingNew: > a = 0 > def __init__(self): > self.b = 1 > self.initialized = True There's a problem with that when you want to subclass: class NothingElseNew(NothingNew): def __init__(self): NothingNew.__init__(self) self.c

Re: design question: no new attributes

2007-02-28 Thread Gabriel Genellina
En Wed, 28 Feb 2007 09:41:47 -0300, Alan Isaac <[EMAIL PROTECTED]> escribió: > However I will observe that > - entire languages are structured on the premise that dynamic > attribute creation can be hazardous That's why we have so many languages to choose from. What is highly important for so

Re: design question: no new attributes

2007-02-28 Thread Bruno Desthuilliers
Alan Isaac a écrit : > Ben Finney writes: > >>Really, though, adding attributes to an instance is a normal thing to >>do in Python, and you've not yet shown why you want that normal >>functionality to be special-cased here. > > > > I accept your earlier point that if an interface changes > one

Re: design question: no new attributes

2007-02-28 Thread Diez B. Roggisch
> However I will observe that > - entire languages are structured on the premise that dynamic > attribute creation can be hazardous Yup, and you are free to use one of them. And as an additional benefit, they will be more performant because you then can optimize the code further. But they certain

Re: design question: no new attributes

2007-02-28 Thread Alan Isaac
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The easy, but inelegant, way is to set a flag. That is the approach I explored here: http://mail.python.org/pipermail/python-list/2007-February/428562.html Btw, I add some background comments about "why" here: http://

Re: design question: no new attributes

2007-02-28 Thread Alan Isaac
Ben Finney writes: > Really, though, adding attributes to an instance is a normal thing to > do in Python, and you've not yet shown why you want that normal > functionality to be special-cased here. I accept your earlier point that if an interface changes one can just trap use of the old interfac

Re: design question: no new attributes

2007-02-27 Thread Steven D'Aprano
On Tue, 27 Feb 2007 20:59:03 +, Alan Isaac wrote: > "Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > class Difficult(object): > def __setattr__(self, name, value): > if self.__dict__.has_key(name): > print "'%s' exists as an instance att

Re: design question: no new attributes

2007-02-27 Thread Ben Finney
"Alan Isaac" <[EMAIL PROTECTED]> writes: > OK, let me approach this from a new direction. Suppose I define a > class that behaves I think as I stipulated:: > > class NothingNew: > a = 0 > def __init__(self): > self.b = 1 > self.initialized = True > def __setattr__(self

Re: design question: no new attributes

2007-02-27 Thread Alan Isaac
OK, let me approach this from a new direction. Suppose I define a class that behaves I think as I stipulated:: class NothingNew: a = 0 def __init__(self): self.b = 1 self.initialized = True def __setattr__(self, attr, val): if not hasattr(self,'initialized') or

Re: design question: no new attributes

2007-02-27 Thread Chris Mellon
On 2/27/07, Alan Isaac <[EMAIL PROTECTED]> wrote: > "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > def __setattr__(self, attr, val): > > if hasattr(self, attr): > > self.__dict__[attr] = val > > else: > > # Tell the user off > > But then

Re: design question: no new attributes

2007-02-27 Thread Alan Isaac
"Arnaud Delobelle" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > def __setattr__(self, attr, val): > if hasattr(self, attr): > self.__dict__[attr] = val > else: > # Tell the user off But then you cannot even set attributes during initialization, right? I wan

Re: design question: no new attributes

2007-02-27 Thread Alan Isaac
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] class Difficult(object): def __setattr__(self, name, value): if self.__dict__.has_key(name): print "'%s' exists as an instance attribute" % name self.__dict__[name] = value elif

Re: design question: no new attributes

2007-02-26 Thread Ben Finney
"Alan Isaac" <[EMAIL PROTECTED]> writes: > "Ben Finney" <[EMAIL PROTECTED]> wrote: > > The Pythonic design is: don't expect to have such control over > > users of your code. > > I know this is a popular response, but the fact of the matter > remains that it can be helpful to know when someone trie

Re: design question: no new attributes

2007-02-26 Thread Arnaud Delobelle
On 27 Feb, 06:40, "Alan Isaac" <[EMAIL PROTECTED]> wrote: > So my question remains: > how best to trap any such attempt > subsequent to object initialization? > (I am willing to have properties for > all data attributes, if that helps.) > You can define the __setattr__ method in your class as def

Re: design question: no new attributes

2007-02-26 Thread Steven D'Aprano
On Tue, 27 Feb 2007 06:40:29 +, Alan Isaac wrote: > "Ben Finney" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> The Pythonic design is: don't expect to have such control over users >> of your code. > > I know this is a popular response, It's popular for good reason. > but

Re: design question: no new attributes

2007-02-26 Thread Alan Isaac
"Ben Finney" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The Pythonic design is: don't expect to have such control over users > of your code. I know this is a popular response, but the fact of the matter remains that it can be helpful to know when someone tries to set a value for

Re: design question: no new attributes

2007-02-26 Thread Ben Finney
"Alan Isaac" <[EMAIL PROTECTED]> writes: > I have a class whose instances should only receive attribute > assignments for attributes that were created at inititialization. > If slots are not appropriate, what is the Pythonic design for this? The Pythonic design is: don't expect to have such contr

Re: design question: no new attributes

2007-02-26 Thread Larry Bates
Alan Isaac wrote: > I have a class whose instances should only receive attribute > assignments for attributes that were created at inititialization. > If slots are not appropriate, what is the Pythonic design for this? > > Thanks, > Alan Isaac > > My understanding of "Pythonic design" is not to

Re: Design Question. Data Acquisition/Display related.

2005-05-17 Thread Alex Verstraeten
StepH wrote: >>a simple loop could do it >> - handle user events >> - collect data >> - update displays >> - sleep >> >> >Here i've a prob. (due to the fact that I start both with Python & >TkInter). In TkInter, you run your app by launching a mainloop() >routine, right ? So, how, in my fo

Re: Design Question. Data Acquisition/Display related.

2005-05-17 Thread StepH
Alex Verstraeten a écrit : > StepH wrote: > >> 1./ Is each "display" must responsible to acquire/read the data ? >> 2./ Or an engine collect the data then send them to each "display" ? >> >> >> > I'd keep it simple: > > - DataCollector class > asociated with one or more display instances (implem

Re: Design Question. Data Acquisition/Display related.

2005-05-17 Thread Alex Verstraeten
StepH wrote: >1./ Is each "display" must responsible to acquire/read the data ? >2./ Or an engine collect the data then send them to each "display" ? > > > I'd keep it simple: - DataCollector class asociated with one or more display instances (implemented as a list of display subscribers) it c