re.NONE

1

1x7y2z9

I am currently using python v2.5.2.

Not sure if this is defined in a later version, but it would be nice
to define re.NONE = 0 in the re module. This would be useful in cases
such as:
flags = re.DOTALL if dotall else re.NONE

Also useful for "building up" flags by ORing with other flags.

Thanks.
 
M

MRAB

1x7y2z9 said:
I am currently using python v2.5.2.

Not sure if this is defined in a later version, but it would be nice
to define re.NONE = 0 in the re module. This would be useful in cases
such as:
flags = re.DOTALL if dotall else re.NONE

Also useful for "building up" flags by ORing with other flags.

Thanks.

Just use 0.

If you want it added then try requesting it at:

http://bugs.python.org/

although it might be best to first gauge how much support you have for
the suggestion.
 
R

Rhodri James

Re-ordered to eliminate the top-posting.


(arg, MRAB, sorry, wrong address!)

Defining None to 0 is a bad idea. You'll have trouble debugging later on.

They aren't talking about None, they're talking about a hypothetical
re.NONE to use as a flag to re.match() and the like. There's no
issue with defining that to be 0, since it is the correct value!
 
L

Lawrence D'Oliveiro

In message <e9213fb3-
Not sure if this is defined in a later version, but it would be nice
to define re.NONE = 0 in the re module.

Do so:

re.NONE = 0

Problem solved.
 
J

John Machin

I am currently using python v2.5.2.

Not sure if this is defined in a later version, but it would be nice
to define re.NONE = 0 in the re module.  This would be useful in cases
such as:
flags = re.DOTALL if dotall else re.NONE

Also useful for "building up" flags by ORing with other flags.

-1

0 is even more useful. YAGNI.

BTW everybody try typing NONE a few times fast ... if your fingers
don't fight your brain and produce None anyway, you haven't been using
Python long enough :)
 
J

John Machin

-1

0 is even more useful. YAGNI.

BTW everybody try typing NONE a few times fast ... if your fingers
don't fight your brain and produce None anyway, you haven't been using
Python long enough :)

Oh and I forgot to mention that if this proposal goes ahead it will
need a one-letter version -- perhaps re.Z -- and maybe even a PEP. It
could end up rivalling the legendary IEFBR14 in the ratio-of-overhead-
to-functionality stakes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,052
Members
47,656
Latest member
rickwatson

Latest Threads

Top