[Edu-sig] Python as a first language for computer scientist

Kirby Urner urnerk at qwest.net
Thu Oct 20 02:01:27 CEST 2005


> At this point, most of the things that I would think would be most
> difficult to understand about Python - for someone coming to it fresh - 
> would be the artifacts of transitions and changes. i.e. new style and old 
> style classes, list comprehension vs generator comprehensions, div old vs 
> div new, @property, and I am sure many others that don't come to me off 
> the top of my head.  

My inclination is to from __future__ import everything in the default
startup module, i.e. just use the new / and // without telling the history.
1/2 returns 0.5 (float type), 1//2 returns 0 (integer type) 'nuff said.
There's also a module-level directive for globally making all classes
inherit from 'object' I think -- or am I dreaming?
 
@property, like @classmethod and @staticmethod, is just syntax for wrapping
a function around another function defined right after, according to the
pattern: 

@xxx
def function():  
    pass

=>

def function():  
    pass
function = xxx(function)

The bottom pattern was being frustrating because you'd do this critical
operation *after* a (perhaps lengthy) function def.  Top-down parsing
demanded that.  The decorator was a solution and parsing is still top down.

Advanced topic:  Sometimes Scott and friends like to add another layer of
indirection, i.e. have @xxx(args) return a function that *then in turn*
wraps the following function.

I'm OK with 'global' so far (haven't seen the Alex Martelli thread you
mention).  But hey, I'm coming from FoxPro, which is really heavy on its use
of 'public' (vs. 'local').

Kirby




More information about the Edu-sig mailing list