Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Perl to Python conversion
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Martin Schöön  
View profile  
 More options Dec 9 2009, 3:33 pm
Newsgroups: comp.lang.python
From: martin.sch...@gmail.com (Martin Schöön)
Date: Wed, 09 Dec 2009 21:33:56 +0100
Local: Wed, Dec 9 2009 3:33 pm
Subject: Perl to Python conversion
First off: I am new here and this is my first post after
lurking for quite some time.

Second off: I don't know much Python---yet.

Problem: I have come across a small open source application
that I find quite useful. It does have one major flaw though.
Its output is in imperial units. Converting isn't a big deal
for occasional use but if I start to use this stuff on a
regular basis...

So I down-loaded the source code and found this thing is written
in Perl.

Should I learn enough Perl to add the conversion? Probably
but this may be a nice excuse to get my Python education
going and if I do I might as well re-do the user interface.

If I do re-write this thing in Python I might need to learn both
Perl and Python...

Hence, are there any Perl to Python converters? So far I
have only found bridgekeeper which really is (was?) consultancy.
Apart from that I only find people recommending a manual re-write.

Any thoughts/recommendations?

TIA,

/Martin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
zeph  
View profile  
 More options Dec 9 2009, 4:05 pm
Newsgroups: comp.lang.python
From: zeph <zep...@gmail.com>
Date: Wed, 9 Dec 2009 13:05:33 -0800 (PST)
Local: Wed, Dec 9 2009 4:05 pm
Subject: Re: Perl to Python conversion
Python and Perl often have different design idioms - learning to write
*well* in a language involves understanding those idioms, and being
able to translate between languages involves understanding the source
language well enough to understand the intent of the program's code
(even if its poorly written), and understanding the target language
well enough to translate the intent into a design fitting the
language.

Perl and Python have enough syntactic similarities that you could, if
you wanted, just translate the program verbatim.

Overall, I would recommend adding your imperial->metric functionality
to the Perl code for now, and on your free time work on translating to
Python, so you don't feel rushed to get it finished.  You will
probably come to understand the Perl code better after having worked
with it and been involved in a hands-on way with it.  Likewise, you
will become even more familiar with it and with Python as you learn
how to translate the application.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Intchanter / Daniel Fackrell  
View profile  
 More options Dec 9 2009, 4:10 pm
Newsgroups: comp.lang.python
From: "Intchanter / Daniel Fackrell" <unlear...@gmail.com>
Date: Wed, 9 Dec 2009 13:10:34 -0800 (PST)
Local: Wed, Dec 9 2009 4:10 pm
Subject: Re: Perl to Python conversion
On Dec 9, 1:33 pm, martin.sch...@gmail.com (Martin Schöön) wrote:

Martin,

A full answer will depend a lot on several different factors,
including the length of the Perl code, what style it was written in
(there seem to be uncountably many possibilities), your experience
with languages in general, and with that style in particular.

In general, though, if your primary purpose is to learn Python and
ending up with a useful tool is secondary, I'd recommend rewriting the
tool from scratch, possibly keeping the Perl source handy.  If the
existing tool is command-line based, you might also be able to write a
short script through which you can pipe the output of the original
program to handle the conversion.

Intchanter
Daniel Fackrell


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Chant  
View profile  
 More options Dec 9 2009, 5:46 pm
Newsgroups: comp.lang.python
Followup-To: comp.lang.python
From: Peter Chant <pet...@MpeteOzilla.Vco.ukE>
Date: Wed, 09 Dec 2009 22:46:15 +0000
Local: Wed, Dec 9 2009 5:46 pm
Subject: Re: Perl to Python conversion

Martin Sch n wrote:
> Hence, are there any Perl to Python converters? So far I
> have only found bridgekeeper which really is (was?) consultancy.
> Apart from that I only find people recommending a manual re-write.

> Any thoughts/recommendations?

Voice of almost no experience.  I once ran a fortran programme through a
fortran to c converter and when I saw the result I ran away screaming - it
did not look very human friendly.

--
http://www.petezilla.co.uk


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
J Kenneth King  
View profile  
 More options Dec 10 2009, 2:04 pm
Newsgroups: comp.lang.python
From: J Kenneth King <ja...@agentultra.com>
Date: Thu, 10 Dec 2009 14:04:52 -0500
Local: Thurs, Dec 10 2009 2:04 pm
Subject: Re: Perl to Python conversion

