recording data between [ and ]

Diez B. Roggisch deetsNOSPAM at web.de
Thu Apr 21 11:03:33 EDT 2005


> Yes, it does... may take me a few minutes to get my head around it
> though. Why do re's have to be so arcane and complicated... especially
> in Python?
> 
> It's hard to preach 'ease of use' with stuff such as this in the
> language. Perhaps one day it can be rolled up into something that
> *really* is easy to understand:

Welcome to the wonderful world of programming. Regular expressions are what
they are because they are modeled after a certain theory - that of finite
state automata and their correspondence to certain classes of grammars. And
they require a bit of understanding. And there is no language that does
them different - some integrate them syntactically (like perl), others
don't have them available in the standard lib at all. But if you get them,
they always look like that.

> import string
> 
> fp = file('filename')
> data = fp.read()
> fp.close()
> 
> string.between(data,[,])

how about

import whatever_is_needed
solve_my_problem()

? Seriously: Programming or maybe better saying the way we tell computers
what to do might evolve by standardization to a point where lots of tasks
get easier.You actual problem might be solved easier one day if
commandline-tools agree on a specific output format (viewed from today
thate means possibly xml) and standard tools to deal with these.

But as the world is complex and people want solutions to their complex
problems, IMHO programming will always be about such nitty gritty details. 


-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list