Python-list Digest, Vol 118, Issue 144

Ben Last ben at benlast.com
Thu Jul 18 03:29:06 CEST 2013


> From: Gregory Ewing <greg.ewing at canterbury.ac.nz>
> To: python-list at python.org
> Is 'dash' the same as 'literal("-")'?
>
Yes, it's a convenience method, like 'dot' and 'underscore'.  The code I
pasted is from the unit tests, where I use the different methods to push
coverage up.


> Is there any difference between 'then' and 'followed_by'?
>
Nope, they're synonyms.  Same as 'zero_or_more' is the same as
'any_number_of', or 'digit' is the same as 'digits'.

Why do some things have __ in front of them? Is there a
> difference between 'literal' and '__literal'?
>
Er... looks like a garblement in my post!  There are no __ in my original
:(  It should be:

north_american_number_re = (RE().start
  .literal('(').followed_by.exactly(3).digits.then.literal(')')
  .then.one.literal("-").then.exactly(3).digits
  .then.one.dash.followed_by.exactly(4).digits.then.end
  .as_string())

Thanks for the comments!
Cheers
b
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130718/6983a35a/attachment.html>


More information about the Python-list mailing list