Showing content from http://mail.python.org/pipermail/python-dev/attachments/20070401/e35ebbfb/attachment.html below:
On 4/1/07, <b class="gmail_sendername">Georg Brandl</b> <<a href="mailto:g.brandl@gmx.net">g.brandl@gmx.net</a>> wrote:<br>[...]<br><div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Example<br>=======<br><br>This is the standard ``os.path.normpath`` function, converted to type declaration<br>syntax::<br><br> def normpathÆ(pathâ)â:<br> """Normalize path, eliminating double slashes, etc."""
<br> if pathâ == '':<br> return '.'<br> initial_slashesâ = pathâ.startswithÆ('/')â<br> # POSIX allows one or two initial slashes, but treats three or more<br> # as single slash.
<br> if (initial_slashesâ and<br> pathâ.startswithÆ('//')â and not pathâ.startswithÆ('///')â)â:<br> initial_slashesâ = 2<br> comps⨠= pathâ.splitÆ('/')â¨<br> new_comps⨠= []â¨
<br> for compâ in compsâ¨:<br> if compâ in ('', '.')â¯:<br> continue<br> if (compâ != '..' or (not initial_slashesâ and not new_compsâ¨)â or<br> (new_comps⨠and new_compsâ¨[-1]â == '..')â)â:
<br> new_compsâ¨.appendÆ(compâ)<br> elif new_compsâ¨:<br> new_compsâ¨.popÆ()â<br> comps⨠= new_compsâ¨<br> pathâ = '/'.join(compsâ¨)â<br> if initial_slashesâ:
<br> pathâ = '/'*initial_slashesâ + pathâ<br> return pathâ or '.'<br><br>As you can clearly see, the type declarations add expressiveness, while at the<br>same time they make the code look much more professional.
</blockquote><div><br></div></div> Is this supposed to be a joke? Please tell me this isn't a real PEP. While I'm all for allowing unicode identifiers in Python, postfix type annotations make Python look like Perl. And how can you claim this code is more readable? It certainly is _less_ readable, not more.
<br><br> I agree that Python should support type annotations, but they should be optional and only present at the function interfaces, i.e. specify the type in the function parameter lists, like in plain old C.<br><br> +1 from me for allowing unicode identifiers.
<br><br> -MAXVOTE for type annotations in identifiers.<br><br>-- <br>Gustavo J. A. M. Carneiro<br>"The universe is always one step beyond logic."
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4