From: Fernando P. <Fer...@co...> - 2005-05-18 16:38:14
|
John Hunter wrote: >>>>>>"Tim" == Tim Leslie <ti...@cs...> writes: > > >> I'm wondering if set is now a bad name for pylab to be using? > > Tim> +1 for changing it. > > Tim> I've also had this issue bite me when I was hacking together > Tim> some code and wanted to use a python set. I'd be in favour of > Tim> changing the pylab set to be called something else, although > Tim> I don't have any good suggestions about what to change it > Tim> to... > > Ouch, I hadn't thought of this. In the past, consensus has been that > pylab should not override built-ins, eg the previous discussion on > min/max which led us to rename these functions to amin/amax. Changing > set, unfortunately, will break a lot of scripts. I think the best > plan of action is to define a new function pset or setp (setp for "set > property") which has the functionality of the old, and keep set around > for a release or two issuing a warning with a line number so people > can get their existing scripts cleaned up. I'd also suggest removing from all example code 'from pylab import *' statements. Frankly, after a while I've completely stopped using 'from foo import *' in _any_ code I write, even small scripts. All I use these days is code like: import Numeric as N import scipy as S import pylab as P The only place where I think that from-import-* is OK is at an interactive prompt, where you are just doing experiments and not writing reusable code. Since the examples tend to be the place that people learn from, I think it would be a good idea to encourage safer practices by banning the dangerous import-* idiom from there. Just my opinion. Best, f |