I didn't find anything useful via Google or Vaults of Parnassus
searches. So, I would appreciate any pointers!
Thanks in advance.
--
Lance Sloan - lslo...@my-deja.com
--
Lance Sloan - lslo...@my-deja.com
Sent via Deja.com
http://www.deja.com/
Maybe the Perl/Python phrasebook at
http://starship.python.net/~da/jak/cookbook.html is helpful to you.
Intra-document links don't work. Does anybody know a better version of
this document?
Gerhard
--
Sorry for the fake email, please use the real one below to reply.
contact: g e r h a r d @ b i g f o o t . d e
web: http://highqualdev.com
I haven't seen anything like that anywhere. I've sometimes wanted something
like that too, but for a different reason--so that I could actually maintain my
old Perl scripts <wink>.
But I _have_ done a little translation _manually_. Here's how it goes:
1) The translation process is mostly mechanical. Semantically, Perl and Python
are very similar; most of the difference is just syntax. (Still, that "little"
difference is why I now use _Python_ instead of Perl!)
2) Much of translating Perl to Python is a "clutter-removal" process. You will
remove braces, semi-colons, and dollar signs--stuff that you really didn't need
in the first place. Despite Perl's reputation for brevity, you'll find yourself
with smaller script files, having fewer lines (at least if you don't write
extremely terse Perl--like I never did.)
3) Most of what's left has to do with what we Pythoneers call "Explicit is
better than implicit." Specifically, you will find yourself adding explicit
variable names to cover what Perl did with all those special "punctuation mark"
things--you know, the things that look like comic-strip cuss words <wink>. In
particular, you will find yourself writing more code for regular
expressions--even though they are semantically very similar to Perl. (This is
something I still miss about Perl: compact regular expressions. Still, given
that explicit is better than implicit, it is a vegatable that one needs to eat.)
To rigorously and correctly translate any-and-all Perl to Python would surely
take a heroic effort, but to do it at about the 90% level can't be all that big
of a job for the language hobbyists out there (anybody know any? <wink>); then,
a Real Live Human Being could fix the remaining 10%.
But in any case, if you are experienced in Perl, you will find Python extremely
easy to pick up. And after going through Guido's tutorial, I can think of no
better way to learn it than to manually translate some of your old Perl scripts
into Python.
python-is-pretty-much-perl-without-all-the-LSD-ly y'rs,
=g2
_____________________________________________________________________
Grant R. Griffin g...@dspguru.com
Publisher of dspGuru http://www.dspguru.com
Iowegian International Corporation http://www.iowegian.com
Agreed. I convered a "dice server" of mine as a way to learn Python and
in several hours of real-time coding spread over two weeks I had the Python
script not only up to about 90% of the functionality of the Perl script but
also had improved upon some portions and felt that I did a much cleaner job in
Python. The remaining 10% that the Python script doesn't do is because there
are libraries in Python to do it that I've not yet played with and don't want
to do it the half-assed way I did in Perl. Another hour or two should have it
completed.
I'm also sure that the Python script could be improved upon greatly.
Point being, though, that it was trivial to do the conversion.
Oh, the only reference I used was the Beazley book.
--
Steve C. Lamb | I'm your priest, I'm your shrink, I'm your
ICQ: 5107343 | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------
Try a google.com search for "perl python phrasebook" for pointers
to such Perl-Python translators, and to other comparisons of
Perl and Python.
--
I won't rest till it's the best ...
Manager, Linux System Software
Paul Jackson <p...@sgi.com> 1.650.933.1373
:I'm an experienced Perl programmer who has just been assigned
:a project that must be done in Python. I'm looking for a
:Perl-to-Python translator to help me out. I don't expect to
:write the whole project in Perl and translate it, though. I'm
:just looking for some automation to help me see how my old work
:could be done in Python.
I've translated a single Perl script (written by someone else) to Python. If
it helps you at all, you can see it here:
http://www.aota.net/ubb/Forum3/HTML/001491-1.html
I would recommend that you read through the Python Tutorial as a start, and
then look at the Library Reference. You should be able to work through the
tutorial in short order, and then browse the Library Reference on an as-needed
basis. The tutorial may seem simple, but it will get you jump started and
won't take long..
--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/
http://www.seanet.com/~hgg9140/comp/index.html
It lets you pretty much read the perl code and write the python code
on the fly. More tedious than true converter, but do-able.
I agree with other posters that after you get into python's own
idioms, you won't miss perl.
Lance Sloan <lslo...@my-deja.com> writes:
--
Harry George E-mail: harry.g...@boeing.com
The Boeing Company Renton: (425) 237-6915
P. O. Box 3707 02-CA Everett: (425) 266-3868
Seattle, WA 98124-2207 Page: (425) 631-8803
-----Original Message-----
From: Gerhard Häring [mailto:gerhard...@bigfoot.de]
Sent: Wednesday, January 31, 2001 2:48 PM
To: pytho...@python.org
Subject: Re: Perl-to-Python converter/translator?
Lance Sloan wrote:
>
> I'm an experienced Perl programmer who has just been assigned
> a project that must be done in Python. I'm looking for a
> Perl-to-Python translator to help me out. I don't expect to
> write the whole project in Perl and translate it, though. I'm
> just looking for some automation to help me see how my old work
> could be done in Python.
>
> I didn't find anything useful via Google or Vaults of Parnassus
> searches. So, I would appreciate any pointers!
Maybe the Perl/Python phrasebook at
http://starship.python.net/~da/jak/cookbook.html is helpful to you.
Intra-document links don't work. Does anybody know a better version of
this document?
Gerhard
Sorry, Grant: simply *parsing* Perl is beyond most peoples' pain tolerance;
search CPAN for an equivalent to Python's tokenize.py and report back on
your successes <wink>.
perhaps-you'd-make-better-progress-if-you-ran-it-through-an-fft-
first-ly y'rs - tim
> Sorry, Grant: simply *parsing* Perl is beyond most peoples' pain
> tolerance; search CPAN for an equivalent to Python's tokenize.py and
> report back on your successes <wink>.
To overcome the expected language incompatibilities between Perl 5 and
the future Perl 6, the language developers are intending to
provide a tool that will migrate existing Perl 5 code to Perl 6. I'm
not sure of the exact details, but I understand that it will make use
of the fact that Perl now has a compiler that can compile to and from
some intermediate format - I presume the scheme being to use the Perl 6
compiler to reconstitute as source code the intermediate code generated
by the Perl 5 compiler. Perhaps it may be possible to reconstitute this
intermediate code as Python source code instead.
Hamish Lawson
It sure was beyond _mine_, Tim! Luckily, just about the time I realized I
couldn't parse my own Perl code, I discovered Python <wink>.
But this is a classic Catch-22: you switch to Python because you found yourself
unable to maintain your own Perl; you want to translate your Perl to Python so
you can maintain it; but there aren't any automatic translators out there
because nobody _else_ can figure out how to parse Perl--which is more-or-less
why you switched in the first place!
Then again, haven't Great Minds already solved the parsing part of automatic
translation? I mean, doesn't Perl come with its own lexer, parser, and even
grammar (though last I checked, they had to doctor the parser that was
automatically generated from the grammar...)
Which reminds me...I really think Open Source Software is gonna become a big
thing one day--just for cases like this <wink>.
>search CPAN for an equivalent to Python's tokenize.py and report back on
>your successes <wink>.
I see what you mean. (Though to be fair, I never found tokenize.py on PYPAN
either <wink>.)
But did I say "translate at about the 90% level"?--I really meant translate at
about the _7%_ level. If somebody came up with something that didn't really
"parse" Perl but just did the simple operation of "clutter-removal" (eliminating
";", "{", "@", "my", etc. outside of strings) that would help.
i'd-write-one-myself-if-perl-hadn't-taught-me-to-be-lazy
-<wink>-ly y'rs,