f



python

I am handled a Python script to re-use a part of it.
I have to options.
Modify Python script and and catch its STDOUT or write the whole code as 
a Perl module.
Is there any other way to include Python code on a Perl script;
0
9/20/2013 3:31:32 PM
comp.lang.perl.misc 33233 articles. 2 followers. brian (1246) is leader. Post Follow

2 Replies
579 Views

Similar Articles

[PageSpeed] 22

On Friday, September 20, 2013 11:31:32 AM UTC-4, George Mpouras wrote:
> I am handled a Python script to re-use a part of it.

Have you tried writing a Perl script that calls the Python script?

Does the Python script return data values? Perhaps it writes to an output f=
ile that you can open and munge in Perl.

You can also try writing a shell script that (1) runs the Python script, (2=
) saves the output in a particular place, and (3) runs the Perl script that=
 accepts the output as input.

I find that Perl and Python are good at different things. Ideally, you shou=
ld use the same language for the same task, just as a matter of sanity, rew=
riting as necessary in the language you choose. However, I don't object to =
having a process that uses different languages to handle different parts, a=
nd I have some processes that use Perl, ColdFusion, Visual Basic, and even =
Transact/SQL (Microsoft DTS) for different parts.

CC.
0
cartercc (463)
9/20/2013 7:04:48 PM
Στις 20/9/2013 22:04, ο/η ccc31807 έγραψε:
> On Friday, September 20, 2013 11:31:32 AM UTC-4, George Mpouras wrote:
>> I am handled a Python script to re-use a part of it.
>
> Have you tried writing a Perl script that calls the Python script?
>
> Does the Python script return data values? Perhaps it writes to an output file that you can open and munge in Perl.
>
> You can also try writing a shell script that (1) runs the Python script, (2) saves the output in a particular place, and (3) runs the Perl script that accepts the output as input.
>
> I find that Perl and Python are good at different things. Ideally, you should use the same language for the same task, just as a matter of sanity, rewriting as necessary in the language you choose. However, I don't object to having a process that uses different languages to handle different parts, and I have some processes that use Perl, ColdFusion, Visual Basic, and even Transact/SQL (Microsoft DTS) for different parts.
>
> CC.
>



there is the Inline::Python
too late now (i rewrite it to Perl) no one mention it , thanks ...

0
9/23/2013 7:46:16 PM
Reply:

Similar Artilces:

deisng perl perl programmibng langs in perl
then liberate big war zones with notes on their download pages. -r www.thevoid1.net/ ...

lang comparison: in-place algorithm for reversing a list in Perl, Python, Lisp
fun example. in-place algorithm for reversing a list in Perl, Python, Lisp http://xahlee.org/comp/in-place_algorithm.html plain text follows ---------------------------------------- What's =93In-place Algorithm=94? Xah Lee, 2012-02-29 This page tells you what's =93In-place algorithm=94, using {python, perl, emacs lisp} code to illustrate. Here's Wikipedia In-place algorithm excerpt: In computer science, an in-place algorithm (or in Latin in situ) is an algorithm which transforms input using a data structure with a small, constant amount of extra storage space. The input is u...

Python re expr from Perl to Python
In Perl, it was: ## Example: "Abc | def | ghi | jkl" ## -> "Abc ghi jkl" ## Take only the text betewwn the 2nd pipe (=cut the text in the 1st pipe). $na =~ s/\ \|(.*?)\ \|(.*?)\ \|/$2/g; ## -- remove [ and ] in text $na =~ s/\[//g; $na =~ s/\]//g; # print "DEB: \"$na\"\n"; # input string na="Abc | def | ghi | jkl [gugu]" # output na="Abc ghi jkl gugu" How is it done in Python? "Michael M." <michael@mustun.ch> writes: > In Perl, it was: > > > ## Example: "Ab...

