Re: #line in python (dirty tricks)

2012-02-20 Thread Duncan Booth
Ross Boylan wrote: >> No [easy] way to go from bytecodes back to AST, but I see no reason >> why you can't create a new code object with your filename and line >> numbers and then create a new function using your modified code >> object. > Could you elaborate? I don't understand what you are su

Re: #line in python (dirty tricks)

2012-02-20 Thread Ross Boylan
Duncan Booth wrote > Ross Boylan wrote: > > > As an extension or alternate, could there be a decorator like > > @source_line(lineno, filename) > > for classes and methods that could do the conversion on the fly? I > > don'

Re: #line in python

2012-02-20 Thread Duncan Booth
Ross Boylan wrote: > As an extension or alternate, could there be a decorator like > @source_line(lineno, filename) > for classes and methods that could do the conversion on the fly? I > don't know if there's a way to go from the function (or class) object > the decorator receives to the AST. >

#line in python

2012-02-18 Thread Ross Boylan
The ast module shows that elements of the syntax tree have line and column numbers. Would it be sensible to attempt to revise them to achieve effects like the #line directive in C? Context: Using noweb, a literate programming tool, which from a source file foo.nw produces foo.py. The lines in th

Re: getting command line in python

2011-11-09 Thread Matej Cepl
Dne 8.11.2011 23:36, MrSmile napsal(a): Thank you all, that was it that I was searching for you. Except that most likely it wasn't the right answer. Take a look at http://docs.python.org/library/argparse.html (or optparse, if you are on Python < 2.7). Best, Matěj -- http://mail.python.org/

Re: getting command line in python

2011-11-08 Thread MrSmile
Thank you all, that was it that I was searching for you. Tamer Am 08.11.2011 23:32, schrieb Cameron Simpson: > On 08Nov2011 23:19, MrSmile wrote: > | I am looking for a way to get the command line in the script. > | > | Let us say I am in the folder "/tmp" okay! > | > | now from /tmp I execut

Re: getting command line in python

2011-11-08 Thread Cameron Simpson
On 08Nov2011 23:19, MrSmile wrote: | I am looking for a way to get the command line in the script. | | Let us say I am in the folder "/tmp" okay! | | now from /tmp I execute in the console this: | python /home/tamer/MyApp/MyScript.py | | in the app itself, I want to grep the path and the script

Re: getting command line in python

2011-11-08 Thread Chris Rebert
On Tue, Nov 8, 2011 at 2:19 PM, MrSmile wrote: > Hi people! > I am looking for a way to get the command line in the script. > > Let us say I am in the folder "/tmp" okay! > > now from /tmp I execute in the console this: > python /home/tamer/MyApp/MyScript.py > > in the app itself, I want to grep t

Re: getting command line in python

2011-11-08 Thread Irmen de Jong
On 8-11-2011 23:19, MrSmile wrote: Hi people! I am looking for a way to get the command line in the script. Let us say I am in the folder "/tmp" okay! now from /tmp I execute in the console this: python /home/tamer/MyApp/MyScript.py in the app itself, I want to grep the path and the scriptname

getting command line in python

2011-11-08 Thread MrSmile
Hi people! I am looking for a way to get the command line in the script. Let us say I am in the folder "/tmp" okay! now from /tmp I execute in the console this: python /home/tamer/MyApp/MyScript.py in the app itself, I want to grep the path and the scriptname itself, like: /home/tamer/MyApp is b