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 didn'

PTH files: Abs paths not working as expected. Symlinks needed?

2017-02-15 Thread poseidon
In /usr/lib/python3.6/site-packages I wrote a file tau4.pth. It contains the line /home/poseidon/tau4/swr/py3/src In /home/poseidon/tau4/swr/py3/src there's an __init__.py file, so it should be possible to write import tau4 in my programs. But it isn't. Despite the fact that /home/poseidon

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. Esp

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 project) with proper size

Re: PTH files: Abs paths not working as expected. Symlinks needed?

2017-02-15 Thread Wolfgang Maier
On 15.02.2017 10:33, poseidon wrote: In /usr/lib/python3.6/site-packages I wrote a file tau4.pth. It contains the line /home/poseidon/tau4/swr/py3/src In /home/poseidon/tau4/swr/py3/src there's an __init__.py file, so it should be possible to write import tau4 in my programs. No, that's no

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

Re: PTH files: Abs paths not working as expected. Symlinks needed?

2017-02-15 Thread poseidon
On 15/02/17 12:16, Wolfgang Maier wrote: On 15.02.2017 10:33, poseidon wrote: In /usr/lib/python3.6/site-packages I wrote a file tau4.pth. It contains the line /home/poseidon/tau4/swr/py3/src In /home/poseidon/tau4/swr/py3/src there's an __init__.py file, so it should be possible to write imp

Create ordering of points

2017-02-15 Thread spiess.benjamin--- via Python-list
Hello !:) I've got a problem which I would really like to solve. I got a cloud of points (in the simplest example its a 2-dimensional cloud of points). First, I want to set one of the points as the initial (or middle) point. Starting from there, the next points with the closest distance to the

Re: PTH files: Abs paths not working as expected. Symlinks needed?

2017-02-15 Thread Wolfgang Maier
On 15.02.2017 13:42, poseidon wrote: On 15/02/17 12:16, Wolfgang Maier wrote: On 15.02.2017 10:33, poseidon wrote: In /usr/lib/python3.6/site-packages I wrote a file tau4.pth. It contains the line /home/poseidon/tau4/swr/py3/src In /home/poseidon/tau4/swr/py3/src there's an __init__.py file,

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 refacto

Re: Create ordering of points

2017-02-15 Thread duncan smith
On 15/02/17 13:27, spiess.benja...@googlemail.com wrote: > Hello !:) > I've got a problem which I would really like to solve. > I got a cloud of points (in the simplest example its a 2-dimensional cloud of > points). > First, I want to set one of the points as the initial (or middle) point. > S

Re: PTH files: Abs paths not working as expected. Symlinks needed?

2017-02-15 Thread poseidon
On 15/02/17 14:34, Wolfgang Maier wrote: On 15.02.2017 13:42, poseidon wrote: On 15/02/17 12:16, Wolfgang Maier wrote: On 15.02.2017 10:33, poseidon wrote: In /usr/lib/python3.6/site-packages I wrote a file tau4.pth. It contains the line /home/poseidon/tau4/swr/py3/src In /home/poseidon/tau4

Re: PTH files: Abs paths not working as expected. Symlinks needed?

2017-02-15 Thread Steve D'Aprano
On Wed, 15 Feb 2017 11:42 pm, poseidon wrote: > Yes, removed it (symlink still there) and it still works. But then, what > are pth files for? Good question. I don't actually know anyone that uses pth files, so perhaps they're unnecessary. But the principle behind them is that they can be used

Re: Create ordering of points

2017-02-15 Thread Ben Bacarisse
spiess.benja...@googlemail.com writes: > I've got a problem which I would really like to solve. > I got a cloud of points (in the simplest example its a 2-dimensional > cloud of points). > First, I want to set one of the points as the initial (or middle) > point. Starting from there, the next poi

Re: Create ordering of points

2017-02-15 Thread Pavol Lisy
On 2/15/17, spiess.benjamin--- via Python-list wrote: > Hello !:) > I've got a problem which I would really like to solve. > I got a cloud of points (in the simplest example its a 2-dimensional cloud > of points). > First, I want to set one of the points as the initial (or middle) point. > Startin

Re: PTH files: Abs paths not working as expected. Symlinks needed?

2017-02-15 Thread gst
Le mercredi 15 février 2017 10:34:42 UTC-5, Steve D'Aprano a écrit : > On Wed, 15 Feb 2017 11:42 pm, poseidon wrote: > > > Yes, removed it (symlink still there) and it still works. But then, what > > are pth files for? > > > Good question. I don't actually know anyone that uses pth files, so pe

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 > diagnostics. That is easier to do

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 prin

Re: subprocess problem

2017-02-15 Thread Andreas Paeffgen
On 2017-02-11 02:23:12 +, Cameron Simpson said: def your_function(...): with open('/path/to/your/logfile.txt', 'a') as logfp: print("PATH=".os.environ['PATH'], file=logfp) p=Popen(...) p.communicate(...) print("p.returncode=%r" % (p.returncode)) and any

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 wrote: >

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 i

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: PTH files: Abs paths not working as expected. Symlinks needed?

2017-02-15 Thread Ned Batchelder
On Wednesday, February 15, 2017 at 8:34:45 AM UTC-5, Wolfgang Maier wrote: > On 15.02.2017 13:42, poseidon wrote: > > On 15/02/17 12:16, Wolfgang Maier wrote: > >> On 15.02.2017 10:33, poseidon wrote: > >>> In /usr/lib/python3.6/site-packages I wrote a file tau4.pth. It contains > >>> the line > >>

Crappy Python code of the day

2017-02-15 Thread Steven D'Aprano
This has been in production for months, the writer of the code has left and the new maintainer has been asked to find out why it has been crashing with UnboundLocalError: try: result = future.result() except requests.exceptions.ConnectionError as e: pass resp = self.

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 about it. -- https://mail.pytho

Re: Create ordering of points

2017-02-15 Thread Paul Rubin
spiess.benja...@googlemail.com writes: > Does somebody know a good technique for this problem? or can even give > a hint to a existing python procedure? You're asking about nearest neighbor search, which is the topic of a huge literature: https://en.wikipedia.org/wiki/Nearest_neighbor_search --

Re: Crappy Python code of the day

2017-02-15 Thread Chris Angelico
On Thu, Feb 16, 2017 at 1:25 PM, Steven D'Aprano wrote: > This has been in production for months, the writer of the code has left > and the new maintainer has been asked to find out why it has been > crashing with UnboundLocalError: > > > try: > result = future.result() > except re

Re: Crappy Python code of the day

2017-02-15 Thread Steven D'Aprano
On Thu, 16 Feb 2017 14:28:57 +1100, Chris Angelico wrote: > On Thu, Feb 16, 2017 at 1:25 PM, Steven D'Aprano > wrote: >> This has been in production for months, the writer of the code has left >> and the new maintainer has been asked to find out why it has been >> crashing with UnboundLocalError: