Re: [Hampshire] Python GUI

Top Page

Reply to this message
Author: Vic
Date:  
To: hampshire
Subject: Re: [Hampshire] Python GUI

> One thing I don't like about Python is one of the things so many others
> seem to like. Blocks defined solely by indent. It sounds reasonable
> enough, but you have only inadvertently to indent some code one
> character too few to totally break a program. I like unambiguous
> blocks.


I'm with you on that, but IMO it is far from the worst thing in Python.
Here's my favourite :-

def foo(newthing, allthings=[]):
    allthings.append(newthing)
    print allthings


Now try the following in order :-

foo("herring", ["knights", "shrubbery"])
foo("holy grail")
foo("herring", ["knights", "shrubbery"])
foo("holy grail")

The results are as follows :-

['knights', 'shrubbery', 'herring']
['holy grail']
['knights', 'shrubbery', 'herring']
['holy grail', 'holy grail']

I consider this to be a language bug, but the language designers see it as
appropriate behaviour :-)

Vic.


--
Please post to: Hampshire@???
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--------------------------------------------------------------