I have a little problem here; how do I make a self argument in Python? I want to be able to create an function that works like this:
'Hello, World!'.Write()
or at least something close to that. This is my code so far:
def Write(self):
print(self)
'Hello, World!'.Write()
I got this as a syntax:
File "main.py", line 3, in <module>
'Hello, World!'.Write()
AttributeError: 'str' object has no attribute 'Write'
python3 exited with code 1...
so I tried changing the last line to Write.'Hello, World!'()
instead. Now I have another error:
File "main.py", line 3
Write.'Hello, world!'()
^
SyntaxError: invalid syntax
python3 exited with code 1...
Something definitely isn't working. Did I miss one or a few steps? Is there something I am not seeing? Should I even use self
?