PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

Travis Griggs travisgriggs at gmail.com
Tue Feb 11 10:36:34 EST 2014


On Feb 10, 2014, at 10:30 PM, Steven D'Aprano <steve at pearwood.info> wrote:

>> 
>>    1. Parenthesis should not be required for parameter- less functions.
> 
> Of course they should. Firstly, parameter-less functions are a code-
> smell, and ought to be discouraged. Secondly, even if you have a good 
> reason for using one -- for example, random.random -- then the difference 
> between referring to the object and calling the object should be clear.

Interesting. Can you clarify or provide some links to the "parameter-less functions are a code-smell” bit?

I agree with your points about consistency. I disagree with the original poster that niladic functions should have a different syntax than the others. I empathize with him, I’ve made the same mistake before (being an ardent Smalltalker in the past, it’s an easy habit to have bite you). But the consistency is more important. And in python, things “happen” when parentheses appear. I just accept that.

OTOH, I’m not sure I’ve heard the parameters-less functions are a code one? Is it just loose functions that you’re referring to? As opposed to methods (which are just bound functions)? I could maybe accept that. But methods with fewer arguments, and even none, are a desirable thing. There are code smells that are the opposite in fact, methods with long parameter lists are generally seen as code smell (“passing a paragraph”).

Anyway, I’d love to understand better what you see as the code smell and why.


More information about the Python-list mailing list