[Tutor] New to Python - print function - invalid syntax

2014-08-04 Thread Greg Markham
Hello,

I'm extremely new to Python having only just started learning this week.
I'm slowly plodding through a book, Python Programming for the Absolute
Beginner, 3rd ed

by Michael Dawson.

Code is provided for all the scripts found throughout the book (found here
),
but I'm running into a syntax error when running one of the unmodified
programs.  On line 14, which reads:

*print("Here", end=" ")*

I'm receiving a *syntax error* which points to the *end *parameter.  In
order to confirm this, I modified the code to read:

*print("Here ")*

...which runs without incident.  My best guess is that there's a minor
difference between the version of Python I'm using (3.4.1) and that which
was in use at the time the book was written (3.1.x) that is responsible for
this error.

Thanks and my apologies for the "greenness" of this question.

Sincerely,

Greg
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python - print function - invalid syntax

2014-08-04 Thread Joel Goldstick
On Mon, Aug 4, 2014 at 1:28 PM, Greg Markham  wrote:
> Hello,
>
> I'm extremely new to Python having only just started learning this week.
> I'm slowly plodding through a book, Python Programming for the Absolute
> Beginner, 3rd ed by Michael Dawson.
>
> Code is provided for all the scripts found throughout the book (found here),
> but I'm running into a syntax error when running one of the unmodified
> programs.  On line 14, which reads:
>
> print("Here", end=" ")
>
> I'm receiving a syntax error which points to the end parameter.  In order to
> confirm this, I modified the code to read:
>
> print("Here ")
>
> ...which runs without incident.  My best guess is that there's a minor
> difference between the version of Python I'm using (3.4.1) and that which
> was in use at the time the book was written (3.1.x) that is responsible for
> this error.

Welcome to the group.  I think you made a typo.  Your code should run.
I just tried this:
>>> print("hi", end=" ")
hi >>>

A couple of things that will make it easier to help:

1. send mail as plain text.  Rich text causes some readers problems
2. copy and paste the code and complete traceback.  retyping things
make it more likely that what is in your code isn't exactly what you
typed

>
> Thanks and my apologies for the "greenness" of this question.

No apologies necessary -- ask away
>
> Sincerely,
>
> Greg
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>



-- 
Joel Goldstick
http://joelgoldstick.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python - print function - invalid syntax

2014-08-04 Thread Danny Yoo
> > but I'm running into a syntax error when running one of the unmodified
> > programs.  On line 14, which reads:
> >
> > print("Here", end=" ")
> >
> > I'm receiving a syntax error which points to the end parameter.

I'd like to also support Joel's suggestion to provide detailed output of
the error message.  It will help.

> > difference between the version of Python I'm using (3.4.1) and that
which
> > was in use at the time the book was written (3.1.x) that is responsible
for
> > this error.

Just to double check: how are you confirming what version of Python you're
using?

Best of wishes!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python - print function - invalid syntax

2014-08-04 Thread Cameron Simpson

On 04Aug2014 13:38, Danny Yoo  wrote:

> difference between the version of Python I'm using (3.4.1) and that which
> was in use at the time the book was written (3.1.x) that is responsible
> for this error.


Just to double check: how are you confirming what version of Python you're
using?


In particular, Python 2 will produce a syntax error for your print statement; 
Python 3 should work.


Show a short transcript which also shows your ptyhon version.

Example:

$ python
Python 2.7.8 (default, Jul 13 2014, 17:11:32)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hi", end=" ")
  File "", line 1
print("hi", end=" ")
   ^
SyntaxError: invalid syntax

Versus:

$ python3.4
Python 3.4.1 (default, May 21 2014, 01:39:38)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hi", end=" ")
hi >>>

The "$" is my prompt.

Any Python 3 should accept your print() call.

The default system "python" on most platforms is still Python 2; that may be 
misleading you. In particular, if you're running a script you may need to 
ensure it is run with the correct Python version.


It is perfectly fine to have multiple Python versions installed, BTW. Just make 
sure you're using what you intend.


Cheers,
Cameron Simpson 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python - print function - invalid syntax

2014-08-04 Thread Greg Markham
On Mon, Aug 4, 2014 at 12:37 PM, Alex Kleider  wrote:

