Points well taken. In fact, the example he demonstrated to me as a one-liner was a regular expression as a line filter in Emacs--essentially just a grep. There's no Pythonic equivalent to this. Right tool for the right job, as you said. He was half-joking about not learning Python if it lacked the option to execute snippets.
His lab maintains a significant amount of Perl code; he was intrigued by my zealous enthusiasm for Python and my assertion that, personally, I experienced greater long-term readability with my scripts written in Python over those written in Perl. I think once he begins to experience Python he will come to understand why it's not suited for one-liners, and why that's a Good Thing. Excellent reply! Chris On 10/15/06, Tim Peters <[EMAIL PROTECTED]> wrote: > [Chris Lasher] > > My professor and advisor has been "inspired" by me to give Python a > > try. He's an avid Perl user, and challenged me with the following: > > > > What is the Python equivalent to perl -e '<some oneliner>'? > > The initally attractive but unsatisfying answer is: > > python -c '<some oneliner>' > > The reason it's "unsatisfying" is that Python isn't concerned with making: > > <some oneliner> > > pleasant, or even sanely possible, for many tasks. Perl excels at > one-liners; Python doesn't much care about them. > > > Embarassingly, I had no answer, but I figure, someone on the list will > > know. His use of Python is at stake; he threatened that, since he's > > dependant enough on using perl -e within Emacs enough, if it can't be > > done in Python, he won't take the language seriously. Help me, Python > > Tutor, you're his only hope! > > Like many Python (very) old-timers, I used Perl heavily at the time > Python came out. As was also true for many of them, as time went on > the size of a new program I was willing to write in Perl instead of in > Python got smaller and smaller, eventually reaching "almost 0". I > still use Perl some 15 years later, but now /only/ for "perl -e"-style > 1-liners at an interactive shell. If it takes more than a line, I > stick it in a module (and maybe a class) for reuse later. > > Python's strengths are more in readability, helpful uniformity, easy > use of classes and rich data structures, and maintainability. Cryptic > one-liners are in general (but not always) opposed to all of those. > > So, ya, "python -c" exists, but your professor won't be happy with it. > That's fine! If one-liners are all he cares about, Perl is usually > the best tool for the job. > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor