+ 1
Would you approve complex oneliner in commercial code?
By 'complex' I mean one which consists of a short, readable shortcut code, enriched with some crazy stuff in the same line. A famous example: ```python n = 100 print sorted(set(range(2,n+1)).difference(set((p * f) for p in range(2,int(n**0.5) + 2) for f in range(2,(n/p)+1)))) ``` Snippets like this will certainly gain upvotes in communities like Sololearn. They are also safe to use in your own code. But I saw negative reactions from people working in the same project, mostly about 'reduced readability', not to mention 'WTF?!' when an urgent fix involves at least understanding such code.
2 Antworten
+ 4
It's not just for python, whenever you work in a team, and on a big project, you have to make codes which other people can understand, and follow up with your work, and it's not just onliner an issue, bad commenting, no proper naming convention, and more would result in delay in submission and ugly codes, and lot off issues would be there at the time of maintenance
One-liners and quick small and random naming convention works well while doing competitive coding
+ 1
One letter variables,
#this is for loop --style comments,
Repeating same part of code instead of using functions,
Bad practice. But, one-line maybe over fancy style imho