[FRPythoneers] Porting perl to python

Karl Putland karl at putland.linux-site.net
Fri Jul 11 15:39:44 MDT 2003


Some links about the subject:

http://mail.python.org/pipermail/python-list/1999-August/009692.html
http://mail.python.org/pipermail/python-list/1999-August/009693.html
http://search.cpan.org/author/GAAS/pyperl-1.0/perlmodule.pod

--Karl


On Fri, 2003-07-11 at 15:29, Erick Bodine wrote:
> Howdy Jake,
> 
> Either your suggestion or Jake Dietrich's solution will work.
> 
> Many thanks,
> 
> --ERick
> 
> 
> -----Original Message-----
> From: Jake Edge [mailto:jake at edge2.net] 
> Sent: Friday, July 11, 2003 11:45 AM
> To: frpythoneers at lists.community.tummy.com
> Subject: Re: [FRPythoneers] Porting perl to python
> 
> 
> On Fri, Jul 11, 2003 at 11:32:15AM -0600, Erick Bodine wrote:
> > I have tried various manipulations using the dir() and callable() 
> > builtins to no avail.  I think that 'recipe' 15.3 in the Python 
> > cookbook might contain some clues (some manipulation around 
> > __import__) but I am not really familiar w/ how this works in Python.
> > 
> > Any help would be appreciated.
> > 
> > # Perl code
> > my (@tests) = qw(domain_administrator
> > 		 scrubber_registry_size
> > 		 pr2051);
> > 
> > foreach my $test_name ( @tests ) {
> >   print "$test_name ", ("." x (26 - length($test_name))), " ";
> >   my ($rc, $reason) = &$test_name;
> > }
> > 		 
> > # Python code
> > def_list = ['test1', 'test2', 'test3]
> > for f in def_list:
> > 	f()			# This won't work because f is not
> > callable
> 
> Hi Erick,
> 
> Perhaps instead of strings, you just want to put function references in
> the list as the following illustrates:
> 
> def foo(bar):
>     print bar
> 
> def bar(xyz):
>     print xyz
> 
> fn_list = [ foo, bar ]
> for i in fn_list:
>     i(42);
> 
> would that work for you?
> 
> jake
-- 
Karl Putland <karl at putland.linux-site.net>




More information about the FRPythoneers mailing list