Re: [Tutor] Fwd: find second occurance of string in line

2015-09-09 Thread Laura Creighton
Peter Otten >Those who regularly need different configurations probably use virtualenv, >or virtual machines when the differences are not limited to Python. Use tox for this. https://testrun.org/tox/latest/ However for development purposes it often helps to have a --force the_one_that_I_want opt

Re: [Tutor] Fwd: find second occurance of string in line

2015-09-09 Thread Peter Otten
Albert-Jan Roskam wrote: >> To: tutor@python.org >> From: __pete...@web.de >> Date: Tue, 8 Sep 2015 21:37:07 +0200 >> Subject: Re: [Tutor] Fwd: find second occurance of string in line >> >> Albert-Jan Roskam wrote: >> >> >> import lxml.

Re: [Tutor] Fwd: find second occurance of string in line

2015-09-08 Thread Peter Otten
Albert-Jan Roskam wrote: >> import lxml.etree >> >> tree = lxml.etree.parse("example.xml") >> print tree.xpath("//objectdata/general/timestamp/text()") > > Nice. I do need to try lxml some time. Is the "text()" part xpath as well? Yes. I think ElementTree supports a subset of XPath. __

Re: [Tutor] Fwd: find second occurance of string in line

2015-09-08 Thread Peter Otten
richard kappler wrote: >> Do you want to find just the second occurence in the *file* or the second > occurence within a given tag in the file (and there could be multiple such > tags)? > > There are multiple objectdata lines in the file and I wish to find the > second occurence of timestamp in e

[Tutor] Fwd: find second occurance of string in line

2015-09-08 Thread richard kappler
> Do you want to find just the second occurence in the *file* or the second occurence within a given tag in the file (and there could be multiple such tags)? There are multiple objectdata lines in the file and I wish to find the second occurence of timestamp in each of those lines. > Is objectdat