> On 2014-08-04 10:28, Greg Markham wrote:
>
>> Hello,
>>
>> I'm extremely new to Python having only just started learning this week.
>> I'm slowly plodding through a book, Python Programming for the Absolute
>> Beginner, 3rd ed
>> > Edition/dp/1435455002/ref=sr_1_5?ie=UTF8&qid=1407049249&sr=
>> 8-5&keywords=learning+python>
>>
>> by Michael Dawson.
>>
>> Code is provided for all the scripts found throughout the book (found here
>> > 1435455002/downloads/py3e_source.zip>),
>>
>> but I'm running into a syntax error when running one of the unmodified
>> programs.  On line 14, which reads:
>>
>> *print("Here", end=" ")*
>>
> try
>
> print("Here", end="")
>
> (no space between the quotes)
> The end parameter defaults to newline.
> If you change it to the empty string, there'll be no output of a newline
> character.
>

As I understand it, newline is inferred unless the "end" parameter is
used.  This program is designed merely to illustrate the flexibility of the
print function.  As you'll see below, the output from the line in which I
was receiving an error is intended to read as, "Here it is..."  For
clarity, the full program reads as follows:


# Game Over - Version 2
# Demonstrates the use of quotes in strings
# Python Programming for the Absolute Beginner, 3rd ed - Ch 2
# Greg Markham - Aug 04, 2014

print("Program 'Game Over' 2.0")

print("Same", "message", "as before")

print("Just",
  "a bit",
  "bigger")

print("Here", end=" ")
print("it is...")

print(
"""
 _   ___   ___  ___   _
/  ___| /   | /   |/   | |  ___|
| |/ /| |/ /|   /| | | |__
| |  _/ ___ |   / / |__/ | | |  __|
| |_| |  / /  | |  / /   | | | |___
\_/ /_/   |_| /_/|_| |_|

 _   _ _   _   _
/  _  \ | |   / / |  ___| |  _  \
| | | | | |  / /  | |__   | |_| |
| | | | | | / /   |  __|  |  _  /
| |_| | | |/ /| |___  | | \ \
\_/ |___/ |_| |_|  \_\

"""
 )

input("\n\nPress the enter key to exit.")
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python - print function - invalid syntax

2014-08-04 Thread Greg Markham
On Mon, Aug 4, 2014 at 11:52 AM, Joel Goldstick 
wrote:

> On Mon, Aug 4, 2014 at 1:28 PM, Greg Markham 
> wrote:
> > Hello,
> >
> > I'm extremely new to Python having only just started learning this week.
> > I'm slowly plodding through a book, Python Programming for the Absolute
> > Beginner, 3rd ed by Michael Dawson.
> >
> > Code is provided for all the scripts found throughout the book (found
> here),
> > but I'm running into a syntax error when running one of the unmodified
> > programs.  On line 14, which reads:
> >
> > print("Here", end=" ")
> >
> > I'm receiving a syntax error which points to the end parameter.  In
> order to
> > confirm this, I modified the code to read:
> >
> > print("Here ")
> >
> > ...which runs without incident.  My best guess is that there's a minor
> > difference between the version of Python I'm using (3.4.1) and that which
> > was in use at the time the book was written (3.1.x) that is responsible
> for
> > this error.
>
> Welcome to the group.  I think you made a typo.  Your code should run.
> I just tried this:
> >>> print("hi", end=" ")
> hi >>>
>

 Ok, when I try this from the Shell window, it works.  When executing the
full program from command line, it does not.  Python versions from both
shell and command line are 3.4.1 (confirmed via command: "python -V").

Full error msg output when run from cmd line reads:

  File "I:\Programming\Scripts\Learning\chapter02\game_over2.py", line 14
print("Here", end=" ")
 ^
SyntaxError: invalid syntax

A couple of things that will make it easier to help:
>
> 1. send mail as plain text.  Rich text causes some readers problems
>

Thanks for the tip.  I'll keep this in mind for future queries & replies.


> 2. copy and paste the code and complete traceback.  retyping things
> make it more likely that what is in your code isn't exactly what you
> typed
>

