+ 9
[SOLVED]Why is input called?
if you read this code, all of it is in a multi-line comment. so why is the input being called? https://code.sololearn.com/cWOgWpxLEHOD/?ref=app
17 odpowiedzi
+ 2
LONGTIE👔 The way that Python look for comments is a little bit different than other languages. In the original documentation of Python web site, they spoke more about PEP 257 -- Docstring Conventions (https://www.python.org/dev/peps/pep-0257/).
First: You need to be use double quotes (For consistency, always use """triple doublequotes""" around docstrings. Use r"""raw triple double quotes""" if you use any backslashes in your docstrings. For Unicode docstrings, useu"""Unicode triple-quoted strings""".)
Second: One-line nor Multi-line Docstrings is made to enclosure real methods.
Third: Some on-line debuggers read each byte to see compile errors exception and after, compile and execute the code. If the debugger, when reading a script, don't see the correct pattern or standard convention model (how we see above), it reads like a normal function. Try put # instead ' ' ' and see the magic happens.
I hope You get it and good study.
+ 10
Maninder Singh it must have something to do with how sololearn reads the code
+ 8
because it is sololearn!
want to see more weird stuff?
try executing this line :
print("/hello/world/does_this_work?/")
+ 8
../Playground/?/
+ 8
btw HonFu use a hashtag when commenting input. that way it doesn't get called.
+ 6
Wansley Nery thanks you for your very informative answer.
+ 5
for some reason (maybe security) the , they(sololearn) scan the code before executing. That's why you are getting input prompt even if input() is in comments.
Another phenomenon of this is if you try printing /some_txt0/some_txt1/some_text2/......./some_txtN it will replace it with that playground thing.
Reason they think its a file path
+ 4
Weirdo🙊🙊🙊
+ 3
it does not work on pc or any other platform.
+ 3
Yeah, I had that too. ^^
In a code I explicitly wanted to avoid the annoying cram-input in the beginning and asked in the comment that the user 'input' the data in the code...
And bam, the cram-mode started anyway. ;-)
+ 2
Haha, what's that? :D
+ 2
This is a opposite example: wants input but doesn't ask for it
https://code.sololearn.com/cPHaN5yFK2oS/?ref=app
And this is similar to yours:
https://code.sololearn.com/cegePegw03XJ/?ref=app
+ 1
Ah, thanks, LONGTIE, that makes sense.
I just fell back on using 'enter' or 'write' or whatnot.
+ 1
I think the playground checks the code for input() to know if input is needed
+ 1
Codes requiring input show the popup while codes not requiring inout don't show it. But it is not so easy to determine which codes require it.
They probably just look if there is input() in the source code.
I was once trying to use sys.stdin or something similar to read input and it didn't show the popup
0
playground
0
don't speak indo