martin.sch...@gmail.com (Martin Schöön) writes:
> First off: I am new here and this is my first post after
> lurking for quite some time.

Hi.

> Second off: I don't know much Python---yet.

It's not a very big language. If you have experience programming in
other languages, you can probably pick it up in a day or two.

> Problem: I have come across a small open source application
> that I find quite useful. It does have one major flaw though.
> Its output is in imperial units. Converting isn't a big deal
> for occasional use but if I start to use this stuff on a
> regular basis...

> So I down-loaded the source code and found this thing is written
> in Perl.

> Should I learn enough Perl to add the conversion? Probably
> but this may be a nice excuse to get my Python education
> going and if I do I might as well re-do the user interface.

Well you can always call it from Python via subprocess (which basically
wraps a shell and has fancy ways putting data in and extracting data
out).

> If I do re-write this thing in Python I might need to learn both
> Perl and Python...

You'll need to know one of them rather well and enough of the other to
get by.  It's probably easier to know more Perl than Python since Perl
is a lot more expressive than Python (in the TMTOWTDI sense).  Frankly I
learned Perl before Python and find it rather easy to go between the
two.  YMMV.

> Hence, are there any Perl to Python converters? So far I
> have only found bridgekeeper which really is (was?) consultancy.
> Apart from that I only find people recommending a manual re-write.

It depends where the two languages vary from one another.

If the script your translating uses basic types or even simple classes
and typical control structures and operations then translating from one
to the other is a simple matter of copy-pasting the code and translating
the syntax and small bits of grammar.

However, in areas where there are high variations; you'll probably want
to stay away from it.  Perl has a lot of freedom to manipulate
references and the programmer can modify the language to suit their
needs.  So just be careful of code that uses these features as they are
difficult to translate into Python.

> Any thoughts/recommendations?

Depends:

- If you needed it done yesterday to get some work done, wrap the Perl
  script in a subprocess and buy yourself some time to think it over.  
- If your purpose is to learn Python, then start from scratch.  Use the
  Perl as a guide if there are any maths or algorithms you are unsure
  about.
- If you're just hacking around to learn stuff, learn a little of both.
  It will make you smarter if it doesn't confuse the heck out of you and
  make you quit before you finish. ;)

> TIA,

> /Martin

HTH

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Schöön  
View profile  
 More options Dec 10 2009, 3:06 pm
Newsgroups: comp.lang.python
From: martin.sch...@gmail.com (Martin Schöön)
Date: Thu, 10 Dec 2009 21:06:14 +0100
Local: Thurs, Dec 10 2009 3:06 pm
Subject: Re: Perl to Python conversion
Thanks all, great response!

A little more background:

I am not a programmer but I have done some programming in the past.
This was all humble number crunching as part of my PhD project using
FORTRAN. I also did some Rocky Mountain Basic coding for programs
manipulating measurement instruments. And I did a minute amount
of Turbo Pascal code, too little and too many years ago to count.

Since then I have done some stuff in Matlab and (very basic) UNIX
scripts.

Does HTML, css and LaTeX count?

So why Python? Well, I thought it would be fun to learn a little
about GUI programming and a friend who is a real programmer recommended
Python + PyQt. I have bought some books and lurked here for about
a year but haven't managed to get going yet. I figured I needed
some kind of project for that and now I have two.

Learning Python and PyQt is spare time killer/brain teaser activity.

The thermal contact conductance stuff is something that come in
handy at work.

So here is what I plan to do based on your kind advice and some
thinking of my own.

1) I fix the unit thing by adding a conversion to the results
presentation routine.

2) Recreating the functionality of the program in Python and PyQt
will be a 'long term' educational project at home. There are
various bits and pieces there: data base handling, GUI design, math,
logic, error/exception handling...

We have long, dark winters where I live :-)

All the best,

/Martin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Colin W.  
View profile  
 More options Dec 12 2009, 12:22 pm
Newsgroups: comp.lang.python
From: "Colin W." <cjwilliam...@gmail.com>
Date: Sat, 12 Dec 2009 12:22:34 -0500
Local: Sat, Dec 12 2009 12:22 pm
Subject: Re: Perl to Python conversion
On 09-Dec-09 15:33 PM, Martin Sch n wrote:

Martin,

