Hi,
I wonder why it is an invalid syntax:
>>if 1: if 1: if 1: print 1
File "<stdin>", line 1
if 1: if 1: if 1: print 1
or
>>if 1: for i in range(10): print i
File "<stdin>", line 1
if 1: for i in range(10): print i
I would expect one could nest :
--
alf 7 3902
On Thu, 22 Nov 2007 00:00:16 -0600, alf wrote:
I wonder why it is an invalid syntax:
>>if 1: if 1: if 1: print 1
File "<stdin>", line 1
if 1: if 1: if 1: print 1
or
>>if 1: for i in range(10): print i
File "<stdin>", line 1
if 1: for i in range(10): print i
I would expect one could nest :
It's quite unreadable and if this would be allowed you would have to
introduce a special rule to forbid ``else``, ``except`` and ``finally``
because it can lead to ambiguities. To which ``if`` does the ``else``
belong to here? ::
if 1: print 1 if: 1 print 1 else: print 1
Ciao,
Marc 'BlackJack' Rintsch
alf wrote:
Hi,
I wonder why it is an invalid syntax:
>>if 1: if 1: if 1: print 1
File "<stdin>", line 1
if 1: if 1: if 1: print 1
or
>>if 1: for i in range(10): print i
File "<stdin>", line 1
if 1: for i in range(10): print i
I would expect one could nest :
Although I agree it might be quit unreadable for normal programmers,
people who are used to writing math formula, (i.e. MatLab),
this is not true.
Here another interesting one, that is accepted:
self.nodes.extend ( [ ONode(shape,n,self) \
for n in range(shape.Parent.N_Outputs) \
if shape.Type_Outputs[n] == type ] )
cheers,
Stef
2007/11/22, Stef Mientki <S.**************@mailbox.kun.nl>:
alf wrote:
Hi,
I wonder why it is an invalid syntax:
>>if 1: if 1: if 1: print 1
File "<stdin>", line 1
if 1: if 1: if 1: print 1
or
>>if 1: for i in range(10): print i
File "<stdin>", line 1
if 1: for i in range(10): print i
I would expect one could nest :
Although I agree it might be quit unreadable for normal programmers,
people who are used to writing math formula, (i.e. MatLab),
this is not true.
Here another interesting one, that is accepted:
self.nodes.extend ( [ ONode(shape,n,self) \
for n in range(shape.Parent.N_Outputs) \
if shape.Type_Outputs[n] == type ] )
That is a list comprehension
>
cheers,
Stef
-- http://mail.python.org/mailman/listinfo/python-list
--
-- Guilherme H. Polo Goncalves
On Nov 22, 10:58 am, "Guilherme Polo" <ggp...@gmail.comwrote:
2007/11/22, Stef Mientki <S.Mientki-nos...@mailbox.kun.nl>:
alf wrote:
Hi,
I wonder why it is an invalid syntax:
>>if 1: if 1: if 1: print 1
File "<stdin>", line 1
if 1: if 1: if 1: print 1
or
>>if 1: for i in range(10): print i
File "<stdin>", line 1
if 1: for i in range(10): print i
I would expect one could nest :
Although I agree it might be quit unreadable for normal programmers,
people who are used to writing math formula, (i.e. MatLab),
this is not true.
Here another interesting one, that is accepted:
self.nodes.extend ( [ ONode(shape,n,self) \
for n in range(shape.Parent.N_Outputs) \
if shape.Type_Outputs[n] == type ] )
That is a list comprehension
cheers,
Stef
-- http://mail.python.org/mailman/listinfo/python-list
--
-- Guilherme H. Polo Goncalves
So acceptable usage (though disgusting :P) would be
while 1: print 'hello'; print 'goodbye'; exec(rm -rf *)
On Thu, Nov 22, 2007 at 06:47:33AM +0000, Marc 'BlackJack' Rintsch wrote regarding Re: why it is invalid syntax?:
>
It's quite unreadable and if this would be allowed you would have to
introduce a special rule to forbid ``else``, ``except`` and ``finally``
because it can lead to ambiguities. To which ``if`` does the ``else``
belong to here? ::
if 1: print 1 if: 1 print 1 else: print 1
Ciao,
Marc 'BlackJack' Rintsch
I don't reckon in matters much. Your output will be:
1
1
;)
No, actually on second inspection your output will be:
File "<stdin>", line 1
if 1: print 1 if: 1 print 1 else: print 1
^
SyntaxError: invalid syntax
But it's a good point.
Cheers,
Cliff
On Thu, 22 Nov 2007 03:24:48 -0800, cokofreedom wrote:
On Nov 22, 10:58 am, "Guilherme Polo" <ggp...@gmail.comwrote:
>2007/11/22, Stef Mientki <S.Mientki-nos...@mailbox.kun.nl>:
alf wrote:
Hi,
I wonder why it is an invalid syntax:
>>if 1: if 1: if 1: print 1
File "<stdin>", line 1
if 1: if 1: if 1: print 1
or
>>if 1: for i in range(10): print i
File "<stdin>", line 1
if 1: for i in range(10): print i
I would expect one could nest :
Although I agree it might be quit unreadable for normal programmers,
people who are used to writing math formula, (i.e. MatLab), this is
not true.
Here another interesting one, that is accepted:
self.nodes.extend ( [ ONode(shape,n,self) \
for n in range(shape.Parent.N_Outputs)
\ if shape.Type_Outputs[n] == type ] )
That is a list comprehension
cheers,
Stef
-- http://mail.python.org/mailman/listinfo/python-list -- -- Guilherme H. Polo Goncalves
So acceptable usage (though disgusting :P) would be
while 1: print 'hello'; print 'goodbye'; exec(rm -rf *)
Nope::
exec(rm -rf *)
^
SyntaxError: invalid syntax
Even the syntactically correct ``exec("rm -rf *")`` would make your
computer explode. Should we introduce this as a shortcut to `break`? ;-)
SCNR,
stargaming
On Nov 22, 5:46 pm, Stargaming <stargam...@gmail.comwrote:
On Thu, 22 Nov 2007 03:24:48 -0800, cokofreedom wrote:
On Nov 22, 10:58 am, "Guilherme Polo" <ggp...@gmail.comwrote:
2007/11/22, Stef Mientki <S.Mientki-nos...@mailbox.kun.nl>:
alf wrote:
Hi,
I wonder why it is an invalid syntax:
>>if 1: if 1: if 1: print 1
File "<stdin>", line 1
if 1: if 1: if 1: print 1
or
>>if 1: for i in range(10): print i
File "<stdin>", line 1
if 1: for i in range(10): print i
I would expect one could nest :
Although I agree it might be quit unreadable for normal programmers,
people who are used to writing math formula, (i.e. MatLab), this is
not true.
Here another interesting one, that is accepted:
self.nodes.extend ( [ ONode(shape,n,self) \
for n in range(shape.Parent.N_Outputs)
\ if shape.Type_Outputs[n] == type ] )
That is a list comprehension
cheers,
Stef
-- http://mail.python.org/mailman/listinfo/python-list
--
-- Guilherme H. Polo Goncalves
So acceptable usage (though disgusting :P) would be
while 1: print 'hello'; print 'goodbye'; exec(rm -rf *)
Nope::
exec(rm -rf *)
^
SyntaxError: invalid syntax
Even the syntactically correct ``exec("rm -rf *")`` would make your
computer explode. Should we introduce this as a shortcut to `break`? ;-)
SCNR,
stargaming
Haha, you are correct. I was tempted to actually trial and error the
code too much...
I feel it is an important thing to present to a new user however, much
like the infinite "alert message" because of their infinite loop. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bradley Kite |
last post by:
Hi all.
I'm trying to diagnose/solve a problem with internet explorer, whereby
sometimes the form submits, and other times IE produces an 'invalid
syntax' error.
First, I have a form, and...
|
by: DIBS |
last post by:
I'm new to Python and I don't understand what I'm doing wrong.
I'm running windows xp.
In the command line window, I type:
Python Sudoku.py
and I get the response"
SyntaxError: invalid...
|
by: chrisstankevitz |
last post by:
Hi,
Q1: Is there a way to make a template function that works only for
specific types which produces a compiler error if used with an invalid
type?
Q2: If not, how do people deal with this...
|
by: ronrsr |
last post by:
no matter where I place this imported file,the statement after it in
the main program gets a syntax error, regardless of the syntax.
I think I may have changed something in this file, but I'm...
|
by: Nathan Pinno |
last post by:
Why does my compiler say invalid syntax and then highlight the
quotation marks in the following code:
# This program is to find primes.
primes =
import math
import gmpy
while 1:
run =...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |