Stefan Behnel wrote:


Nick Coghlan wrote

a) Patches are more likely to be looked at if placed on the SF patch tracker.


see your own b), I wanted to discuss them first.

Fair enough.

Still, when I first tried out the Template class, I immediately stumbled over the fact that the substitute methods always return strings, and never Template objects. While it makes sense for their primary purpose, it totally restricts the usage of this module to one-show operations.

Except that it is easy to turn a string into a template using a constructor. . .

However, now that I think more about your 'partial_substitute' method it does make sense as an alternative constructor:

  @classmethod
  def from_template(*args, **kwds):
    cls, orig = args[:2]
    return cls(orig.safe_substitute(*args[2:], **kwds))

Usable as:
  new_templ = Template.from_template(orig_templ, *args, **kwds)

Versus:
  new_templ = Template(orig_templ.safe_substitute(*args, **kwds))

Mutating the template in place seems questionable. Rebinding the name with the above constructor would be more appropriate, IMO.

Hmm - I'm unconvinced, but it's probably still worth posting a patch and sending it in Barry Warsaw's direction.

Cheers,
Nick.

--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
            http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to