OO misconceptions

Tim Hammerquist tim at vegeta.ath.cx
Wed Jul 18 01:53:08 EDT 2001


Me parece que Peter Hansen <peter at engcorp.com> dijo:
> François Pinard wrote:
> > [Steve Holden]
> > > Suppose a Perl-to-Python conversion were possible (and I'm not suggesting
> > > it isn't): would it be the kind of Python you'd want to use to teach the
> > > language?
> > 
> > Surely not.  The idea is not to use it to teach Python, but to help quickly
> > migrating already written Perl code to Python.
> 
> I imagine that the Python code produced by such a creature
> would be more readable (to me!) than the original Perl code,
> even if it were to produce code which was considered pretty 
> hideous.

Actually, I have a snippet of code I'd love to be able to convert to
Python.  The only thing is I can't find a Python equivalent for Perl's
record separator variable ($/).  This is from 'Perl Cookbook' (ORA).

sub pick_quote {
	my $sigfile = 'filename';
	open (SIGS, "< $sigfile") or die "can't open $sigfile";
	local $/ = "%%\n";
	local $_;
	my $quip;
	rand($.) < 1 && ($quip = $_) while <SIGS>;
	close SIGS;
	chomp $quip;
	return $quip || "ENOSIG: This signature file is empty.\n";
}

Any ideas/suggestions?

TIA
-- 
It's astonishing how much trouble one can
get oneself into, if one works at it.
    -- Destruction, The Sandman



More information about the Python-list mailing list