Cookie Notice



Question to Python Programmers

I am not a Python guy. I'm a Perl guy. I've tried it several times, and each time, I've found something that offended me about it. The first time, yes, was about whitespace. Finding the one SpaceTab intent in a page full of Tab indents took an hour and soured me. But the second time, the way Python's equivalent to LWP worked was seriously counterintuitive.

I've found something exciting and new that bugs me. Take this as a sample chunk of perl.

use This ;
use That ;
use The::Other::Thing ;

a() ;
for my $i ( b() ) {

sub a {

sub b {

sub c {

I edit a program and, after the declarations, all my central logic is up top. Compare a Python program.

import this
import that
import the_other_thing

def a:

def b:

def c:

b = b()
for i in b:

This puts the "main" of the program at the bottom. I couldn't even fake it and make a def main(): and put it somewhere, because it would have to come after all the functions it uses anyway, so it would be useless.

If programs are to be written for other programmers to read and only incidentally for computers to run, it seems like this forced formatting seems wrong. But I'm willing to be taught. Am I missing something on this one?