Re: question about endswith()

2011-03-04 Thread Mauro Caceres
if you could define extension to be a tuple, you could use it this way, which is a little simpler: extensions = ('hdf5',) #works files = ('MOD03.A2010002.1810.005.2010258062733.hdf','MOD03.A2010002.1950.005.2010258063105.hdf','MOD03.A2010002.1950.005.2010258063105.hdf5') for filename in files:

Re: Extending classes __init__behavior for newbies

2011-02-14 Thread Mauro Caceres
> > > Where is the buggy code? Show me how Ship.__init__() can break. Anyone > can argue, few can offer facts. If you bring an argument that > Ship.__init__() can break if someone changes the code then that IS NOT > an valid argument. ANY code can be broken with the addition or > subtraction of a s

Re: returning all matching groups with re.search()

2011-02-07 Thread Mauro Caceres
>>> import re >>> help(re.findall) Help on function findall in module re: findall(pattern, string, flags=0) Return a list of all non-overlapping matches in the string. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the patte

Re: Short circuting

2011-01-24 Thread Mauro Caceres
Another option could be something like this: You can add ids to your regexp, so you can retrive them latter using groupdict. Once you have the ids in place, you can join in a new regexp with the "|" operator which is not greedy, it will stop after the first match. pattern = (?Pre_section)|?Pre_se

Re: Books recommendation

2010-12-07 Thread Mauro Caceres
> > > I am also interested to find where I can get Python modules from and how... > similar tools and sites with cpan and ppm for Perl. > > You should look at http://pypi.python.org/pypi, for modules. pip (http://pip.openplans.org/) is a tool used to install python modules. enjoy -- Mauro Cácer