Home > Software design >  What do the brackets in 'turtle.pen()' do? What are they supposed to contain?
What do the brackets in 'turtle.pen()' do? What are they supposed to contain?

Time:05-07

So recently I was planning to write a code using turtle graphics and I had a question. What do the brackets in t = turtle.Pen() mean? What are they supposed to contain? Please answer in a simplified manner as I am still a beginner at python :)

CodePudding user response:

Those aren't brackets, they are parentheses. It's a function call without arguments (or in this case, an object instantiation).

What they're "supposed" to contain depends entirely on the function you're calling (or object you're instantiating).

For instance, print() accepts the arguments to print (or none to just print a new line):

>>> print()

>>> print("hello")
hello
>>> print("hello", 42)
hello 42
>>>
  • Related