+ 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

17th Aug 2018, 4:25 PM
LONGTIE👔
LONGTIE👔 - avatar
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.
24th Aug 2018, 11:06 AM
Wansley Nery
Wansley Nery - avatar
+ 10
Maninder Singh it must have something to do with how sololearn reads the code
17th Aug 2018, 4:38 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 8
because it is sololearn! want to see more weird stuff? try executing this line : print("/hello/world/does_this_work?/")
17th Aug 2018, 5:26 PM
code learner
code learner - avatar
+ 8
../Playground/?/
17th Aug 2018, 5:33 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 8
btw HonFu use a hashtag when commenting input. that way it doesn't get called.
17th Aug 2018, 5:35 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 6
Wansley Nery thanks you for your very informative answer.
24th Aug 2018, 1:43 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 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
17th Aug 2018, 10:52 PM
code learner
code learner - avatar
+ 4
Weirdo🙊🙊🙊
17th Aug 2018, 4:27 PM
Seniru
Seniru - avatar
+ 3
it does not work on pc or any other platform.
17th Aug 2018, 4:36 PM
Maninder $ingh
Maninder $ingh - avatar
+ 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. ;-)
17th Aug 2018, 5:06 PM
HonFu
HonFu - avatar
+ 2
Haha, what's that? :D
17th Aug 2018, 5:30 PM
HonFu
HonFu - avatar
+ 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
18th Aug 2018, 1:39 PM
michal
+ 1
Ah, thanks, LONGTIE, that makes sense. I just fell back on using 'enter' or 'write' or whatnot.
17th Aug 2018, 5:45 PM
HonFu
HonFu - avatar
+ 1
I think the playground checks the code for input() to know if input is needed
18th Aug 2018, 10:28 AM
Tim
Tim - avatar
+ 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
18th Aug 2018, 1:35 PM
michal
0
playground
18th Aug 2018, 12:18 AM
Vinith Thavarasa
Vinith Thavarasa - avatar
0
don't speak indo
25th Aug 2018, 7:41 AM
Xizhe Lee
Xizhe Lee - avatar