Re: [OT] inline python (was Re: [ in /usr/bin Question)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 05/10/07 12:27, Ken Irving wrote:
> On Thu, May 10, 2007 at 05:52:03PM +0100, william pursell wrote:
>> Bob McGowan wrote:
>>> So, a question: Can python 'run' code directly from the command line,
>>> as Perl does with the -e option?
>> Yes:
>>
>> python -c 'print "!dlrow olleH"[::-1]'
>
> Nice example of how python, besides being capable of one-liners, isn't
> a cryptic language! ;-)
I didn't know that Python could reverse strings like that. Here's
the non-cryptic version:
$ python -c 'x=list("!dlrow olleH");x.reverse();print "".join(x)'
> I had no idea what the above collection of characters would do, though in
> retrospect I should have figured it out. Perl is famous for obfuscation
> contests, but it can also be pretty clear (as, I'm sure, can Python
> be), e.g.,
>
> $ perl -e 'print reverse(split(//,"!dlrow olleH")), "\n"'
>
> But where's the fun in that?
>
> It's tiring to hear, repeatedly, how much better MY language is than YOUR
> language. Once one learns any given language it's perfectly obvious to
> the writer, and to any reader also familiar with it, what a given piece
> of code does. To say that MY language is intrinsically superior to
> YOURS because it is not cryptic is, well, a comfortable belief, I suppose.
>
> Ken
>
- --
Ron Johnson, Jr.
Jefferson LA USA
Give a man a fish, and he eats for a day.
Hit him with a fish, and he goes away for good!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFGQ5/gS9HxQb37XmcRAgj0AKCtuKD8yEY7uhOupv9+gejfbLRYWQCfW0aw
KUv7yqgl8FFYpwfnx5YfuUs=
=MSfW
-----END PGP SIGNATURE-----
Reply to: