function prototyping?
Burton Samograd
kruhftREMOVE at gmail.com
Thu Apr 13 14:35:38 EDT 2006
bruno at modulix <onurb at xiludom.gro> writes:
> Burton Samograd wrote:
> > Duncan Booth <duncan.booth at invalid.invalid> writes:
>
> dont use 'dict' as an identifier, it shadows the builtin dict type.
just an example i jotted down, not real code.
> > 'a': a_fun,
> > 'b': b_fun
> > }
> > --------------------------------------
> >
> > where a_fun and b_fun are in fun.py:
> >
> > -- fun.py ----------------------------
> > def a_fun(): pass
> > def b_fun(): pass
>
> Until this point, everything is (almost) fine. You'd just need to
> rewrite config.py so it imports a_fun and b_fun from fun.py:
>
> #-- config.py -------------------------
> import fun
> conf = {
> 'a': fun.a_fun,
> 'b': fun.b_fun
> }
> # --------------------------------------
>
> But then, we have this :
>
> > import config
>
> And then we have a circular import...
>
> *But* is it necessary to have the main() in the same file that defines
> a_fun and b_fun ? It's quite common (and not only in Python) to use a
> distinct file for the main(). So you can easily solve your problem by
> splitting fun.py into fun.py and main.py:
ah yes, that might be a good idea. I'm just hacking together a
prototype right now and I'm thinking in C'isms still, so maybe I'll
modularize it a bit more to see if that could solve the problem.
> > I like having the module/namespace seperation with the configuration
> > variables but I would like to make them easily (re)defined in the
> > configuration file by the user.
>
> You may want to look at one of the existing configuration modules.
I like the idea of using python as the configuration system, plus this
is giving me a good exercise with learning more of the language so I'm
going to stick with it for a bit, at least until my questions get too
annoying ;-)
> > Does python have the idea of a 'weak'
> > reference
>
> Yes, but that's something totally different.
Care to describe?
--
burton samograd kruhft .at. gmail
kruhft.blogspot.com www.myspace.com/kruhft metashell.blogspot.com
More information about the Python-list
mailing list