Classes as namespaces?
lie.1296 at gmail.com
Tue Mar 30 13:39:41 CEST 2010
On 03/27/2010 10:28 PM, Jonathan Hartley wrote:
> one might like to name the complex block of logic, just to make it
> x = 1
> def account_for_non_square_pixels(x):
> ((some complex logic))
> y = 2
> But defining and then calling the function like that is a tad
> cumbersome. So I was wondering about:
I never liked the narrow definition of function as "reusable piece of
code". This narrow definition implies that a piece of code used only
once do not need to be made a function.
I would rather define function as "a logically independent piece of
code" and encourage refactorizing code into functions even if they are
only used once as long as they are conceptually a "step" and being able
to reuse code as a nice side-effect of it.
Under this definition, the "some complex logic" conceptually is an
independent piece of code that can (and probably should) be factorized.
More information about the Python-list