[Tutor] namespaces and global
ljmamoreira at gmail.com
Thu Oct 15 00:24:22 CEST 2009
Alan, Kent, hello!
Thanks for your help. As for your "curiosity", I'm teaching elementary physics
to undergraduates in computer engineering. Trying to speak my students'
language, I wanted to show them simple applications that compute numerical
values for the kinematics formulas of uniformly accelerated motion (the weaker
students call these formulas Chinese gibberish).
What I had in mind was to have a module define vectors and vector algebra
operations using a simple class definition, and another with kinematics
formulas, like (for uniformly accelerated motion)
Here r0 (initial position) v0 (initial velocity) and a (acceleration) are
global vector parameters which I'd define in an interactive session with the
students, but I'd rather not include them in the formal parameter list of
function pos, just because they aren't usually displayed as such in physical
formulae. I'd like to keep the look and feel of those formulas in the
interactive python session, without having to type the function definitions in
that session, but rather import them from a pre-prepared module file.
Anyway, thanks again!
On Wednesday 14 October 2009 06:18:28 pm Alan Gauld wrote:
> "Jose Amoreira" <ljmamoreira at gmail.com> wrote
> > Of course I could redefine my module function, including the parameter a
> > in
> > the list of arguments, but I'd rather not.
> Why not? That would be good computer science practice and the
> most reliable way to do it. Why do you not want to go down that
> route? Is there a specific reason to use a global variable when
> use of globals is normally considered bad practice?
> I'm curious?
More information about the Tutor