If you convert the Perl, you continue the other fellow's errors.  If you
do it yourself, you'll be able to make your own - there should be fewer
of them.

Google: unit conversion python

you'll have lots of offers.

Colin W.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
r0g  
View profile  
 More options Dec 13 2009, 4:08 pm
Newsgroups: comp.lang.python
From: r0g <aioe....@technicalbloke.com>
Date: Sun, 13 Dec 2009 21:08:50 +0000
Local: Sun, Dec 13 2009 4:08 pm
Subject: Re: Perl to Python conversion

I'd recommend you start from scratch and refer to the perl version if
and when you need to. You'll probably find the majority of code in a GUI
app is boring window handling stuff rather, often this is machine
generated (by progs like glade) rather than hand coded anyway so it will
probably provide little insight. Also, they probably didn't make it with
QT which is fairly different from GTK. It's like the housing industry,
demolition + newbuild is almost always cheaper than renovation. If you
can spare yourself the ordeal of learning perl and the chore of
interpreting somebody else's perl then grasp it with both hands!

Good luck. I'm sure you'll be fine - python is a deeply pleasing
language to work in :)

Roger.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Schöön  
View profile  
 More options Dec 13 2009, 5:23 pm
Newsgroups: comp.lang.python
From: martin.sch...@gmail.com (Martin Schöön)
Date: Sun, 13 Dec 2009 23:23:04 +0100
Local: Sun, Dec 13 2009 5:23 pm
Subject: Re: Perl to Python conversion

r0g <aioe....@technicalbloke.com> writes:

> I'd recommend you start from scratch and refer to the perl version if
> and when you need to.

That is my plan.

> You'll probably find the majority of code in a GUI
> app is boring window handling stuff rather, often this is machine
> generated (by progs like glade) rather than hand coded anyway so it will
> probably provide little insight. Also, they probably didn't make it with
> QT which is fairly different from GTK.

Tk is what they used.

/Martin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aahz  
View profile  
 More options Dec 25 2009, 1:35 pm
Newsgroups: comp.lang.python
From: a...@pythoncraft.com (Aahz)
Date: 25 Dec 2009 10:35:57 -0800
Local: Fri, Dec 25 2009 1:35 pm
Subject: Re: Perl to Python conversion
In article <87zl5rnayz....@crunchbang.Belkin>,

Martin =?utf-8?B?U2Now7bDtm4=?= <martin.sch...@gmail.com> wrote:

>Problem: I have come across a small open source application that I find
>quite useful. It does have one major flaw though.  Its output is in
>imperial units. Converting isn't a big deal for occasional use but if I
>start to use this stuff on a regular basis...

I'd write an imperial to metric converter in Python  ;-)
--
Aahz (a...@pythoncraft.com)           <*>         http://www.pythoncraft.com/

Looking back over the years, after I learned Python I realized that I
never really had enjoyed programming before.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Yeung  
View profile  
 More options Dec 25 2009, 2:54 pm
Newsgroups: comp.lang.python
From: John Yeung <gallium.arsen...@gmail.com>
Date: Fri, 25 Dec 2009 11:54:45 -0800 (PST)
Local: Fri, Dec 25 2009 2:54 pm
Subject: Re: Perl to Python conversion
On Dec 13, 5:23 pm, martin.sch...@gmail.com (Martin Schöön) wrote:

> r0g <aioe....@technicalbloke.com> writes:
> > You'll probably find the majority of code in a GUI
> > app is boring window handling stuff [...]
> > Also, they probably didn't make it with
> > QT which is fairly different from GTK.

> Tk is what they used.

Well, on the surface then, it would seem that it might be easier to
just use Python's included Tkinter for the GUI bits.  However, PyQt is
widely regarded as a nicer and more capable package.

John


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Brunning  
View profile  
 More options Dec 28 2009, 7:38 am
Newsgroups: comp.lang.python
From: Simon Brunning <si...@brunningonline.net>
Date: Mon, 28 Dec 2009 12:38:18 +0000
Local: Mon, Dec 28 2009 7:38 am
Subject: Re: Perl to Python conversion
2009/12/25 Aahz <a...@pythoncraft.com>:

> I'd write an imperial to metric converter in Python  ;-)

Should be possible to use unum (<http://bit.ly/4X0PwR>) to do the
conversions. The SI units are already defined - adding in any
necessary imperial units should be easy enough.

--
Cheers,
Simon B.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »