newbie question

Albert Hopkins marduk at letterboxes.org
Wed Nov 26 14:21:44 EST 2008


On Wed, 2008-11-26 at 11:11 -0800, Nan wrote:
> Hello,
>    I just started to use Python. I wrote the following code and
> expected 'main' would be called.
> 
> def main():
>   print "hello"
> 
> main
> 
> But I was wrong. I have to use 'main()' to invoke main. The python
> interpreter does not give any warnings for the above code. Is there
> any way/tool to easily detect this kind of errors ?
> 

Syntactically your code is correct, so the interpreter just goes about
its business.  You can usually use tools such as pylint or pychecker to
find find such issues. For example, pylint reports (among other things):

W:  4: Statement seems to have no effect





More information about the Python-list mailing list