Why not allow empty code blocks?
Rustom Mody
rustompmody at gmail.com
Sat Jul 30 08:11:08 EDT 2016
On Saturday, July 30, 2016 at 5:19:25 PM UTC+5:30, Chris Angelico wrote:
> On Sat, Jul 30, 2016 at 9:39 PM, Rustom Mody wrote:
> > On Saturday, July 30, 2016 at 4:56:01 PM UTC+5:30, Chris Angelico wrote:
> >> On Sat, Jul 30, 2016 at 8:15 PM, BartC wrote:
> >> > Anyway, if you're going to talk about annoying things forced upon you by the
> >> > language, what about:
> >> >
> >> > "()" in "print (x)" for Python 3the modulo operator
> >>
> >> Why are you singling out print? It's just a function like any other.
> >> Are you complaining about the way function calls need parentheses?
> >
> > Its a function… ok.
> > Its ‘just’ a function… Arguable
> >
> > For example:
> >
> > - Prior Art: Its builtin and special in Fortran, Pascal, Basic
>
> And it's not built-in or special in C, or a bunch of other languages.
>
> > - More immediate : It was a special in python2
>
> Which resulted in unmitigatable problems, such as that you can't mock
> it for testing or redirection purposes, and it demands syntactic magic
> to do its work - for instance, the only option is a "soft space" in
> place of a newline, where the print function allows full customization
> of both end= and sep=. The print function is DEFINITELY an
> improvement. I would also posit that an sprintf() built-in function
> instead of str.__mod__ would have meant there was less kickback
> against printf-style formatting, because it wouldn't have had the
> strange behaviour around single-argument use. (It's pretty simple to
> write, of course, but built-ins are extremely significant to
> perception. def sprintf(fmt, *args): return fmt % args) Syntax is NOT
> always an improvement.
>
> > - Poorer error catching: What was a straight syntax error is now a lint-catch (at best)
> > [print (x) for x in range(20)]
>
> Huh? Aside from the fact that you're constructing a useless list of
> Nones, what's the error?
Huh²
Are you seriously suggesting that python-3’s behavior below is better IN
THIS INSTANCE than python-2’s?
[That there may be other reasons that outweigh this one for print-as-function
is not something I am disputing. I was solely disputing your ‘just’]
Python 2.7.12 (default, Jul 1 2016, 15:12:24)
>>> [print(x) for x in range(10)]
File "<stdin>", line 1
[print(x) for x in range(10)]
^
SyntaxError: invalid syntax
>>>
Python 3.5.2 (default, Jul 5 2016, 12:43:10)
>>> [print(x) for x in range(10)]
0
1
2
3
4
5
6
7
8
9
[None, None, None, None, None, None, None, None, None, None]
>>>
More information about the Python-list
mailing list