Page 1 of 1

Brackets or not to Brackets

Posted: Thu Apr 03, 2014 2:29 pm
by meddyliol
Most (if not all) online Python tutorials do not use brackets, for example: print "Hello", if I do this with the raspberry it gives a syntax error. Of course writing: print("Hello") does work. Is there a reason for this? I thought that Python did away with using brackets.

Cheers

Brian :?

Re: Brackets or not to Brackets

Posted: Thu Apr 03, 2014 2:42 pm
by Joe Schmoe
s/brackets/parentheses/g

Re: Brackets or not to Brackets

Posted: Thu Apr 03, 2014 2:42 pm
by rpdom
I think that is the difference between python 2 and python 3.

(I'm not a Python programmer, but I've seen it mentioned before)

Re: Brackets or not to Brackets

Posted: Thu Apr 03, 2014 2:43 pm
by DougieLawson
Parentheses are needed for python3.

You're using python2 if it works without.

Re: Brackets or not to Brackets

Posted: Thu Apr 03, 2014 2:45 pm
by DougieLawson
Joe Schmoe wrote:s/brackets/parentheses/g
+1

Brackets being the square ones [] and braces being the curly ones {}.

Re: Brackets or not to Brackets

Posted: Thu Apr 03, 2014 2:58 pm
by jamesh
DougieLawson wrote:
Joe Schmoe wrote:s/brackets/parentheses/g
+1

Brackets being the square ones [] and braces being the curly ones {}.
So what are ( and )?

Re: Brackets or not to Brackets

Posted: Thu Apr 03, 2014 3:11 pm
by Joe Schmoe
So what are ( and )?
As indicated above (my first post on this thread):
parentheses
Note that some of the text above is what they call a "parenthetical".

Re: Brackets or not to Brackets

Posted: Thu Apr 03, 2014 3:42 pm
by jamesh
Nope.

All the above are brackets according to the English definition...because they all 'bracket' something...so the OP is actually correct in his use of the word brackets. If not particularly specific.

Re: Brackets or not to Brackets

Posted: Thu Apr 03, 2014 4:15 pm
by rpdom
Brackets: ()
Curly brackets: {}
Square brackets: []
Quotey things: ""
Smiley: :lol:

Re: Brackets or not to Brackets

Posted: Thu Apr 03, 2014 4:23 pm
by iinnovations
jamesh wrote:Nope.

All the above are brackets according to the English definition...because they all 'bracket' something...so the OP is actually correct in his use of the word brackets. If not particularly specific.
While technically true, the request "please help me with my words because my little computer doesn't do what I want" is equally accurate (and difficult to process). ;)

Re: Brackets or not to Brackets

Posted: Thu Apr 03, 2014 10:40 pm
by DougieLawson
jamesh wrote:Nope.

All the above are brackets according to the English definition...because they all 'bracket' something...so the OP is actually correct in his use of the word brackets. If not particularly specific.
Oh dear. English is losing to Merriam & Webster's egregious American Standard definitions. All is lost, I'll blame Facebook for that.

Re: Brackets or not to Brackets

Posted: Fri Apr 04, 2014 3:39 am
by Tarcas
Let me put up a quick translation guide, based on rpdom's post:

Code: Select all

British            Symbol   American

Brackets            ()   Parentheses
Curly brackets      {}   Curley Braces
Square brackets     []   Brackets
Quotey things       ""   Quotation Marks
?                   ''   Single Quotes
?                   <>   Angle brackets (if used as brackets. Otherwise Less Than and Greater Than)
?                   #    Pound Sign or Hash
?                   ~    Tilde
Smiley              :-)   Smiley

Re: Brackets or not to Brackets

Posted: Fri Apr 04, 2014 8:53 am
by chrisryall
.
:? I thought braces were what all those US teenagers have on their teeth? But I use braces to hold my trousers up
.
"Er, what are trousers"?

Oh, :| pants!

Re: Brackets or not to Brackets

Posted: Fri Apr 04, 2014 9:18 am
by Richard-TX
chrisryall wrote:.
:? I thought braces were what all those US teenagers have on their teeth? But I use braces to hold my trousers up
.
"Er, what are trousers"?

Oh, :| pants!
Pants from the spanish pantaloons.

Re: Brackets or not to Brackets

Posted: Fri Apr 04, 2014 10:11 am
by piglet

Code: Select all

British                Symbol   American
                       
Brackets                   ()    Parentheses
Curly brackets             {}    Curley Braces
Square brackets            []    Brackets
Double quotes              ""    Quotation Marks
Single quotes              ''    Single Quotes
Angle brackets             <>    Angle brackets (if used as brackets. Otherwise Less Than and Greater Than)
Hash                       #     Pound Sign or Hash
Pound sign (weight)        lb/℔  Huh? Do you mean #?
Pound sign (money)         £     Do you mean dollars?
Tilde/Squiggly thing       ~     Tilde

Everyone               Symbol    BBC

Slash or forward slash     /     Stroke


Re: Brackets or not to Brackets

Posted: Fri Apr 04, 2014 10:23 am
by jamesh
DougieLawson wrote:
jamesh wrote:Nope.

All the above are brackets according to the English definition...because they all 'bracket' something...so the OP is actually correct in his use of the word brackets. If not particularly specific.
Oh dear. English is losing to Merriam & Webster's egregious American Standard definitions. All is lost, I'll blame Facebook for that.
Really?

http://www.oxforddictionaries.com/defin ... q=brackets

Pretty sure Oxford University Press are fairly British English.

Re: Brackets or not to Brackets

Posted: Fri Apr 04, 2014 10:30 am
by DeeJay
All very enlightening, but to get back to helping the enquirer:
meddyliol wrote:Most (if not all) online Python tutorials do not use brackets, for example: print "Hello", if I do this with the raspberry it gives a syntax error. Of course writing: print("Hello") does work. Is there a reason for this? I thought that Python did away with using brackets.
" I thought that Python did away with using brackets."

Quite the contrary. The move from python2 to python3 made their use mandatory in some situations where they were optional before. print is probably the most obvious example.

Re: Brackets or not to Brackets

Posted: Fri Apr 04, 2014 1:47 pm
by Tarcas
Pound sign (weight) lb/℔ Huh? Do you mean #?
Pound sign (money) £ Do you mean dollars?
We use lb or # for pounds weight. (usually in the grocery store you'll see prices in $/lb rather than $/#, although I have seen the latter, but usually on hand-written signs.)

I think most of us know what a £ is. But good response nonetheless. :-)

Re: Brackets or not to Brackets

Posted: Fri Apr 04, 2014 5:09 pm
by meddyliol
Thank you all for your informative answers. I think you have answered my question ;) Along with lots of other must know stuff 8-)

Cheers

Brian

P.S. Wasn't that a rather retrograde step going from Python 2 to 3 and putting brackets () back in? Everywhere online seems to do without brackets ().

Re: Brackets or not to Brackets

Posted: Fri Apr 04, 2014 8:45 pm
by chrisryall
I can't think for the life of me think why either. This in a language that uses vacuous and tab-indistinguishable "white space" to control the more inportant "flow"

In there with those anal ';'s at the end of every line in C (or the Algol group). Javascript is cool on the issue and nothing seems to fall off ;)