Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > stop executing

Reply
Thread Tools

stop executing

 
 
Andreas Lobinger
Guest
Posts: n/a
 
      10-05-2004
Aloha,

i want to put a short script and additional data together in
an shellexecutable, like this

--begin-file--
#!/usr/bin/env python
import sys
print sys.argv
sys.exit()

other data following, strictly not in python syntax...
--end-file--

I would expect the interpreter to stop after the sys.exit, but of
course the parser tries to read on.
lobingera@scylla: b.py
File "b.py", line 7
other data
^
SyntaxError: invalid syntax

I have now a somehow working solution by putting the data in a
multiline string, but that raises the subquestion:
How much data can be put in a multiline string and how do i
escape the tripple-" ?

Hoping for an answer and wishing a happy day
LOBI
 
Reply With Quote
 
 
 
 
Michael Hudson
Guest
Posts: n/a
 
      10-05-2004
Andreas Lobinger <(E-Mail Removed)> writes:

> Aloha,
>
> i want to put a short script and additional data together in
> an shellexecutable, like this
>
> --begin-file--
> #!/usr/bin/env python
> import sys
> print sys.argv
> sys.exit()
>
> other data following, strictly not in python syntax...
> --end-file--
>
> I would expect the interpreter to stop after the sys.exit, but of
> course the parser tries to read on.
> lobingera@scylla: b.py
> File "b.py", line 7
> other data
> ^
> SyntaxError: invalid syntax
>
> I have now a somehow working solution by putting the data in a
> multiline string, but that raises the subquestion:
> How much data can be put in a multiline string


Well, you'll get into real trouble around the 2 gig mark on most
machines, though I guess memory consumption will hurt you first.

> and how do i escape the tripple-" ?


backslashes?

Another option, instead of having 'python' in your hash-bang line
would be to have a program that preprocessed the file before handing
it to Python.

Cheers,
mwh

--
If you don't use emacs, you're a pathetic, mewling, masochistic
weakling and I can't be bothered to convert you. -- Ron Echeverri
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
use registroy to stop autorun.inf files executing lexdean Computer Security 0 11-17-2008 09:35 PM
How can we stop IE from executing javascript on a back button click Tom Javascript 3 11-27-2007 04:00 PM
How to stop a validation function from executing after it encounters an error? effendi@epitome.com.sg Javascript 5 03-02-2005 10:56 PM
Get debugging to stop on line executing when error occurs Lloyd Sheen ASP .Net 3 03-07-2004 05:30 PM
Perl: how to stop users from executing commands from browser Nick Perl Misc 4 09-23-2003 07:20 PM



Advertisments