Wizzard Wizzard -4 years ago 131
Python Question

Python "best formating practice" for lists, dictionary, etc

I have been looking over the Python documentation for code formatting best practice for large lists and dictionaries, for example,

something = {'foo' : 'bar', 'foo2' : 'bar2', 'foo3' : 'bar3'..... 200 chars wide, etc..}


or

something = {'foo' : 'bar',
'foo2' : 'bar2',
'foo3' : 'bar3',
...
}


or

something = {
'foo' : 'bar',
'foo2' : 'bar2',
'foo3' : 'bar3',
...
}


How do I handle deep nesting of lists/dictionaries?

Answer Source

My preferred way is:

something = {'foo': 'bar',
             'foo2': 'bar2',
             'foo3': 'bar3',
             ...
             'fooN': 'barN'}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download