Apologies, but what is a traceback?  Is this a debugging feature found in
the shell?  (I looked, but didn't see it)

Thanks,

Greg
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python - print function - invalid syntax

2014-08-04 Thread Alan Gauld

On 05/08/14 00:21, Greg Markham wrote:


but I'm running into a syntax error


As others have said you are getting the expected error when running 
Python v3 code under Python v2.


How exactly are you running the program? It looks like somehow you
are picking up Python v2 when you run the script even though your python 
-V is showing v3.


BTW. Which OS are you using? It shouldn't affect the cause but
it helps with the debugging!


For clarity, the full program reads as follows:


# Game Over - Version 2
# Demonstrates the use of quotes in strings
# Python Programming for the Absolute Beginner, 3rd ed - Ch 2
# Greg Markham - Aug 04, 2014

print("Program 'Game Over' 2.0")

print("Same", "message", "as before")

print("Just",
   "a bit",
   "bigger")


Does all of the above print out correctly? Can you send
us a cut n paste of the exact output of the program?




print("Here", end=" ")
print("it is...")

print(
 """
  _   ___   ___  ___   _
 /  ___| /   | /   |/   | |  ___|
 | |/ /| |/ /|   /| | | |__
 | |  _/ ___ |   / / |__/ | | |  __|
 | |_| |  / /  | |  / /   | | | |___
 \_/ /_/   |_| /_/|_| |_|

  _   _ _   _   _
 /  _  \ | |   / / |  ___| |  _  \
 | | | | | |  / /  | |__   | |_| |
 | | | | | | / /   |  __|  |  _  /
 | |_| | | |/ /| |___  | | \ \
 \_/ |___/ |_| |_|  \_\

 """
  )

input("\n\nPress the enter key to exit.")


finally you could try putting the following at the very top of your program:

import sys
print(sys.version)

That will definitively prove that you are actually
running v3 on the file...

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python - print function - invalid syntax

2014-08-04 Thread Steven D'Aprano
On Mon, Aug 04, 2014 at 04:44:46PM -0700, Greg Markham wrote:

>  Ok, when I try this from the Shell window, it works.  When executing the
> full program from command line, it does not.  Python versions from both
> shell and command line are 3.4.1 (confirmed via command: "python -V").

I'm a little confused, because I consider "the shell" and "command line" 
to more or less be synonymous. Perhaps if you explain step-by-step what 
you do. Here's my guess of what you mean by "command line":

Click on Start Menu.
Choose "Run" command.
Enter "cmd.exe"
Enter "python I:\Programming\Scripts\Learning\chapter02\game_over2.py"

Am I close?

> Full error msg output when run from cmd line reads:
> 
>   File "I:\Programming\Scripts\Learning\chapter02\game_over2.py", line 14
> print("Here", end=" ")
>  ^
> SyntaxError: invalid syntax

That definitely looks like a Python 2 error, but it should work in any 
version of Python 3. This is a most perplexing error, I can only imagine 
that you have both Python 2 and 3 installed and somehow, for some 
unknown reason, you're sometimes getting one and sometimes getting the 
other.


> > 2. copy and paste the code and complete traceback.  retyping things
> > make it more likely that what is in your code isn't exactly what you
> > typed
> >
> 
> Apologies, but what is a traceback?  Is this a debugging feature found in
> the shell?  (I looked, but didn't see it)

A traceback is the text Python prints when an error occurs. It normally 
starts with the word "Traceback" and ends with the kind of error 
(SyntaxError, NameError, ImportError, etc.) and usually an error 
message. For example:

Traceback (most recent call last):
  File "", line 1, in 
  File "", line 2, in function
TypeError: object of type 'int' has no len()

or similar. The details will differ slightly (e.g. sometimes Python can 
print the offending lines of code) but the important thing is that there 
is a lot of useful information available in the traceback, if you show 
us the entire thing, from start to finish.

SyntaxError is quite exceptional, in that it normally doesn't start with 
the word "Traceback", for technical reasons[1]. Technically, I suppose, 
it's not really a traceback, but we tend to call it such regardless.






[1] SyntaxError normally occurs at compile-time, while Python is parsing 
the source code, and before execution starts, so there's no chain of 
calling functions and no traceback. But we normally don't care about the 
technical details.


-- 
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python - print function - invalid syntax

2014-08-05 Thread Greg Markham
On Mon, Aug 4, 2014 at 5:13 PM, Alan Gauld 
wrote:

> On 05/08/14 00:21, Greg Markham wrote:
>
>  but I'm running into a syntax error
>>
>
> As others have said you are getting the expected error when running Python
> v3 code under Python v2.
>
> How exactly are you running the program? It looks like somehow you
> are picking up Python v2 when you run the script even though your python
> -V is showing v3.
>
> BTW. Which OS are you using? It shouldn't affect the cause but
> it helps with the debugging!
>
>
>  For clarity, the full program reads as follows:
>>
>>
>> # Game Over - Version 2
>> # Demonstrates the use of quotes in strings
>> # Python Programming for the Absolute Beginner, 3rd ed - Ch 2
>> # Greg Markham - Aug 04, 2014
>>
>> print("Program 'Game Over' 2.0")
>>
>> print("Same", "message", "as before")
>>
>> print("Just",
>>"a bit",
>>"bigger")
>>
>
> Does all of the above print out correctly? Can you send
> us a cut n paste of the exact output of the program?
>
>
>
>> print("Here", end=" ")
>> print("it is...")
>>
>> print(
>>  """
>>   _   ___   ___  ___   _
>>  /  ___| /   | /   |/   | |  ___|
>>  | |/ /| |/ /|   /| | | |__
>>  | |  _/ ___ |   / / |__/ | | |  __|
>>  | |_| |  / /  | |  / /   | | | |___
>>  \_/ /_/   |_| /_/|_| |_|
>>
>>   _   _ _   _   _
>>  /  _  \ | |   / / |  ___| |  _  \
>>  | | | | | |  / /  | |__   | |_| |
>>  | | | | | | / /   |  __|  |  _  /
>>  | |_| | | |/ /| |___  | | \ \
>>  \_/ |___/ |_| |_|  \_\
>>
>>  """
>>   )
>>
>> input("\n\nPress the enter key to exit.")
>>
>
> finally you could try putting the following at the very top of your
> program:
>
> import sys
> print(sys.version)
>
> That will definitively prove that you are actually
> running v3 on the file...


Aaaah, brilliant!  You were right!

I:\Programming\Scripts\Learning\chapter02>game_over2.py
2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)]

I installed ver 2.7.8 initially then some time later installed ver 3.4.1
upon starting the above mentioned book which uses that version.  I thought
I had handled the problem by renaming the executables to python27.exe and
pythonw27.exe as well as modifying the path statement to point to where the
latest version was installed, but that appears not to have been enough.  To
avoid further confusion, I'm uninstalling both versions and reinstalling
the latest now so as to reset the file associations which have become a
little out of sorts from all my tampering.

Thanks for helping me get to the heart of it!

--Greg
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python - print function - invalid syntax

2014-08-05 Thread Greg Markham
On Mon, Aug 4, 2014 at 7:38 PM, Steven D'Aprano  wrote:

> On Mon, Aug 04, 2014 at 04:44:46PM -0700, Greg Markham wrote:
>
> >  Ok, when I try this from the Shell window, it works.  When executing the
> > full program from command line, it does not.  Python versions from both
> > shell and command line are 3.4.1 (confirmed via command: "python -V").
>
> I'm a little confused, because I consider "the shell" and "command line"
> to more or less be synonymous. Perhaps if you explain step-by-step what
> you do. Here's my guess of what you mean by "command line":
>
> Click on Start Menu.
> Choose "Run" command.
> Enter "cmd.exe"
> Enter "python I:\Programming\Scripts\Learning\chapter02\game_over2.py"
>
> Am I close?
>

For cmd line, yes that's basically it.  When I say "shell", I'm referring
to the Python IDLE GUI.


>
> > Full error msg output when run from cmd line reads:
> >
> >   File "I:\Programming\Scripts\Learning\chapter02\game_over2.py", line 14
> > print("Here", end=" ")
> >  ^
> > SyntaxError: invalid syntax
>
> That definitely looks like a Python 2 error, but it should work in any
> version of Python 3. This is a most perplexing error, I can only imagine
> that you have both Python 2 and 3 installed and somehow, for some
> unknown reason, you're sometimes getting one and sometimes getting the
> other.
>

That's correct, I did have two versions installed.  I first installed ver
2.7, then later installed ver 3.4 when I began going through the lessons in
the aforementioned book.  Although I'd taken steps to ensure the latest
version was used, I was apparently not thorough enough as when I inserted
some code in the program that revealed the version being used, it stated
2.7.4.  So, I ended up uninstalling both versions, then reinstalling ver
3.4 which reset the file associations and resolved the issue.

Hopefully any further issues I encounter aren't due to misconfigurations
and the like.

Thanks for your help, Steven.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python - print function - invalid syntax

2014-08-05 Thread Maxime Steisel
Le 2014-08-05 02:07, "Greg Markham"  a écrit:
>  Ok, when I try this from the Shell window, it works.  When executing the
full program from command line, it does not.  Python versions from both
shell and command line are 3.4.1 (confirmed via command: "python -V").
>
> Full error msg output when run from cmd line reads:
>
>   File "I:\Programming\Scripts\Learning\chapter02\game_over2.py", line 14
>
> print("Here", end=" ")
>  ^
> SyntaxError: invalid syntax
>

That definitely show that python2 is running.

I think this is because on windows, *.py files are associated with py.exe
that choose the python version depending on the first line of your file.
Putting #!python3 on the first line of game_over2.py should solve it.

See PEP 397 [1] for more details about this feature.

[1] http://legacy.python.org/dev/peps/pep-0397/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python - print function - invalid syntax

2014-08-05 Thread Ben Finney
Greg Markham  writes:

> For cmd line, yes that's basically it. When I say "shell", I'm
> referring to the Python IDLE GUI.

For future reference: the operating system shell presents a command
line. The Python shell presents a command line. So “shell” and “command
line” don't distinguish between those.

You might better use the terms “operating system shell” (“OS shell”) and
“Python shell”.

Hope that helps.

