where is best place for import statements?
Graham Ashton
gashton at cmedltd.com
Sun Oct 26 06:26:40 EST 2003
On Thu, 23 Oct 2003 21:27:37 +0200, Peter Otten wrote:
> Literal answer: put
>
> from math import *
>
> into myshapes.py, and access variables and functions like so:
> import myshapes
> myshapes.pi
> myshapes.sin(alpha)
Why on earth would you want to do that? If somebody wants to get the
value of PI why would you want them to use anything other than math.pi
directly? I realise you might be using this as an example of what you
*could* do, but I don't think it's good practice.
If I was reading code and saw myshapes.sin, and I new that math.sin
existed (which I do as it's in the standard library), I would
naturally assume that it was either an alternative implementation
(which I wouldn't trust), or that it did something else entirely.
More information about the Python-list
mailing list