multiline prototyping on command line
Eric Smith
eric at fruitcom.com
Sat Oct 30 05:31:56 EDT 1999
gerglery at usa.net (greg andruk) posted in comp.lang.python on
30 Oct 1999 04:55:37 -0400:
> Eric Smith <eric at fruitcom.com> wrote:
>
> > I am am a perl programmer looking at Python and would like to know whether
> > it is possible on the command line to test algorithms like I do in perl
> > thusly:
>
> > perl -e '$r="de";if ($r eq "whatever" or "de") {print "a match\n"}
>
> Nitpick: I don't think the above is testing what you think it's
> testing; it will always print "a match" regardless of $r's value.
> I'll assume you meant `...($r eq "whatever" or $r eq "de")...' there.
>
> Anyway, Python's not especially amenable to one-liners. Instead, it
> has a really spiffy interactive mode you can leave running in a window
> or spare console session that works like you probably wish `perl -d'
> worked:
>
> meowing:~$ pytest
> Python 1.5.2+ (#2, Oct 25 1999, 05:27:05) [GCC 2.7.2.3] on linux2
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> r = 'de'
> >>> r in ('whatever', 'de')
> 1
> >>> # and just for the heck of it...
> ... r == 'whatever' or 'de'
> 'de'
> >>>
--
Eric Smith
eric at fruitcom.com
www.fruitcom.com
unix perl - sailing to war in an Armada of nutshells.
More information about the Python-list
mailing list