[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Syntax questions
- From: Nick Gammon <nick@...>
- Date: Thu, 11 Sep 2008 16:33:33 +1000
1. Why does this not work?
a = { 1, 2, 3, 4 } [1] --> Error: unexpected symbol near '['
But this does:
a = ({ 1, 2, 3, 4 }) [1]
print (a) --> 1
2. Similarly:
s = "testing" : upper () --> Error: ')' expected near ':'
But:
s = ("testing") : upper ()
print (s) --> TESTING
Putting brackets around a literal string, or a table constructor seems
to somehow "finalize" their construction, so they can be used normally
afterwards, but what is the precise reason for their requirement?