meddyliol
Posts: 118
Joined: Thu Mar 20, 2014 8:28 am
Location: South Wales

Brackets or not to Brackets

Thu Apr 03, 2014 2:29 pm

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 :?
Raspberry Pi B, Raspberry Pi 2, monitor, powered hub, mouse, keyboard and Volvo V50 car

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Brackets or not to Brackets

Thu Apr 03, 2014 2:42 pm

s/brackets/parentheses/g
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

User avatar
rpdom
Posts: 17174
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Brackets or not to Brackets

Thu Apr 03, 2014 2:42 pm

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)

User avatar
DougieLawson
Posts: 39124
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Brackets or not to Brackets

Thu Apr 03, 2014 2:43 pm

Parentheses are needed for python3.

You're using python2 if it works without.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
DougieLawson
Posts: 39124
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Brackets or not to Brackets

Thu Apr 03, 2014 2:45 pm

Joe Schmoe wrote:s/brackets/parentheses/g
+1

Brackets being the square ones [] and braces being the curly ones {}.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26660
Joined: Sat Jul 30, 2011 7:41 pm

Re: Brackets or not to Brackets

Thu Apr 03, 2014 2:58 pm

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 )?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Brackets or not to Brackets

Thu Apr 03, 2014 3:11 pm

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".
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26660
Joined: Sat Jul 30, 2011 7:41 pm

Re: Brackets or not to Brackets

Thu Apr 03, 2014 3:42 pm

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.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

User avatar
rpdom
Posts: 17174
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Brackets or not to Brackets

Thu Apr 03, 2014 4:15 pm

Brackets: ()
Curly brackets: {}
Square brackets: []
Quotey things: ""
Smiley: :lol:

User avatar
iinnovations
Posts: 621
Joined: Thu Jun 06, 2013 5:17 pm

Re: Brackets or not to Brackets

Thu Apr 03, 2014 4:23 pm

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). ;)
CuPID Controls :: Open Source browser-based sensor and device control
interfaceinnovations.org/cupidcontrols.html
cupidcontrols.com

User avatar
DougieLawson
Posts: 39124
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Brackets or not to Brackets

Thu Apr 03, 2014 10:40 pm

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.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Tarcas
Posts: 741
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: Brackets or not to Brackets

Fri Apr 04, 2014 3:39 am

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

User avatar
chrisryall
Posts: 155
Joined: Wed Nov 27, 2013 11:45 am
Location: Wirral UK
Contact: Website

Re: Brackets or not to Brackets

Fri Apr 04, 2014 8:53 am

.
:? 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!

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Brackets or not to Brackets

Fri Apr 04, 2014 9:18 am

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.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

User avatar
piglet
Posts: 915
Joined: Sat Aug 27, 2011 1:16 pm

Re: Brackets or not to Brackets

Fri Apr 04, 2014 10:11 am

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


jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26660
Joined: Sat Jul 30, 2011 7:41 pm

Re: Brackets or not to Brackets

Fri Apr 04, 2014 10:23 am

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.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: Brackets or not to Brackets

Fri Apr 04, 2014 10:30 am

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.
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

Tarcas
Posts: 741
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: Brackets or not to Brackets

Fri Apr 04, 2014 1:47 pm

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. :-)
Last edited by Tarcas on Fri Apr 04, 2014 6:00 pm, edited 1 time in total.

meddyliol
Posts: 118
Joined: Thu Mar 20, 2014 8:28 am
Location: South Wales

Re: Brackets or not to Brackets

Fri Apr 04, 2014 5:09 pm

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 ().
Raspberry Pi B, Raspberry Pi 2, monitor, powered hub, mouse, keyboard and Volvo V50 car

User avatar
chrisryall
Posts: 155
Joined: Wed Nov 27, 2013 11:45 am
Location: Wirral UK
Contact: Website

Re: Brackets or not to Brackets

Fri Apr 04, 2014 8:45 pm

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 ;)

Return to “Beginners”