By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,626 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,626 IT Pros & Developers. It's quick & easy.

C/C++, Perl, etc. to Python converter

P: n/a
mm

Is there a Perl to Python converter?
Or in general: a XY to Python converter?

Is see, that Python is much better then Perl anyway.
But for beginners, they whant to konw how is this done with Python etc.

Sure, there are some docus out there in the internet. But a converter?
Jan 3 '07 #1
Share this Question
Share on Google+
10 Replies


P: n/a
mm wrote:
>
Is there a Perl to Python converter?
Or in general: a XY to Python converter?

Is see, that Python is much better then Perl anyway.
But for beginners, they whant to konw how is this done with Python etc.

Sure, there are some docus out there in the internet. But a converter?
Nope. Different languages have different idioms, translating them to each
other - while technically possible, at least to some extend - won't result
in anything that a human being can work with.

Diez
Jan 3 '07 #2

P: n/a
I don't know of a converter, one may exist. I have seen similar
requests though and will give you a similar response to what I have
seen. A converter, if it exists, may be able to produce working code
but _not_ readable code. Python is a language whose strength comes
from, among other things, its readability and conventions. Learning
python is best done by using the online documentation
(http://docs.python.org/tut/tut.html) and reading existing code (take a
look at the built in modules).

My biggest fear of teaching someone to program by using a program to
convert perl to python is that they will end up writing python that
still looks like perl.

I don't know if it helps, but I know others will give you similar
advice.

-Matt

Jan 3 '07 #3

P: n/a
Yes, I konw what you mean. And thats the right way to do it - for
beginners. --But not for someone who allready know programmings things
for many years.

They ask themself: How can I do this in Python? I can remember, it was
that-way with Perl or C or C++ or whatever.

So, not only a ververter can be useful, also a translation table.
(Maybe just a table for print out.)

LangX <-LangY

Matimus wrote:
I don't know of a converter, one may exist. I have seen similar
requests though and will give you a similar response to what I have
seen. A converter, if it exists, may be able to produce working code
but _not_ readable code. Python is a language whose strength comes
from, among other things, its readability and conventions. Learning
python is best done by using the online documentation
(http://docs.python.org/tut/tut.html) and reading existing code (take a
look at the built in modules).

My biggest fear of teaching someone to program by using a program to
convert perl to python is that they will end up writing python that
still looks like perl.

I don't know if it helps, but I know others will give you similar
advice.

-Matt
Jan 3 '07 #4

P: n/a

mm wrote:
Is there a Perl to Python converter?
Or in general: a XY to Python converter?

Is see, that Python is much better then Perl anyway.
But for beginners, they whant to konw how is this done with Python etc.

Sure, there are some docus out there in the internet. But a converter?
I don't know of any converter, but I have seen a number of tutorials
that show how to do OO things in both perl and python for example.
Avi Kak of Purdue U. has one such tutorial.
When I took his class, he had a large package of notes that he said was
the basis for his next book. It doesn't look like he ever got around
to publishing that one.
However, if you google his homepage, he does have at last one tutorial
posted for Perl vs. Python.

Jan 3 '07 #5

P: n/a
Matimus schrieb:
I don't know of a converter, one may exist. I have seen similar
requests though and will give you a similar response to what I have
seen. A converter, if it exists, may be able to produce working code
but _not_ readable code. Python is a language whose strength comes
from, among other things, its readability and conventions. Learning
python is best done by using the online documentation
(http://docs.python.org/tut/tut.html) and reading existing code (take a
look at the built in modules).

My biggest fear of teaching someone to program by using a program to
convert perl to python is that they will end up writing python that
still looks like perl.

I don't know if it helps, but I know others will give you similar
advice.

-Matt
I think that it *is* possible to do it, but a whole lot of work had to
be done to achieve this. It is all about how many rules (like how to
convert this block of unreadable code of language X into a readable
python block) you are willing to find/program (and these are a lot). It
is a almost gigantic task to make this work proper, but it definitely
*is* possible.

Something like this doesn't exist yet, but people (especially
Computational Linguists) are working on this.

Thomas
Jan 3 '07 #6

P: n/a
>
I think that it *is* possible to do it, but a whole lot of work had to
be done to achieve this. It is all about how many rules (like how to
convert this block of unreadable code of language X into a readable
python block) you are willing to find/program (and these are a lot). It
is a almost gigantic task to make this work proper, but it definitely
*is* possible.
It is definitely _not_ possible. There are so many design decisions that
are differing based on what a language offers - e.g. generators, garbage
collection, precise control over memory layout and so on.

Projects like jython or ironpython show that to some degree at least
binary compatibility is feasible - but beyond that, machine generated
cod will always be that, and by no means idiomatic.

Diez
Jan 4 '07 #7

P: n/a
Diez B. Roggisch wrote:
>
>>
I think that it *is* possible to do it, but a whole lot of work had to
be done to achieve this. It is all about how many rules (like how to
convert this block of unreadable code of language X into a readable
python block) you are willing to find/program (and these are a lot). It
is a almost gigantic task to make this work proper, but it definitely
*is* possible.


It is definitely _not_ possible. There are so many design decisions that
are differing based on what a language offers - e.g. generators, garbage
collection, precise control over memory layout and so on.
Inter-language translators have been written. There's usually
a performance penalty, which can be severe when the idioms of
the languages are quite different.

Perl to Python translation might be worth doing. The
languages have quite different syntax, but roughly the same
functionality. You'd probably have to write a set of libraries
in Python with the equivalent definitions to their Perl
counterparts, but that's just time-consuming, not difficult.

John Nagle
Jan 4 '07 #8

P: n/a

mm wrote:
Is there a Perl to Python converter?
Or in general: a XY to Python converter?

Is see, that Python is much better then Perl anyway.
But for beginners, they whant to konw how is this done with Python etc.

Sure, there are some docus out there in the internet. But a converter?
Try this page:
http://wiki.python.org/moin/PerlPhrasebook

- Paddy.

Jan 5 '07 #9

P: n/a
>It is definitely _not_ possible. There are so many design decisions
>that are differing based on what a language offers - e.g. generators,
garbage collection, precise control over memory layout and so on.

Inter-language translators have been written. There's usually
a performance penalty, which can be severe when the idioms of
the languages are quite different.
The point discussed here was not the feasibility of language-translators
per se. These are certainly possible, yet I doubt that e.g. C++2Python
would really come to existence.

Thomas expressed his belief that a _idiomatic_ translator was possible.
And that certainly isn't the case.

Diez
Jan 5 '07 #10

P: n/a
mm wrote:
>
Is there a Perl to Python converter?
Or in general: a XY to Python converter?

Is see, that Python is much better then Perl anyway.
But for beginners, they whant to konw how is this done with Python etc.

Sure, there are some docus out there in the internet. But a converter?
Maybe this can help in converting from prel to python:
http://www.crazy-compilers.com/bridgekeeper/

Uwe
Jan 5 '07 #11

This discussion thread is closed

Replies have been disabled for this discussion.