Better writing in python

Alexandre Badez alexandre.badez at gmail.com
Wed Oct 24 22:09:27 CEST 2007


On Oct 24, 3:46 pm, Duncan Booth <duncan.bo... at invalid.invalid> wrote:
> For a 'python like' look lose the Hungarian notation (even Microsoft
> have largely stopped using it)

I wish I could.
But my corporation do not want to apply python.org coding rules

> increase the indentation to 4 spaces,

Well, it is in my python file.
I do not do it here, because I'm a bit lazy.

> and also get rid of the spurious parentheses around the result.

Thanks

> Otherwise it is fine: clear and to the point.

Thanks

>
> If you really wanted you could write something like:
>
> m, o = [], []
> for arg in cls.dArguments:
>     (m if cls.dArguments[arg]['mandatory'] else o).append(arg)
> return m, o
>
> Or even:
> m, o = [], []
> action = [o.append, m.append]
> for arg in cls.dArguments:
>     action[bool(cls.dArguments[arg]['mandatory'])](arg)
> return m, o
>
> but it just makes the code less clear, so why bother?

And finally thanks again ;)




More information about the Python-list mailing list