<br><br><div class="gmail_quote">On Wed, Dec 5, 2012 at 11:22 AM, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div id=":2l9">- Unions. We need a way to say "either X or Y". Given that we're<br>
defining our own objects we may actually be able to get away with<br>
writing e.g. "Int | Str" or "Str | List[Str]", and isinstance() would<br>
still work. It would also be useful to have a shorthand for "either T<br>
or None", written as Optional[T] or Optional(T).<br></div></blockquote></div><br><div>Optional is not the same as "or None" to me:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">

<div>Dict(a=Int, b=Int | None, c=Optional(Int))</div></blockquote><div><br></div><div>suggests that b is required but might be None while c is not required, i.e., {'a': 3, b: None} is allowed while {'a': 3, c: None} is not. </div>

<div><br></div><div>Ditto for Tuples:</div><div><br></div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>Tuple[Int, Str | None, Optional(Int)]</div><div><br></div></blockquote>where (3, None) matches as does (3, 'a', 4) but not (3, None, None).</div>

<div><br></div><div><div>Optionals might be restricted to the end as matching in the middle would be complicated and possibly error-prone:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">

<div>Tuple[Int, Optional(Int | None), Int | Str, Int | None]</div><div><br></div></blockquote></div><div><font face="arial, helvetica, sans-serif">--- Bruce</font><div><font face="arial, helvetica, sans-serif">Follow me: <a href="http://www.twitter.com/Vroo" target="_blank">http://www.twitter.com/Vroo</a> <a href="http://www.vroospeak.com/" target="_blank">http://www.vroospeak.com</a></font></div>

</div><div><br></div>