From: Norm P. <nj...@nj...> - 2004-09-16 17:27:02
|
+1 for "explicit is better" (the suggested change is fine, and as a complete pytables newbie, I don't have any affected production code) Thanks for making just the tool I need right now to manage a lot of industrial real-time data. Nice work! ----- Original Message ----- From: "Francesc Alted" <fa...@py...> To: <pyt...@li...> Sent: Thursday, September 16, 2004 12:47 PM Subject: [Pytables-users] Special __call__ method in PyTables objects > Dear PyTables users, > > I'm pondering to disable most of __call__() methods is PyTables objects > because of two things: > > 1.- ipython (http://ipython.scipy.org/), which is a very good shell for > Python adds by default the parenthesis '()' if you type just a name at the > prompt and nothing more. Example: > > In [7]: float > ------> float() > Out[7]: 0.0 > > This is considered a good thing for most uses. Unfortunately, PyTables is > designed to make use of bare object names to print a description of the > object. That is, in the standard python console: > > >>> f.root.small > /small (Group) 'small Group' > children := ['create_worst' (Table), 'search_best' (Group), 'search_worst' (Group), 'create_best' (Table)] > > but the same in ipython gives: > > In [9]: f.root.small > ------> f.root.small() > Out[9]: <generator object at 0x415d490c> > > which is not was the user intended usually. > > 2.- More importantly, in my struggle to make interactive work with pytables > easy, I'm afraid that I've abused a bit of the __call__ method, in most > cases being introduced as a shortcut basically. For example, this is a > typical use: > > >>> names=[ x['name'] for x in table(start=2, stop=1000) if x['TDCcount']>3] > > which is the same as: > > >>> names=[ x['name'] for x in table.iterrows(start=2, stop=1000) if x['TDCcount']>3] > > As I see it now, I find the second version much more clear, and although it > is a bit more expensive to type, if we follow the mantra "explicit is better > than implicit" I definitely think that the second is the way to go. > > So, these are the reasons why I'm planning to remove most of the __call__() > methods and, if necessary, replace them by acurate method names. Although I > think this is a good thing (TM), this may pose problems of backward > compatibility with existing programs, and this is why I'm asking here. > > What do you think? You would like the change? That might cause problems with > your programs? Do you have a better alternative? > > Cheers, > > -- > Francesc Alted > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 > Project Admins to receive an Apple iPod Mini FREE for your judgement on > who ports your project to Linux PPC the best. Sponsored by IBM. > Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php > _______________________________________________ > Pytables-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pytables-users > |