Re: [Tutor] Example of use of (?P) and (?P=name) in Python regular expressions?

2009-12-03 Thread Michael Hannon
t place. This is as opposed to the thing I was trying to do, which was to use the "P=" syntax in a substitution. -- Mike - Original Message From: Michael Hannon To: tutor@python.org Sent: Sat, November 28, 2009 3:15:36 PM Subject: [Tutor] Example of use of (?P) and (?P=name)

[Tutor] Example of use of (?P) and (?P=name) in Python regular expressions?

2009-11-28 Thread Michael Hannon
Greetings. While looking into the use of regular expressions in Python, I saw that it's possible to name match groups using: (?P...) and then refer to them using: (?P=name) I was able to get this to work in the following, nonsensical, example: >>> x = 'Free Fri Fro From' >>>

[Tutor] Custom metaclass?

2007-04-19 Thread Michael Hannon
etattr__ = no_new_attributes(type.__setattr__) (Beware line breaks introduced by email software.) Finally, my question: can somebody enlighten me as to how and why the "custom metaclass", class __metaclass__(type): does something useful? Thanks.

Re: [Tutor] The '45' bug in round()

2007-03-20 Thread Michael Hannon
On Tue, Mar 20, 2007 at 09:03:43AM -0700, Dick Moores wrote: . . . > >Well, perhaps this is something for me to think about, but if you had asked > >me to round 0.19945 to four decimal places, I would have told you the > >answer > >is 0.1994, i.e., the same answer that Python gives. > > Is this b

Re: [Tutor] The '45' bug in round()

2007-03-20 Thread Michael Hannon
On Tue, Mar 20, 2007 at 04:09:49AM -0700, Dick Moores wrote: > At 11:00 AM 3/19/2007, Michael Hannon wrote: > >On Mon, Mar 19, 2007 at 03:04:03AM -0700, Dick Moores wrote: > >> Yesterday I was shocked, SHOCKED, to discover that round() is > >> occasionally roundi

Re: [Tutor] The '45' bug in round()

2007-03-19 Thread Michael Hannon
On Mon, Mar 19, 2007 at 03:04:03AM -0700, Dick Moores wrote: > Yesterday I was shocked, SHOCKED, to discover that round() is > occasionally rounding incorrectly. For example, > > >>> print round(0.19945,4) > 0.1994 . . . > Comments, Tutors? Am I way out in left field with this? I suggest you m