concept parenthesis in category python

appears as: parentheses, parentheses
Tiny Python Projects: Learn coding and testing with puzzles and games

This is an excerpt from Manning's book Tiny Python Projects: Learn coding and testing with puzzles and games.

You must include the parentheses, (), or else you’re talking about the function itself:

>>> word.upper
<built-in method upper of str object at 0x10559e500>

That will actually come in handy later, when we use functions like map() and filter(), but for now we want Python to execute the str.upper() function on the variable word, so we add the parentheses. Note that the function returns an uppercase version of the word but does not change the value of word:

The match.groups() function returns a tuple containing the matches for each grouping created by the parentheses. You can also use match.group() (singular) with a group number to get a specific group. Note that these start numbering from 1:

Get Programming: Learn to code with Python

This is an excerpt from Manning's book Get Programming: Learn to code with Python.

  • You’re trying to call the command with an object when the command doesn’t need anything in the parentheses.
  • You’re trying to call the command with only one object when the command needs two in the parentheses.
  • In this lesson, my objective was to teach you about the subtleties of functions. These ideas only begin to scratch the surface of what you can do with functions. You created functions that had variables with the same name and saw that they didn’t interfere with each other because of function scopes. You learned that functions are Python objects and that they can be passed in as parameters to or returned by other functions. Here are the major takeaways: