[Python-Dev] Revising RE docs

Stephen J. Turnbull stephen at xemacs.org
Thu Sep 1 07:41:45 CEST 2005


>>>>> "Greg" == Greg Ewing <greg.ewing at canterbury.ac.nz> writes:

 Greg> Stephen J. Turnbull wrote:
 >> But you could have string objects (or a derivative) grow a
 >> "compiled_regexp" attribute internally.
 Greg> That would make the core dependent on the re module, which I
 Greg> think would be a bad idea.
Probably.
 Greg> Personally I like the way the compilation step is made at
 Greg> least somewhat explicit. Regular expressions are not
 Greg> strings; a string is just one way of representing a regular
 Greg> expression. There could potentially be other representations
 Greg> that compile to the same re object.
I guess I agree, but I would put the emphasis elsewhere. Something
like, think of the call to compile() as a declaration that this string
(or other representation) represents a regular expression. The actual
compilation is an accidental side effect: it could be postponed to the
first call of .match() or .search().
So I guess I would prefer a nomenclature like
 r = re.RegExp (string)
over
 r = re.compile (string)
Not a big deal though.
-- 
School of Systems and Information Engineering http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
 Ask not how you can "do" free software business;
 ask what your business can "do for" free software.


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /