Skip to content

Tag: coding-style

How to copy a dict and modify it in one line of code

Very often I need to create dicts that differ one from another by an item or two. Here is what I usually do: The fact that there is a point in the program at which setup2 is an identical copy of setup1 makes me nervous, as I’m afraid that at some point of the program life the two lines might

How to break a line of chained methods in Python?

I have a line of the following code (don’t blame for naming conventions, they are not mine): I don’t like how it looks like (not too readable) but I don’t have any better idea to limit lines to 79 characters in this situation. Is there a better way of breaking it (preferably without backslas…