473,216 Members | 2,215 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,216 software developers and data experts.

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

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
10 14792
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
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
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

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
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
>
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
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

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
>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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
by: Fred Ma | last post by:
Hello, This is not a troll posting, and I've refrained from asking because I've seen similar threads get all nitter-nattery. But I really want to make a decision on how best to invest my time....
4
by: Xah Lee | last post by:
while programing in Python, one can lookup syntax or info for keywords or modules within Python. In the command line, type python to get into the python interactive program. then type...
4
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # to open a file and write to file # do f=open('xfile.txt','w') # this creates a file "object" and name it f. # the second argument of open can be
2
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # in Python, one can define a boxed set # of data and functions, which are # traditionally known as "class". # in the following, we define a...
2
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # suppose you want to fetch a webpage. from urllib import urlopen print urlopen('http://xahlee.org/Periodic_dosage_dir/_p2/russell-lecture.html').read() #...
41
by: Xah Lee | last post by:
here's another interesting algorithmic exercise, again from part of a larger program in the previous series. Here's the original Perl documentation: =pod merge($pairings) takes a list of...
20
by: Xah Lee | last post by:
Sort a List Xah Lee, 200510 In this page, we show how to sort a list in Python & Perl and also discuss some math of sort. To sort a list in Python, use the “sort” method. For example: ...
3
by: Xah Lee | last post by:
Split File Fullpath Into Parts Xah Lee, 20051016 Often, we are given a file fullpath and we need to split it into the directory name and file name. The file name is often split into a core...
0
by: Xah Lee | last post by:
One-Liner Loop in Functional Style Xah Lee, 200510 Today we show a example of a loop done as a one-liner of Functional Programing style. Suppose you have a list of file full paths of...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.