[Omaha.pm] Re: [oma-python] an almost-switch statement
Jay Hannah
jay at jays.net
Fri Jun 11 20:39:46 CDT 2004
On Jun 10, 2004, at 6:30 AM, Mike Hostetler wrote:
> Here is an example of real working code that decodes a list of Unicode
> strings into latin-1:
> goodProcRef = map(lambda x: x.decode("latin-1"), goodProcRef)
How do you use that? (Can I get some context code?)
> But these days most people are leaving lambda's behind and using
> generators for a lot of there stuff.
>
> http://c2.com/cgi/wiki?GeneratorsInPython
> http://www-106.ibm.com/developerworks/linux/library/l-pythrd.html
My brain just melted. -grin-
> It's a bit different than the Python version above -- basically the
> same as
> DB = lambda x: x+42
Ya. Perl
$f = sub { $_[0] + 42 }
> I don't mind using modules in Perl that give back object and using
> their methods/attributes. But it get's funky sometimes. And I've
> never made my own class in Perl, but I've never really needed to.
my $m = new Mike;
print $m->status;
package Mike;
sub new {
bless {};
}
sub status {
ref($_[0]) . " rules!";
}
Grin,
j
More information about the Omaha-pm
mailing list