dict slice in python (translating perl to python)
Hi, Let's take following perl code snippet: %myhash=( one => 1 , two => 2 , three => 3 ); ($v1,$v2,$v3) = @myhash{qw(one two two)}; # <-- line of interest print "$v1\n$v2\n$v2\n"; How do I translate the second line in a similiar compact way to python? Below is what I tried. I'm just interested in something more compact. mydict={ 'one' : 1 , 'two' : 2 , 'three' : 3 } # first idea, but still a little too much to type [v1,v2,v3] = [ mydict[k] for k in ['one','two','two']] # for long lists lazier...

[perl-python] Python documentation moronicities (continued)
http://python.org/doc/2.4.1/lib/module-re.html http://python.org/doc/2.4.1/lib/node114.html --------- QUOTE The module defines several functions, constants, and an exception. Some of the functions are simplified versions of the full featured methods for compiled regular expressions. Most non-trivial applications always use the compiled form UNQUOTE What does a programer who wants to use regex gets out from this piece of motherfucking irrevalent drivel? ---------- QUOTE compile( pattern[, flags]) Compile a regular expression pattern into a regular expression object, which can be used for ...

Re: dict slice in python (translating perl to python}
MRAB <googl....arnett.plus.com> wrote: >On Sep 11, 6:11 pm, Fredrik Lundh <fred...@pythonware.com> wrote: >[snip] >> (the next step towards true Pythonicness would be to store your data in 8<----------------------- >> >Surely the word is "Pythonicity"? :-) When faced with the choice between "Pythonicness" and "Pythonicity", I feel a bit like Ogden Nash must have felt when he wrote: The Camel has a single hump, The Dromedary, two. Or the other way around. I'm never sure, are you? - Hendrik ...

python or perl
I often hear that perl and python are useful languages to remedy Matlab, and these combined with Matlab make a lot of work easier. If that is the case, which of the two is more recommended? Thanks On Mon, 04 Apr 2005 12:49:43 -0700, b83503104@yahoo.com wrote: > I often hear that perl and python are useful languages to remedy > Matlab, and these combined with Matlab make a lot of work easier. > > If that is the case, which of the two is more recommended? > Thanks Probably depends on what you're trying to do, and which language you know better. For matching and manipulat...

perl to python
Hello , What is the python way of doing this : perl -pi -e 's/string1/string2/' file ? Thanks Olivier Olivier Scalbert <olivier.scalbert@algosyn.com> pisze: > What is the python way of doing this : > perl -pi -e 's/string1/string2/' file Use sed. -- Jarek Zgoda http://jpa.berlios.de/ Jarek Zgoda wrote: >Olivier Scalbert <olivier.scalbert@algosyn.com> pisze: > > > >>What is the python way of doing this : >>perl -pi -e 's/string1/string2/' file >> >> > >Use sed. > > > yes, but in python ?...

OpenGL Benchmarks: C vs Perl, Perl vs Python
Just posted several OpenGL benchmarks: C vs Perl, Perl vs Python, and SDL::OpenGL vs POGL http://graphcomp.com/opengl/benchmarks Cheers! - Bob On May 23, 11:34 am, "visitor" <visi...@msn.com> wrote: > Just posted several OpenGL benchmarks: C vs Perl, Perl vs Python, and > SDL::OpenGL vs POGL > > http://graphcomp.com/opengl/benchmarks > So you established that calling "glutWireTeapot();" runs at about the same speed in Perl as it does in C, that display lists run just as fast in Python as in C, and that Vista does OpenGL via an emulation la...

Perl or Python
Hi, I am looking for a scripting language that I can use for GUI, file I/O, process management, and SQL access. I am looking at Perl or Python. Which is a better language for the above mentioned tasks? Any opinions are appreciated. Michael On Sat, 11 Dec 2004 21:47:48 -0700, Michael McGarry <replytogroup@nospam.org> wrote: >Hi, > >I am looking for a scripting language that I can use for GUI, file I/O, >process management, and SQL access. I am looking at Perl or Python. >Which is a better language for the above mentioned tasks? > >Any opinio...

python is a python
python is a python ...

