WANT: bad code in python (for refactoring example)

Erik python at lucidity.plus.com
Wed Feb 15 16:53:33 EST 2017


Hi,

On 15/02/17 09:36, Makoto Kuwata wrote:
> I'm sorry that my explanation is not enough.
> I'm looking for bad python code, not refactoring examples.

I think you need to explain what you mean by "bad". Do you mean 
something like:

i = 0
data = ["bad", "example", "of", "python", "code"]
while i < len(data):
     process(data[i])
     i = i + 1

... which could be better expressed as:

data = ["good", "example", "of", "python", "code"]
for d in data:
     process(data)

?

If so, then you're asking for "unpythonic" code examples (code that is 
written in the style of a different language that doesn't have some of 
Python's syntactic sugar and underlying mechanisms).

I suspect that you can find many short examples like the above on sites 
like StackOverflow, but finding a substantial code-base example (which 
is what I think you mean by "proper size") is unlikely, as anyone 
writing a large project in Python is almost certainly going to have 
learned and adopted the "pythonic" idioms long before their project 
became as large as you appear to be asking for.

If you _don't_ mean what I suggested above, please explain further 
(Python code examples of what you think is "bad" vs "good" would be useful).

E.



More information about the Python-list mailing list