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: some_type_that_signals_sql_interpolation) > > > > and "%" is overloadable on the basis that the return type is determined > > to be compatible with "some_type_that_signals_sql_interpolation". 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. _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com