Sydney Python Meetup July 21: Python, Perl, and Cold Beverages
Date: Thursday July 21 Time: 6:00pm-8:30pm, with drinks and food during and after. Topics: Graham Dumpleton on The Vampire mod_python extension Paul Fenwick "So you want to start a business?" Place: James Squires Brewhouse 2 The Promenade, King St Wharf Sydney Fee: $0.00 The Sydney Python meetup group is on this Thursday. The meeting time has been brought forward half an hour, and the formal part of the evening will commence promptly at 6:30pm. The James Squires Brewhouse managed to book the Python Meetup Group and the Perl Mongers in adjoining rooms for the same night. Everybody has promised to be nice and we'll be combining with them to hear from one of their Melbourne gurus. As always, everybody is welcome. Graham Dumpleton, author of Vampire, will be speaking first (6:30-7:30). He describes his presentation thusly: "Although I'll talk a bit about the motivations behind writing Vampire and why this extra layer on top of mod_python is useful, what I want to talk about more is what I have learnt from writing Vampire. From that I would like to go on to describe a new and better way of doing this same thing for mod_python that Vampire attempted to do. This new approach moves even further away from the monolithic framework approach towards small building blocks of functionality that can be slotted together to build up a web application how you want it and not...

Perl s/ To Python?
Does anyone know of a quick way of performing this: $testVar =~ s#/mail/.*$##g The only way I can think of doing it, is: mailPos = testVar.find( "mail" ) remainder = testVar[ :mailPos ] Any ideas would be appreciated. I'm iterating over a lot of entries, and running these lines for each entry. J Dnia Fri, 10 Jun 2005 14:57:21 +0100, John Abel napisa�(a): > $testVar =~ s#/mail/.*$##g > > The only way I can think of doing it, is: > > mailPos = testVar.find( "mail" ) > remainder = testVar[ :mailPos ] > > Any ideas would be appreciate...

Perl Versus Python
I've read some posts on Perl versus Python and studied a bit of my Python book. I'm a software engineer, familiar with C++ objected oriented development, but have been using Perl because it is great for pattern matching, text processing, and automated testing. Our company is really fixated on risk managnemt and the only way I can do enough testing without working overtime (which some people have ended up doing) is by automating my testing. That's what got me started on Perl. I've read that many people prefer Python and that it is better than Perl. However, I want to ask a few other questions. 1. Perl seems to have alot of packaged utilities available through CPAN, the comprehensive perl network. These can aid in building parsers, web development, perl DBI is heavily used. This seems to be a very important benifit. I'm not sure that Python is as extenive at all in that regard ? Perl also has excellent pattern matching compared to sed, not sure about how Python measures up, but this seems to make perl ideally suited to text processing. 2. Python is apparantly better at object oriented. Perl has some kind of name spacing, I have used that in a limited way. Does Perl use a cheap and less than optimal Object oriented approach ? That was what someone at work said, he advocates Python. Is it likely that Perl will improve it's object oriented features in the next few years ? 3. Perl is installed on our system and alot of other systems. You don't...

why scheme over perl or python?
why? "gavino" <bootiack@yahoo.com> writes: > why? If you have to ask it, then you can't afford the answer. -- __Pascal Bourguignon__ http://www.informatimago.com/ "You question the worthiness of my code? I should kill you where you stand!" gavino wrote: > why? Irrational non-conformism? I guess what it basically comes down to is that every time I read about Python, I didn't find anything that makes me think, "I have to try that language!" Yet, just about every time I read about Scheme, I found things that made ...

luatex: perl or python?
Hello! I have a confusion. This far, TeX has been seeming to behave a bit like pyt= hon, i.e. you need to precompile a binary object (a format) which is then l= oaded at execution time to save time and space in the typesetting process. = With LuaTeX and new, faster, bigger CPUs, the time saved is negligible; so,= will LuaTeX behave a bit more like perl, i.e. you may load TeX macros dire= ctly, bypassing the need to load a precompiled binary format? AFAIK, having= getting rid of the need of a pool of strings, LuaTeX doesn't even need the= only process where I see formats may st...

