<div dir="ltr">It happens that the statement "there is no reliable way to distinguish a mapping from a sequence" is not true.  I submit the following example.<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"> Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win<br>32<br>Type "help", "copyright", "credits" or "license" for more information.<br>>>> from collections import Mapping<br>>>> seq = [1, 2]<br>>>> map = {'one':1, 'two':2}<br>>>> params = seq<br>>>> isinstance(params, Mapping)<br>False<br>>>> params = map<br>>>> isinstance(params, Mapping)<br>True<br>>>><br></blockquote><div> </div><div>The  current production version of <a href="http://sf.net/projects/adodbapi">adodbapi</a> does exactly what Tony proposes, if the programmer sets the paramstye to "dynamic".  Yes, it does work reliably.  I challenge anyone who claims otherwise to prove their assertion.<br><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 16, 2013 at 4:15 AM, Dieter Maurer <span dir="ltr"><<a href="mailto:dieter@handshake.de" target="_blank">dieter@handshake.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Tony Locke wrote at 2013-9-13 18:54 +0100:<br>
> ...<br>
>I thought I'd give a suggestion for unified parameters. Apologies if<br>
>this has been suggested before, I did have a look at the archives :-)<br>
><br>
>In DBAPI 2.0, the parameters to execute() can be a sequence or a<br>
>mapping. In DBAPI 3.0, the paramstyle attribute should be removed, and<br>
>the style determined by whether the parameters are a sequence or<br>
>mapping. For a sequence the 'numeric' style is expected, and for a<br>
>mapping the 'named' style. For example:<br>
><br>
>execute("select * from emp where name = :1", ['horatio'])<br>
><br>
>execute("select * from emp where name = :name", {'name': 'horatio'})<br>
><br>
>The reason I like this solution is that if someone asked me how<br>
>parameters work in DBAPI, this one would be the easiest to explain!<br>
><br>
>Any thoughts?<br>
<br>
This has been suggested and found one objection: there is no reliable<br>
way to distinguish a mapping from a sequence -- or put in<br>
different words: it is easy to define a class which supports both<br>
the sequence as well as the mapping protocol.<br>
<br>
<br>
<br>
--<br>
Dieter<br>
_______________________________________________<br>
DB-SIG maillist  -  <a href="mailto:DB-SIG@python.org">DB-SIG@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/db-sig" target="_blank">https://mail.python.org/mailman/listinfo/db-sig</a><br>
</blockquote></div><br></div>