Re: WANT: bad code in python (for refactoring example)

2017-02-19 Thread Dotan Cohen
There are some nice changes in here. You can mention to the students that I really appreciated the work done on the menu loop. You took an example of code that had grown piecemeal and become reasonably unmaintainable, and refactored it to be very maintainable in the future. Good luck to all class

Re: WANT: bad code in python (for refactoring example)

2017-02-17 Thread Makoto Kuwata
On Thu, Feb 16, 2017 at 6:34 AM, Dotan Cohen wrote: > I think that we can help each other! This is my own code, back when I > was writing Python like PHP: > https://github.com/dotancohen/burton Year, this is a good example code for me to do refactoring. I created a pull

Re: WANT: bad code in python (for refactoring example)

2017-02-17 Thread Jussi Piitulainen
Makoto Kuwata writes: > On Thu, Feb 16, 2017 at 6:53 AM, Erik wrote: >> >> (Python code examples of what you think is "bad" vs "good" would be >> useful). > > You are right. > > Bad code Example: > > # >

Re: WANT: bad code in python (for refactoring example)

2017-02-16 Thread Makoto Kuwata
Thanks Erik, On Thu, Feb 16, 2017 at 6:53 AM, Erik wrote: > (which is what I think you mean by "proper size") > As I explained at my first post, I'm teaching Python to novice programmers. Therefore refactoring example code should be in the size what they can

Re: WANT: bad code in python (for refactoring example)

2017-02-16 Thread alister
On Thu, 16 Feb 2017 12:00:36 +0100, Cecil Westerhof wrote: > On Thursday 16 Feb 2017 10:43 CET, alister wrote: > >> On Wed, 15 Feb 2017 19:08:59 -0800, Paul Rubin wrote: >> >>> Antoon Pardon writes: On reason to use this is for some easy "logging" >>> >>> I

Re: WANT: bad code in python (for refactoring example)

2017-02-16 Thread Cecil Westerhof
On Thursday 16 Feb 2017 10:43 CET, alister wrote: > On Wed, 15 Feb 2017 19:08:59 -0800, Paul Rubin wrote: > >> Antoon Pardon writes: >>> On reason to use this is for some easy "logging" >> >> I think it's better to use the actual logging module. I generally >> start

Re: WANT: bad code in python (for refactoring example)

2017-02-16 Thread alister
On Wed, 15 Feb 2017 19:08:59 -0800, Paul Rubin wrote: > Antoon Pardon writes: >> On reason to use this is for some easy "logging" > > I think it's better to use the actual logging module. I generally start > a new program with print statements but convert them to

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Paul Rubin
Antoon Pardon writes: > On reason to use this is for some easy "logging" I think it's better to use the actual logging module. I generally start a new program with print statements but convert them to logging after there's enough code to want to be more organized

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Erik
On 15/02/17 21:53, Erik wrote: process(data) Before I get jumped on by a pack of rabid wolves, I of course meant: process(d) E. -- https://mail.python.org/mailman/listinfo/python-list

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Erik
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

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Dotan Cohen
I think that we can help each other! This is my own code, back when I was writing Python like PHP: https://github.com/dotancohen/burton It is badly in need of a Pythonic refactor! Have at it, and I'll be happy to accept any pull requests. On Wed, Feb 15, 2017 at 12:44 AM, Makoto Kuwata

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread jladasky
On Wednesday, February 15, 2017 at 2:52:55 AM UTC-8, Antoon Pardon wrote: > Op 15-02-17 om 07:28 schreef Steven D'Aprano: > > E.g. http://code.activestate.com/recipes/580750 > > > > does nothing more that define > > > > echo = sys.stdout.write > > > > Why not use sys.stdout.write directly? Or

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Chris Angelico
On Thu, Feb 16, 2017 at 12:37 AM, Antoon Pardon wrote: >> But a better way, in my opinion, is to >> use your editor to search for: >> >> print( >> >> and replace with: >> >> #print( > > You don't seem to understand, I don't want to disable all printing, only the >

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Antoon Pardon
Op 15-02-17 om 13:24 schreef Steve D'Aprano: > On Wed, 15 Feb 2017 09:49 pm, Antoon Pardon wrote: > >> Op 15-02-17 om 07:28 schreef Steven D'Aprano: > [...] >>> Why not use sys.stdout.write directly? Or print? If I saw somebody using >>> this recipe in production code, in the way shown, I'd

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Steve D'Aprano
On Wed, 15 Feb 2017 09:49 pm, Antoon Pardon wrote: > Op 15-02-17 om 07:28 schreef Steven D'Aprano: [...] >> Why not use sys.stdout.write directly? Or print? If I saw somebody using >> this recipe in production code, in the way shown, I'd refactor it to just >> use print. There's no advantage to

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread David Palao
2017-02-15 10:36 GMT+01:00 Makoto Kuwata : > Thanks Irmen and Steven, > > I'm sorry that my explanation is not enough. > I'm looking for bad python code, not refactoring examples. > I can do (and want to do) refactor bad code by myself. > > Is there any bad python code (or

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Antoon Pardon
Op 15-02-17 om 07:28 schreef Steven D'Aprano: > On Wed, 15 Feb 2017 07:44:03 +0900, Makoto Kuwata wrote: > >> Hi, >> >> Is there any *just right* python code to refactor? >> In other words, I'm finding bad code example in python. > > Try looking at the ActiveState website for recipes in Python.

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Makoto Kuwata
Thanks Irmen and Steven, I'm sorry that my explanation is not enough. I'm looking for bad python code, not refactoring examples. I can do (and want to do) refactor bad code by myself. Is there any bad python code (or project) with proper size? # I found a lot of bad PHP code in github, but

Re: WANT: bad code in python (for refactoring example)

2017-02-14 Thread Steven D'Aprano
On Wed, 15 Feb 2017 07:44:03 +0900, Makoto Kuwata wrote: > Hi, > > Is there any *just right* python code to refactor? > In other words, I'm finding bad code example in python. Try looking at the ActiveState website for recipes in Python. Especially look at the ones with negative ratings, but

Re: WANT: bad code in python (for refactoring example)

2017-02-14 Thread Irmen de Jong
On 14-2-2017 23:44, Makoto Kuwata wrote: > Hi, > > Is there any *just right* python code to refactor? > In other words, I'm finding bad code example in python. > > (background) > I'm teaching Python to some novice programmer, and > want to show refactoring example to them. > > (required) > *