PYTHON WORKING WITH PERL ??
To All, I was wondering if it was possible to have a situation where a programming project would utilized BOTH python and perl? Such as utilizing python for internet programming and then utilize perl for text processing and systems programming? Is this even feasible??? Thanks, David Blubaugh This e-mail transmission contains information that is confidential and = may be=20 privileged. It is intended only for the addressee(s) named above. If you = receive=20 this e-mail in error, please do not read, copy or disseminate it in any = manner.=20 If you are not the intended recipient, a...

python and s-lang
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I was just wondering if anyone has looked into using Python instead of, or in additon to, s-lang modules. Does slrn support the use of other interpreted languages ? (I hate the term scripted languages; very innacurate of modern interpreted languages). Given the fact that Python is as flexible and powerful as it is, and given the fact that it was designed to interface with such languages as C, it seemed natural that someone must have done this if it is possible. I would like to hear from those individuals, or anyone with programming experience (a...

Python is overtaking Perl
Here are the statistics from Google Trends: http://benyang22a.blogspot.com/2007/09/perl-vs-python.html On Tue, 04 Sep 2007 00:32:23 -0000 Ben <benyang22@gmail.com> wrote: > Here are the statistics from Google Trends: > > http://benyang22a.blogspot.com/2007/09/perl-vs-python.html > This chart is showing that amount of python programers is smaller every year :( On Sep 4, 10:49 am, Sulsa <su...@gazeta.pl> wrote: > On Tue, 04 Sep 2007 00:32:23 -0000 > > Ben <benyan...@gmail.com> wrote: > > Here are the statistics from Google Trends: > > &g...

TCL with Perl or Python?
Hi First post here.. so no flaming please. This post is NOT an attempt to start a flame war between Perl and Python folks. I've been using TclTk in my work for a few years now. Some of the TclTk gui's are used with either csh or perl scripts to run programs that can't be run easily from within Tcl. I've also heard or seen a lot about how great Python is but what I would like to know is just what are the advantages of using Python over Perl when working with a gui created with TclTk (I use Vtcl to initially create the gui). At one point I had the impression that Python was...

Python versus Perl
Dear all, I'm currently comparing Python versus Perl to use in a project that involved a lot of text processing. I'm trying to determine what the most efficient language would be for our purposes. I have to admit that, although I'm very familiar with Python, I'm complete Perl noob (and I hope to stay one) which is reflected in my questions. I know that the web offers a lot of resources on Python/Perl differences. But I couldn't find a satisfying answer to my questions: 1 - How does the speed of execution of Perl compares to that of Python? 2 - Regular Expressions a...

RE: perl to python
First off, this isn't even remotely a slam, so I hope it's not taken as = such. My question is this. Why bother with getting perl code translated into python code? Perl is probably one of the best string manipulation and RegEx = processors ever. Python is probably one of the easist general purpose scripting languages = ever. They don't have to overlap. With Python's pipe handling there's little = reason not to simply leave the perl code where it is and run it from an = orchestration script in Python. Perl is a pretty involved, terse and comprehensive wheel. Not sure I...

regexp in Python (from Perl)
I have a regexp in Perl that converts the last digit of an ip address to '9'. This is a very particular case so I don't want to go off on a tangent of IP octets. ( my $s = $str ) =~ s/((\d+\.){3})\d+/${1}9/ ; While I can do this in Python which accomplishes the same thing: ip = ip[ :-1 ] ip =+ '9' I'm more interested, for my own edification in non-trivial cases, in how one would convert the Perl RE to a Python RE that use groups. I am somewhat familiar using the group method from the re package but I wanted to know if there was a one-line solution. Thank you. Pat a �crit : > I have a regexp in Perl that converts the last digit of an ip address to > '9'. This is a very particular case so I don't want to go off on a > tangent of IP octets. > > ( my $s = $str ) =~ s/((\d+\.){3})\d+/${1}9/ ; > > While I can do this in Python which accomplishes the same thing: > > ip = ip[ :-1 ] > ip =+ '9' or: ip = ip[:-1]+"9" > I'm more interested, for my own edification in non-trivial cases, in how > one would convert the Perl RE to a Python RE that use groups. I am > somewhat familiar using the group method from the re package but I > wanted to know if there was a one-line solution. Is that what you want ? >>> re.sub(r'^(((\d+)\.){3})\d+$', "\g<1>9", "192.168.1.1") '192.168.1.9' >>> re.sub(r'^(((...

perl vs python
Which one is best among perl and python ??? I know python and perl are different languages. But there are substitute of python like java, C#, etc similarly for perl there is so many substitutes. But these languages are useful. But which one is best for future ??? On Mon, 15 Sep 2008 12:07:06 -0700 (PDT), asit <lipun4u@gmail.com> wrote: > Which one is best among perl and python ??? Learn both. They are both nice languages, and they have thriving, wonderful communities of very smart people. In article <0d8abd5a-3eb3-4c14-a84e-2716f10fe665@p10g2000prf.googlegroups.com>, asi...

Regex: Perl to Python
Hi, I'm trying to move away from Perl and go to Python. Regex seems to bethe hardest challenge so far. Perl: while (<HEADERFILE>) { if (/(\d+)\t(.+)$/) { print $1." - ". $2."\n"; } } into python pattern = re.compile(r"(\d+)\t(.+)$") with open(fields_Indexfile,mode="rt",encoding='utf-8') as headerfile: for line in headerfile: #sys.stdout.write(line) m = pattern.match(line) print(m.group(0)) headerfile.close() but I must be getting something fundamentally wrong because: Traceback (most recent call last): File "./slicer.py", line 30, in <module> print(m.group(0)) AttributeError: 'NoneType' object has no attribute 'group' why is 'm' a None? the input data has this format: : 3 prop1 4 prop2 5 prop3 Thanks On Mon, Mar 7, 2016 at 3:38 PM, Fillmore <fillmore_remove@hotmail.com> wrote: > pattern = re.compile(r"(\d+)\t(.+)$") > with open(fields_Indexfile,mode="rt",encoding='utf-8') as headerfile: > for line in headerfile: > #sys.stdout.write(line) > m = pattern.match(line) > print(m.group(0)) > headerfile.close() > > but I must be getting something fundamentally wrong because: > > Traceback (most recent call last): > File "./slicer.py...

Web resources about - python - comp.lang.perl.misc

Python - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Pregnant woman bitten by python in bedroom
A pregnant woman remained "calm" after she was bitten by a python in her bedroom at the Sunshine Coast.

Five cats eaten by pythons in one month in Cairns
Ever heard the saying curiosity killed the cat? Well in North Queensland, curiosity, and pythons, killed five cats in one month.

106 Burmese pythons captured in Florida hunt, including 15-footer
AL.com 106 Burmese pythons captured in Florida hunt, including 15-footer AL.com DAVIE, Fla. (AP) — The 106 Burmese pythons captured over a ...

Ars Cardboard classics—the stupid fun Monty Python Fluxx
... embarrassment. But it was absolutely true that I wanted those two extra cards. And that, ladies and gentleman is the joy of Monty Python- themed ...

Local python hitches ride in Zimbabwean farmer's engine bay
Filed under: Humor , Ownership , Weird Car News , Ford , Safety , Africa , Truck Serpentine belts are an integral part of a car's engine. Actual ...

Successful Snake Hunt Shines Light On Florida’s Python Problem
After a monthlong snake hunt, the 106 Burmese pythons captured in Florida may not put a dent in the invasive species' growing numbers, but wildlife ...

On the hunt to get rid of Florida's invasive pythons - Videos - CBS News
The hunt is on in the Florida Everglades for Burmese pythons, an out-of-control snake species. They’re not venomous, but they are big, strong ...

Don’t be afraid of Python; charm it instead
Python lives up to its name as one of the most flexible and far-reaching languages in web development. Like all coding languages, it can seem ...

Save hundreds on the Python Programming Bootcamp
Save hundreds on the Python Programming Bootcamp

Resources last updated: 3/8/2016 5:04:15 AM