1 |
On 30 May 2015 10:18, Brian Dolbec wrote: |
2 |
> On Sat, 30 May 2015 12:29:14 -0400 Mike Frysinger wrote: |
3 |
> > +from __future__ import print_function |
4 |
> |
5 |
> If I'm not mistaken, this is not needed for 2.7+ anymore. It is |
6 |
> still for 2.6 though. |
7 |
|
8 |
i believe you're mistaken :) |
9 |
$ python2.7 -c 'print "abc"' |
10 |
abc |
11 |
$ python2.7 -c 'print("abc", file=open("/dev/null", "w"))' |
12 |
File "<string>", line 1 |
13 |
print("abc", file=open("/dev/null", "w")) |
14 |
^ |
15 |
SyntaxError: invalid syntax |
16 |
|
17 |
don't be fooled by the naive case: |
18 |
$ python2.7 -c 'print("abc")' |
19 |
abc |
20 |
|
21 |
that's just parens around a string and since it's a single item, it's not a |
22 |
tuple, just a string. if you were to add more, it's more obvious: |
23 |
$ python2.7 -c 'print("abc", "ddd")' |
24 |
('abc', 'ddd') |
25 |
|
26 |
> > +def get_python_executable(ver): |
27 |
> > + """Find the right python executable for |ver|""" |
28 |
> > + if ver == 'pypy': |
29 |
> > + prog = 'pypy' |
30 |
> > + else: |
31 |
> > + prog = 'python' + ver |
32 |
> > + return os.path.join(EPREFIX, 'usr', 'bin', prog) |
33 |
> |
34 |
> |
35 |
> The only thing I don't like about this is it could mean more |
36 |
> maintenance changes in the future if others come along. |
37 |
|
38 |
to be clear: this is not new code. this is (more or less) a straight port from |
39 |
bash to python. your feedback here applies to the bash version as well. i'd |
40 |
like to minimize the changes when converting languages and then address |
41 |
feedback like this on top of that. |
42 |
|
43 |
> I think making the lists have more complete naming would be better |
44 |
> |
45 |
> PYTHON_SUPPORTED_VERSIONS = [ |
46 |
> 'python2.7', |
47 |
> 'python3.3', |
48 |
> 'python3.4', |
49 |
> ] |
50 |
> |
51 |
> # The rest are just "nice to have". |
52 |
> PYTHON_NICE_VERSIONS = [ |
53 |
> 'pypy', |
54 |
> 'python3.5', |
55 |
> 'foo-bar-7.6', |
56 |
> ] |
57 |
> |
58 |
> Then all that is needed in get_python_executable() is the final path. |
59 |
> No other future code changes are likely to be needed. |
60 |
> Also easier to override from the environment without editing code. |
61 |
|
62 |
this makes the command line interface a bit more annoying. today you can do: |
63 |
$ runtests --python-version '2.7 3.3' |
64 |
|
65 |
but with this change, it'd be: |
66 |
$ runtests --python-version 'python2.7 python3.3' |
67 |
|
68 |
we could add some logic so that if the arg is composed of dots & digits, we'd |
69 |
blindly prefix it with "python". |
70 |
-mike |