[Python-3000] features i'd like [Python 3000?] ... #4: interpolated strings ala perl (original) (raw)
Jan Grant jan.grant at bristol.ac.uk
Wed Dec 6 17:53:13 CET 2006
- Previous message: [Python-3000] features i'd like [Python 3000?] ... #4: interpolated strings ala perl
- Next message: [Python-3000] features i'd like [Python 3000?] ... #4: interpolated strings ala perl
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, 6 Dec 2006, Barry Warsaw wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Dec 6, 2006, at 5:24 AM, Jan Grant wrote: > PS. IF generic functions (operators) could be sensitive to return types > and IF python6k supported a complex type inference mechanism (possibly > including automatic coercion), then one might be able to do something > like: > > def foo(d: sqlDriver): > s = "select template goes here" % (param1, param2) > r = d.query(s) > > where sqlDriver has a method > > def query(self, s: sometypethatsignalssqlinterpolation) > > and "%" is overloadable on the basis that the return type is determined > to be compatible with "sometypethatsignalssqlinterpolation". Those > are some mighty big "IF"s though, and you could still concoct cases > where things would break :-) BTW, I believe that most of the SQL wrapper packages for Python already provide safe prepared statement like functionality, that is convenient to use.
You are absolutely right, and on reflection I think I concur.
Whilst some hoop-jumping might be possible to ensure that the formatting operator % is compatible with various application-specific quoting requirements (and without which "string interpolation" in the language is a terrible misfeature IMHO*), appropriate (and suitably "pythonic") mechanisms already exist for this in the libraries I care about.
jan
- by using any proposed string interpolation syntax as sugar for a %-expression
-- jan grant, ISYS, University of Bristol. http://www.bris.ac.uk/ Tel +44 (0)117 3317661 http://ioctl.org/jan/ Goth isn't dead, it's just lying very still and sucking its cheeks in.
- Previous message: [Python-3000] features i'd like [Python 3000?] ... #4: interpolated strings ala perl
- Next message: [Python-3000] features i'd like [Python 3000?] ... #4: interpolated strings ala perl
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]