Re: Strange syntax error, occurs only when script is executed directly [solved]

2014-04-22 Thread Andrew Cooper
On 22/04/2q014 13:26, Chris Angelico wrote: > On Tue, Apr 22, 2014 at 10:21 PM, Antoon Pardon > wrote: >> Yes that was it. I changed the first line of my script to: >> >> #!/opt/local/bin/python2.7 >> >> and it now works. > > Excellent! Shebangs are *extremely* specific, so you may want to > cons

Re: Strange syntax error, occurs only when script is executed directly [solved]

2014-04-22 Thread Andrew Cooper
On 22/04/2q014 13:26, Chris Angelico wrote: > On Tue, Apr 22, 2014 at 10:21 PM, Antoon Pardon > wrote: >> Yes that was it. I changed the first line of my script to: >> >> #!/opt/local/bin/python2.7 >> >> and it now works. > > Excellent! Shebangs are *extremely* specific, so you may want to > cons

Re: Strange syntax error, occurs only when script is executed directly

2014-04-22 Thread Andrew Cooper
On 22/04/2014 13:52, Chris Angelico wrote: > On Tue, Apr 22, 2014 at 10:36 PM, Steven D'Aprano > wrote: >>> These are the 15 first lines of the script: >>> >>> #! /opt/local/bin/python >> >> This being Solaris, what happens if you remove the space between the hash- >> bang and the path? On Linux i

Re: Strange syntax error, occurs only when script is executed directly

2014-04-22 Thread Chris Angelico
On Tue, Apr 22, 2014 at 11:22 PM, Tim Chase wrote: > On 2014-04-22 22:52, Chris Angelico wrote: >> I'm pretty sure the POSIX standard stipulates that a space there is >> optional. Should be no difference between "#!/" and "#! /" on any >> compliant OS. (But I can't right now find a citation for th

Re: Strange syntax error, occurs only when script is executed directly

2014-04-22 Thread Tim Chase
On 2014-04-22 22:52, Chris Angelico wrote: > I'm pretty sure the POSIX standard stipulates that a space there is > optional. Should be no difference between "#!/" and "#! /" on any > compliant OS. (But I can't right now find a citation for that, so I > may be wrong.) I wondered this too, so went r

Re: Strange syntax error, occurs only when script is executed directly [solved]

2014-04-22 Thread Chris Angelico
On Tue, Apr 22, 2014 at 11:01 PM, Antoon Pardon wrote: > On 22-04-14 14:26, Chris Angelico wrote: > >> On Tue, Apr 22, 2014 at 10:21 PM, Antoon Pardon >> wrote: >>> Yes that was it. I changed the first line of my script to: >>> >>> #!/opt/local/bin/python2.7 >>> >>> and it now works. >> Excellent

Re: Strange syntax error, occurs only when script is executed directly [solved]

2014-04-22 Thread Antoon Pardon
On 22-04-14 14:26, Chris Angelico wrote: > On Tue, Apr 22, 2014 at 10:21 PM, Antoon Pardon > wrote: >> Yes that was it. I changed the first line of my script to: >> >> #!/opt/local/bin/python2.7 >> >> and it now works. > Excellent! Shebangs are *extremely* specific, so you may want to > consider

Re: Strange syntax error, occurs only when script is executed directly

2014-04-22 Thread Chris Angelico
On Tue, Apr 22, 2014 at 10:36 PM, Steven D'Aprano wrote: >> These are the 15 first lines of the script: >> >> #! /opt/local/bin/python > > This being Solaris, what happens if you remove the space between the hash- > bang and the path? On Linux it makes no difference, but Solaris tends to > be a bi

Re: Strange syntax error, occurs only when script is executed directly

2014-04-22 Thread Steven D'Aprano
On Tue, 22 Apr 2014 12:29:56 +0200, Antoon Pardon wrote: > I am workin on a solaris 11 machine. The python version is 2.7.6 path to > python is /opt/local/bin/python. Are you sure about that? You ought to double check that /opt/local/bin/ python is what you think it is, and not (say) a symlink to

Re: Strange syntax error, occurs only when script is executed directly [solved]

2014-04-22 Thread Chris Angelico
On Tue, Apr 22, 2014 at 10:21 PM, Antoon Pardon wrote: > Yes that was it. I changed the first line of my script to: > > #!/opt/local/bin/python2.7 > > and it now works. Excellent! Shebangs are *extremely* specific, so you may want to consider using "/usr/bin/env python" to get a bit more flexibil

Re: Strange syntax error, occurs only when script is executed directly [solved]

2014-04-22 Thread Antoon Pardon
On 22-04-14 14:09, Chris Angelico wrote: > On Tue, Apr 22, 2014 at 8:29 PM, Antoon Pardon > wrote: >> However if I call the script directly and want the #! line do its work I get >> the following error. >> >> # /usr/local/bin/ldapwatch /opt/local/log/openldap.log | head >> /usr/local/bin/ldapwatc

Re: Strange syntax error, occurs only when script is executed directly

2014-04-22 Thread Chris Angelico
On Tue, Apr 22, 2014 at 8:29 PM, Antoon Pardon wrote: > However if I call the script directly and want the #! line do its work I get > the following error. > > # /usr/local/bin/ldapwatch /opt/local/log/openldap.log | head > /usr/local/bin/ldapwatch: line 3: syntax error near unexpected token `('

Re: Strange syntax error, occurs only when script is executed directly

2014-04-22 Thread Antoon Pardon
On 22-04-14 12:42, Frank Millman wrote: > "Antoon Pardon" wrote in message > news:535644a4.6060...@rece.vub.ac.be... >> I am workin on a solaris 11 machine. The python version is 2.7.6 >> path to python is /opt/local/bin/python. >> > [...] >> Now if I execute the script by explicitly calling the

Re: Strange syntax error, occurs only when script is executed directly

2014-04-22 Thread Frank Millman
"Antoon Pardon" wrote in message news:535644a4.6060...@rece.vub.ac.be... >I am workin on a solaris 11 machine. The python version is 2.7.6 > path to python is /opt/local/bin/python. > [...] > > Now if I execute the script by explicitly calling the interpreter > everything works fine. > [...] > >

Re: Strange syntax error, occurs only when script is executed directly

2014-04-22 Thread Tim Golden
On 22/04/2014 11:29, Antoon Pardon wrote: > I am workin on a solaris 11 machine. The python version is 2.7.6 > path to python is /opt/local/bin/python. > > These are the 15 first lines of the script: > > #! /opt/local/bin/python > > class vslice(object): > > def __init__(self, fun): >

Strange syntax error, occurs only when script is executed directly

2014-04-22 Thread Antoon Pardon
I am workin on a solaris 11 machine. The python version is 2.7.6 path to python is /opt/local/bin/python. These are the 15 first lines of the script: #! /opt/local/bin/python class vslice(object): def __init__(self, fun): self.fun = fun def __getitem__(self, inx

Re: strange syntax error

2010-06-04 Thread Jerry Hill
On Fri, Jun 4, 2010 at 1:31 PM, _wolf wrote: >    File "", line 6 >      # >      ^ >  SyntaxError: invalid syntax I believe you're encountering this bug: http://bugs.python.org/issue1184112 It's been fixed for 2.7 and 3.2. Until then, you'll need to work around it. You can either append a new

strange syntax error

2010-06-04 Thread _wolf
this may not be an earth-shattering deficiency of python, but i still wonder about the rationale behind the following behavior: when i run :: source = """ print( 'helo' ) if __name__ == '__main__': print( 'yeah!' ) #""" print( compile( source, '', 'exec' ) ) i get :: File "",