Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8025
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'python': 0.08; 'subject:string': 0.09; 'pm,': 0.10; 'wrote:': 0.14; 'library': 0.15; '2.6,': 0.16; 'slicing': 0.16; 'str.format()': 0.16; 'string:': 0.16; '\xa0to': 0.16; 'cc:addr:python-list': 0.17; 'mon,': 0.17; 'header:In-Reply-To:1': 0.21; 'cc:2**0': 0.22; 'parse': 0.23; 'received:209.85.161.46': 0.23; 'received:mail- fx0-f46.google.com': 0.23; 'versions': 0.23; 'extract': 0.25; 'match': 0.26; 'received:209.85.161': 0.26; 'string': 0.26; 'message-id:@mail.gmail.com': 0.28; 'import': 0.29; 'version': 0.29; 'cc:addr:python.org': 0.30; 'optimal': 0.30; 'subject:format': 0.30; "skip:' 10": 0.32; 'expression': 0.32; 'skip:\xa0 30': 0.32; 'question': 0.34; 'regular': 0.34; 'there': 0.35; '2.6': 0.35; '8bit%:3': 0.35; 'using': 0.35; 'received:google.com': 0.37; 'received:209.85': 0.37; '20,': 0.37; 'could': 0.38; 'subject:from': 0.38; 'but': 0.38; 'data': 0.38; 'earlier': 0.38; 'subject:: ': 0.38; 'some': 0.38; 'received:209': 0.39; 'johnson': 0.39; 'serving': 0.66; '12:14': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=Pkl9xUG6jFwjSvTWW4E80JgpeL81ifv59TyepokQrYI=; b=iZPH3pocAn+S71mHIZstZk/lBmHASq3LoEy0R3deVxe+qE93oK4ekwTPOzRGvuXgPj S79t1y2BUmam4w18bozIwezumN8r/krVteqKpY6Nwp2m1QfVKmakuwcmBydxk9dtnHG4 EoMDgxzPsZukPMAo12mhWrVl6x2fhJMLNvQ0o= |
| DomainKey-Signature | a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=I6wgvzcpKj29Juiq6uhrqOJNTRFKyOUThYKW6gJ7dWq693KEafEidV85mu4zQI5Nay kqtJ5V95JgxeoCatFPn1NGunMtrWF/BKA8utKO5/VWorZHUMzC7wF7HyHt04ILp7f5eK P3owh3Xckbmixx7JyQa6/uqK+y1R1tL2B6gtw= |
| MIME-Version | 1.0 |
| In-Reply-To | <20110620181446.GI1971@johnsons-web.com> |
| References | <20110620181446.GI1971@johnsons-web.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Mon, 20 Jun 2011 13:34:46 -0600 |
| Subject | Re: Parsing a dictionary from a format string |
| To | Tim Johnson <tim@johnsons-web.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | Python ML <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.189.1308598518.1164.python-list@python.org> (permalink) |
| Lines | 23 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1308598519 news.xs4all.nl 49174 [::ffff:82.94.164.166]:40367 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:8025 |
Show key headers only | View raw
On Mon, Jun 20, 2011 at 12:14 PM, Tim Johnson <tim@johnsons-web.com> wrote:
> Currently using python 2.6, but am serving some systems that have
> older versions of python (no earlier than.
> Question 1:
> With what version of python was str.format() first implemented?
2.6
> Question 2:
> Given the following string:
> S = 'Coordinates: {latitude}, {longitude}'
> Is there a python library that would provide an optimal way
> to parse from S the following
> {'latitude':"",'longitude':""}
> ?
import re
match = re.match('^Coordinates: (.+), (.+)$', S)
if match:
data = {'latitude': match.group(1), 'longitude': match.group(2)}
Or you could use string methods and slicing to extract the figures,
which would be faster than the regular expression machinery.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Parsing a dictionary from a format string Ian Kelly <ian.g.kelly@gmail.com> - 2011-06-20 13:34 -0600
csiph-web