Home > Back-end >  What does this period change in the line of code?
What does this period change in the line of code?

Time:03-04

What does this period change in the command line? I defined "list" as a variable, but why can't I just use the "write" command? [1]: https://i.stack.imgur.com/JpRPz.png

CodePudding user response:

First, don't name variables using python built-ins such as list.

Secondly, to answer your question, assigning a file pointer to the variable list creates an object (to put it vaguely) list. In python, methods can perform functions specific to an object type, such as the one assigned to list. In your case, the method is to write the contents supplied to write() to the file you opened. Methods are called upon using . following an instantiated object.

CodePudding user response:

well i am unsure of what you are exactly asking but the period/comma just allows you to add the edit permission of the file. and you can just use the .write() command because the file hasn't been defined

  • Related