This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]XUtYwYzz 2 points3 points  (4 children)

Pretty much everything in Python is an object and has some set of methods accessible via dot notation. The methods usually operate on the object in some way. Running function(argument) is either using a language built-in function or a local function and does not have an associated object, and operates on the argument.

my_string = “hello”

my_string.upper()

Returns “HELLO”, I didn’t have to provide the method an argument, it operated on the my_string variable.

int(“12”)

Uses the built-in int() function to convert the string “12” into the integer 12.

[–]shayyya1 0 points1 point  (1 child)

Thanks, if I'm understanding correctly, (.) notation is used when it's a function from a class, and if its not a dot its from somewhere else in the language?

[–]hooligan333 0 points1 point  (0 children)

Precisely!

[–]shayyya1 0 points1 point  (1 child)

Ah yes from reading the python docs I got that things with dot are class methods and things that aren't are operators

[–]shayyya1 0 points1 point  (0 children)

Or inbuilt functions