Jim Carson in Bellevue is doing 5 things including…

learn python

3 cheers

Jim Carson has written 3 entries about this goal

Finished my first mostly-useful program 1 year ago

I finished my first semi-useful program today. I probably wrote 800 lines of code, during the run, debug, repeat process just trying to unwrap my mind from the Perl Way and get used to Python’s Way.

The final thrust today was figuring out how to use regular expressions to pluck things from a configuration file. It’s something I can do in Perl in my sleep, with one hand on a cup of coffee. For example, this:

while (|STDIN|) {
if (/^([SV])_(\w+)=(\w+)/) {
($blah, $di, $blahblah) = ($1,$2,$3);
}
}

does what I want, took a minute to write, but, arguably, looks I let the coffee spill on the keyboard. (43things won’t let me use the lessthan/greater than signs, hence the pipes) The python n00b equivalent took a while to work out the invocation of the re functions.

foo = re.compile('^([SV])_(\w+)=(\w+)',re.VERBOSE)
while 1:
line = f.readline()
if not line:
break
match = foo.search(line)
if match:
blah, di, blahblah = match.groups()
I miss curly braces as visual delimiters where a function ends, especially as I’ve been burned by the incorrect indentation, but being encouraged to write smallish functions like this:

def get_config_file(x):
for i in a_list_i_made_up:
if os.environ.has_key(i):
if exists(join(os.environ[i], x)):
return join(os.environ[i], x)
exit

seems like a long-term win.


A question about this goal: Any suggestions on easing the transition from perl to python? 1 year ago


Finding time and a projectlet to focus on... 1 year ago

I’ve worked through a simple fast Fourier transform example that I used as the basis for a mock-up. However, for me to be successful, I will need to identify and build a mini-project (aka “projectlet”). Several of my coworkers are out of town/on vacation this week, offering an opportunity to do it this week. (I hope)

I have access to various linux machines, including my web server, but will probably use my windows desktop to tinker. I’ve had great luck with ActiveState’s “ActivePerl” on Windows, and expect the same with their python distribution

In addition to the online version of the book Kiri recommended, I am working with a hardcopy of Python: Essential Reference



Jim Carson has gotten 3 cheers on this goal.

 

I want to:

The world wants to...