#๐Ÿ”’ class questions

13 messages ยท Page 1 of 1 (latest)

stuck rootBOT
#

@green wedge

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

green wedge
#

class questions

lone briar
#

Yes, str() calls the __str__ dunder. Creating instances of int the way you're describing is a unique thing based on how the language was designed. These creations are known as "literals"

#

!e
5 = 10

stuck rootBOT
# lone briar !e 5 = 10

:x: Your 3.13 eval job has completed with return code 1.

001 |   File "/home/main.py", line 1
002 |     5 = 10
003 |     ^
004 | SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?
lone briar
#

"cannot assign to literal"

#

It calls it in the class you're converting. It's basically 5.__str__()

#

We can still instantiate with the literal class name. int() gives you 0

#

Python is written in C. I don't personally know how they implemented literals

#

Yeah for sure, that's part of the interpreter

#

You don't really need to understand it unless you're interested in programming languages in general

stuck rootBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.