[Israel.pm] A bit about Python

Shmuel Fomberg semuelf at 012.net.il
Mon Nov 16 21:15:22 PST 2009

Hi All.

I have been looking on Python in the last weeks, and a few thoughts:

they (the python world) hate mini-languages, and prefer objects with a 
lot of methods.

for example, instead of sprintf("%10s", ...) they have string.ljust method.

Python include a regex engine, but they really hate the idea. so I see 
explanations like:

"Regex is never the answer, except when it is". maybe it is connected to 
their hate for

mini languages.

The closure mechanizem is pretty weak, and can be better describe as 
constants placing, and is reduced to one liner.

(something like: lambda x: x * value)

Trying to cover for the weak closure, they have a 'generator' functions, 
with special command - yield.

def Counter(start)

   x = start

   while x < 7:

       yield x

       x = x + 1

so after we create the Counter, every time we call Counter.next the 
program return to the loop and run until the yield command.

As much as I can see there is no way to pass parameter to the next command.

A plus side is that this generator can work with a for loop, that will 
stop when the generator exits.

for e in Counter(5)

in Python, there is a map and filter functions. they don't like them 
very much, and the new syntex is:

newList = [e*2 for e in oldList if e > 3]

I don't know if I like this writing, because the flow zig-zags. starts 
with the "for e in oldList", then goes to the right with "if e > 3", and 
then to the left with "e*2".

after years of maping and greping I'm used to see data flows in one 

A weird thing about objects and inheritance: when calling a super's 
function, we can't call $self->SUPER::func(...) of like Moose super(). 
(if I remember correctly) we call the super function by name. 
MyBase.func(self, ...).

And I'm missing CPAN. they don't have a main archive of modules, but 
every module have his own website.

That's what I can remember right now.

Good morning.


More information about the Perl mailing list