I am trying to wrap my head around naming conventions & semantics in Python.
Here are two code snippets, and below those two snippets are my questions:

# code snippet 1
file_path = "C:\\Users\\...etl.csv"
with open(file_path) as file_object:
    contents = file_object.read()
contents_split = contents.split("\n")
print(contents_split[:3])

['Year,Week,Winner,Loser', '1966,1,Miami Dolphins,Oakland Raiders',
'1966,1,Houston Oilers,Denver Broncos']

# code snippet 2
file_path = "C:\\Users\\...etl.csv"
with open(file_path) as file_object:
    contents = list(file_object)
print(contents[:3])

['Year,Week,Winner,Loser\n', '1966,1,Miami Dolphins,Oakland
Raiders\n', '1966,1,Houston Oilers,Denver Broncos\n']

Here are my questions:

- List is a function, and read is a method, is that correct?
- Semantic wise it would be always like function(something) and a
method would be something.method() .. is that correct?
- Assuming the above is correct, it seems that there is a tiny line
between methods and functions? Why is something a method or a
function?
- For example, why is print a function and not a method?
something.print() instead of print(something)

Just trying to understand logic of Python and conventions, which will
then make learning and memorizing things easier.

Thanks.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to