-- 
 \   “Never express yourself more clearly than you are able to |
  `\   think.” —Niels Bohr |
_o__)  |
Ben Finney

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python - print function - invalid syntax

2014-08-05 Thread Marc Tompkins
On Tue, Aug 5, 2014 at 12:48 AM, Maxime Steisel  wrote:
> I think this is because on windows, *.py files are associated with py.exe
> that choose the python version depending on the first line of your file.

No.  *ix operating systems (Unix, Linux, OS X, etc.) inspect the first
line of a file to determine how to handle it; Windows does NOT.
Windows simply looks at the filename extension (.py, .pyw, etc.) and
consults its internal registry of file type associations.  The way
that you, as a user, can edit those associations has changed over the
years; in Windows 7 and 8, it's Control Panel\All Control Panel
Items\Default Programs\Set Associations.

On the other hand, when you start up CMD.EXE and type "python" at the
prompt, Windows uses a procedure that goes back to DOS 2 or so: the
PATH environment variable.  This is similar to, but a little different
from, the way that *ixes work; Windows first compares what you've
typed with the list of commands built-in to CMD, then with all of the
executable files in the current working directory, THEN
walks through the directories listed in PATH.  The first matching
command or executable it finds is the one that runs.

> Putting #!python3 on the first line of game_over2.py should solve it.
NO.  #! has no effect in Windows, because the choice of Python
interpreter has already been made by the time anybody gets round to
reading the first line of the file.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python - print function - invalid syntax

2014-08-05 Thread Mark Lawrence

On 05/08/2014 15:56, Marc Tompkins wrote:

On Tue, Aug 5, 2014 at 12:48 AM, Maxime Steisel  wrote:

I think this is because on windows, *.py files are associated with py.exe
that choose the python version depending on the first line of your file.


No.  *ix operating systems (Unix, Linux, OS X, etc.) inspect the first
line of a file to determine how to handle it; Windows does NOT.
Windows simply looks at the filename extension (.py, .pyw, etc.) and
consults its internal registry of file type associations.  The way
that you, as a user, can edit those associations has changed over the
years; in Windows 7 and 8, it's Control Panel\All Control Panel
Items\Default Programs\Set Associations.

On the other hand, when you start up CMD.EXE and type "python" at the
prompt, Windows uses a procedure that goes back to DOS 2 or so: the
PATH environment variable.  This is similar to, but a little different
from, the way that *ixes work; Windows first compares what you've
typed with the list of commands built-in to CMD, then with all of the
executable files in the current working directory, THEN
walks through the directories listed in PATH.  The first matching
command or executable it finds is the one that runs.


Putting #!python3 on the first line of game_over2.py should solve it.

NO.  #! has no effect in Windows, because the choice of Python
interpreter has already been made by the time anybody gets round to
reading the first line of the file.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor



Completely wrong, the reference that Maxime gave to PEP 397 that you've 
snipped was absolutely correct.  Windows might not handle shebang lines, 
Python on Windows does.


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python - print function - invalid syntax

2014-08-05 Thread Zachary Ware
On Tue, Aug 5, 2014 at 9:56 AM, Marc Tompkins  wrote:
> On Tue, Aug 5, 2014 at 12:48 AM, Maxime Steisel  
> wrote:
>> I think this is because on windows, *.py files are associated with py.exe
>> that choose the python version depending on the first line of your file.
>
> No.  *ix operating systems (Unix, Linux, OS X, etc.) inspect the first
> line of a file to determine how to handle it; Windows does NOT.

Have a look at PEP 397[1].  You are correct, *Windows* does not look
at the shebang line.  However, Maxime is also correct in that Python
3.3+ installs the Python Launcher for Windows (py.exe) and associates
the .py extension with it, and *py.exe* does shebang line handling,
spawning the interpreter requested by the shebang line as a
subprocess.

> Windows simply looks at the filename extension (.py, .pyw, etc.) and
> consults its internal registry of file type associations.  The way
> that you, as a user, can edit those associations has changed over the
> years; in Windows 7 and 8, it's Control Panel\All Control Panel
> Items\Default Programs\Set Associations.
>
> On the other hand, when you start up CMD.EXE and type "python" at the
> prompt, Windows uses a procedure that goes back to DOS 2 or so: the
> PATH environment variable.  This is similar to, but a little different
> from, the way that *ixes work; Windows first compares what you've
> typed with the list of commands built-in to CMD, then with all of the
> executable files in the current working directory, THEN
> walks through the directories listed in PATH.  The first matching
> command or executable it finds is the one that runs.
>
>> Putting #!python3 on the first line of game_over2.py should solve it.
> NO.  #! has no effect in Windows, because the choice of Python
> interpreter has already been made by the time anybody gets round to
> reading the first line of the file.

"#!python3.4" or "#!C:\Python34\python.exe" or "#!/usr/bin/env
python3" should all work if the '.py' extension is properly associated
with the py.exe launcher, which it should be if the most recently
installed Python was 3.3 or 3.4, installed with default options.

-- 
Zach

[1] http://legacy.python.org/dev/peps/pep-0397/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python - print function - invalid syntax

2014-08-05 Thread Marc Tompkins
On Tue, Aug 5, 2014 at 8:23 AM, Zachary Ware
 wrote:
>
> which it should be if the most recently
> installed Python was 3.3 or 3.4, installed with default options.
>

And there we have my problem with this glorious new "feature".  YOU
CAN'T RELY ON IT, because it depends on the most recent version having
been installed most recently.  Much better to depend on the underlying
behavior of the operating system.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python - print function - invalid syntax

2014-08-05 Thread Dave Angel
Marc Tompkins  Wrote in message:
> On Tue, Aug 5, 2014 at 8:23 AM, Zachary Ware
>  wrote:
>>
>> which it should be if the most recently
>> installed Python was 3.3 or 3.4, installed with default options.
>>
> 
> And there we have my problem with this glorious new "feature".  YOU
> CAN'T RELY ON IT, because it depends on the most recent version having
> been installed most recently.  Much better to depend on the underlying
> behavior of the operating system.
> 

Read some more. Once you've got py.exe installed,  whether from
 python 3.3+ or manually, then you just point the path and/or file
 associations at it.  That's done by default when python 3.3+ is
 installed, and only messed up when you subsequently install an
 older version using the wrong options. 



-- 
DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor