In article <cc87ebf5-5ce1-4fb5-bb2d-cd4bc2426...@q36g2000vbn.googlegroups.com>, sprad <jsp...@gmail.com> wrote:
> On Jan 3, 6:41 pm, Steven D'Aprano <st...@remove-this- > cybersource.com.au> wrote: > > The OP comes from a Perl background, which AFAIK allows you to concat > > numbers to strings and add strings to numbers. That's probably the (mis) > > feature he was hoping Python had. > > That's correct -- and that's been one of the more difficult parts of > my transition. Learned C++ in college, spent a few years doing Perl, > and now all of a sudden type matters again. It's a very different > philosophy, but I'm determined to stick with it until I have an Aha! > moment and find something I can do more easily than I can with Perl. The Aha! moment comes 6 months from now, when you discover that you can understand the Python code you wrote 6 months ago, but the Perl code you wrote at the same time has become gibberish, even to you. The other day, I came upon this gem. It's a bit of perl embedded in a Makefile; this makes it even more gnarly because all the $'s get doubled to hide them from make: define absmondir $(shell perl -e ' \ sub absmon { my $$a = $$_[0]; \ if ( $$^O =~ m/cygwin|MSWin32/i ) { $$prefix = `/bin/mount -p|awk "NR==2{print \\\$$1}"`; chomp($$prefix); \ $$a = ($$_[1]||"$(PWD)") . "/$$a" \ unless ( $$a =~ m !^(:?$$prefix|/|[A-Za-z]:)! ); \ } else { $$a = ($$_[1]||"$(PWD)") . "/$$a" unless ( $$a =~ m !^/! ); } \ return unslash(undot(undotdot($$a))); }; \ sub unslash ($$) { $$_[0] =~ s://+:/:g; $$_[0] =~ s:/$$::; return($$_[0]); }; \ sub undot ($$) { $$_[0]=~s:/\./:/:g; return ($$_[0]); }; \ sub undotdot ($$) { my $$in = $$_[0]; \ return ( $$in =~ s:/[^/.][^/]*/\.\.::g )?undotdot($$in):$$in; }; \ print absmon("$(1)","$(2)"); \ ' ) endef Barf-o-rama. I know what it's supposed to do, and I still can't figure it out.
-- http://mail.python.org/mailman/listinfo/python-list