"assert" annoyance

Evan Klitzke evan at yelp.com
Fri Jun 22 03:41:29 EDT 2007


On 6/22/07, Miles <semanticist at gmail.com> wrote:
> On Jun 22, 2:45 am, "Evan Klitzke" <e... at yelp.com> wrote:
> > On 6/21/07, Miles <semantic... at gmail.com> wrote:
> >
> > > On Jun 22, 1:31 am, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> > > > What I really want is for any assertion failure, anywhere in the
> > > > program, to trap to the debugger WITHOUT blowing out of the scope
> > > > where the failure happened, so I can examine the local frame.  That
> > > > just seems natural, but I don't see an obvious way to do it.
> >
> > > You could run the entire program through pdb:
> > > ----
> > > #!/usr/bin/env python -m pdb
> >
> > > print "Hello!"
> > > assert False
> > > print "...world!"
> > > ----
> >
> > You can only pass one argument to a command that you invoke with the
> > shebang sequence, so this won't work the way you wrote it.
> >
> > --
> > Evan Klitzke <e... at yelp.com>
>
> It actually does work on my system (OS X); I didn't realize it wasn't
> portable.

This sort of surprised me (in a good way), since I just took the one
argument rule for granted. It's always bugged me that I couldn't do,
say, #!/usr/bin/env python -O. So it's nice to see that OS X splits
the arguments, even if this isn't completely portable! I did some
research on this and it looks like a few other Unices do it too. If
anyone is interested, there's a table documenting the behavior of
different systems at
http://www.in-ulm.de/~mascheck/various/shebang/#results

Maybe I should start using a Mac ;-)

-- 
Evan Klitzke <evan at yelp.com>



More information about the Python-list mailing list