<div dir="ltr">Steven,<div><br></div><div>(short of time here)</div><div><br></div><div>With **kwargs and a little more work, the function would check if the type is already defined, and retur the ntuple with the correct type, not the type.</div><div><br></div><div>Your sketch of a solution convinced me it can be done with a library function; no additional syntax needed.</div><div><br></div><div>Cheers, </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 25, 2017 at 5:08 AM, Stephen J. Turnbull <span dir="ltr"><<a href="mailto:turnbull.stephen.fw@u.tsukuba.ac.jp" target="_blank">turnbull.stephen.fw@u.tsukuba.ac.jp</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">C Anthony Risinger writes:<br>
<br>
 > At the end of the day, I don't see a way to have both a literal and<br>
 > something that is externally "named", because the only ways to pass the<br>
 > name I can imagine would make it look like a value within the container<br>
 > itself (such as using a literal string for the first item), unless even<br>
 > more new syntax was added.<br>
<br>
</span>OK, so I took your "a tuple is a tuple is a tuple" incorrectly.  What<br>
you want (as I understand it now) is not what<br>
<br>
    def ntuple0(attr_list):<br>
        return namedtuple("_", attr_list)<br>
<br>
gives you, but something like what<br>
<br>
    def ntuple1(attr_list)<br>
        return namedtuple("<wbr>ImplicitNamedtuple_" + "_".join(attr_list),<br>
                          attr_list)<br>
<br>
does.  Then this would truly be a "duck-typed namedtuple" as Chris<br>
Barker proposed in response to Steven d'Aprano elsewhere in this<br>
thread.  See also Nick's full, namedtuple-compatible, implementation.<br>
Of course we still have the horrible "list of strings naming<br>
attributes" argument, so you still want a literal if possible, but<br>
with a **key argument, a new builtin would do the trick for me.  YMMV.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Associate Professor              Division of Policy and Planning Science<br>
<a href="http://turnbull/sk.tsukuba.ac.jp/" rel="noreferrer" target="_blank">http://turnbull/sk.tsukuba.ac.<wbr>jp/</a>     Faculty of Systems and Information<br>
Email: <a href="mailto:turnbull@sk.tsukuba.ac.jp">turnbull@sk.tsukuba.ac.jp</a>                   University of Tsukuba<br>
Tel: 029-853-5175                 Tennodai 1-1-1, Tsukuba 305-8573 JAPAN<br>
</font></span><div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><span style="color:rgb(0,102,0)">Juancarlo </span><b style="color:rgb(0,102,0)">Añez</b></div>
</div>