This should be a simple question...

andrew cooke andrew at acooke.org
Fri Mar 6 14:58:35 CET 2009


if the values are related in meaning then it seems possible that they
should be attributes on an object.  in which case you would use an
instance of the object in both cases and set the values in the objects
constructor.

if they are not related in meaning then you're not really repeating
yourself (since you may one day need to change one set, but not the other
set).

andrew


Neal Becker wrote:
> Maybe I'm missing something obvious here
>
> def A (...):
> #set a bunch of variables
>   x = 1
>   b = 2
>   ...
>
>   Do something with them
>
> def B (...):
> #set the same bunch of variables
>   x = 1
>   b = 2
>   ...
>
>   Do something with them
>
> I want to apply DRY, and extract out the common setting of these variables
> into the local scope of the functions A and B.  How to do this?  (Other
> than
> just setting them in the module scope)
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>





More information about the Python-list mailing list