Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80517 > unrolled thread

What is ?s here?

Started bysatishmlmlml@gmail.com
First post2014-11-11 01:37 -0800
Last post2014-11-11 17:34 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  What is ?s here? satishmlmlml@gmail.com - 2014-11-11 01:37 -0800
    Re: What is ?s here? Denis McMahon <denismfmcmahon@gmail.com> - 2014-11-11 17:34 +0000

#80517 — What is ?s here?

Fromsatishmlmlml@gmail.com
Date2014-11-11 01:37 -0800
SubjectWhat is ?s here?
Message-ID<a4b767a7-9669-4b4a-8068-63c23c2ef1c0@googlegroups.com>
What does ?s do in the following piece of code?

import re, pprint
text = open('books.xml').read()
pattern = '(?s)isbn="(.*?)".*?<title>(.*?)</title>'
found = re.findall(pattern, text)
mapping = {isbn: title for (isbn, title) in found}
pprint.pprint(mapping)

Here is books.xml

<catalog>
       <book isbn="0-596-00128-2">
             <title>Python &amp; XML</title>
             <date>December 2001</date>
             <author>Jones, Drake</author>
       </book>
</catalog>

[toc] | [next] | [standalone]


#80544

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2014-11-11 17:34 +0000
Message-ID<m3thb9$vod$2@dont-email.me>
In reply to#80517
On Tue, 11 Nov 2014 01:37:21 -0800, satishmlmlml wrote:

> What does ?s do in the following piece of code?

It tells you to learn about regex.

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web