How can this code print Hello World without any print statement
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Book End
--
Chapters
00:00 Question
01:18 Accepted answer (Score 14)
01:43 Thank you
--
Full question
https://stackoverflow.com/questions/3140...
Question links:
[Here's]: http://codepad.org/UzSmoxF2
[Here]: https://benkurtovic.com/2014/06/01/obfus...
Accepted answer links:
https://benkurtovic.com/2014/06/01/obfus...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python
#avk47
    --
Music by Eric Matyas
https://www.soundimage.org
Track title: Book End
--
Chapters
00:00 Question
01:18 Accepted answer (Score 14)
01:43 Thank you
--
Full question
https://stackoverflow.com/questions/3140...
Question links:
[Here's]: http://codepad.org/UzSmoxF2
[Here]: https://benkurtovic.com/2014/06/01/obfus...
Accepted answer links:
https://benkurtovic.com/2014/06/01/obfus...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python
#avk47
ACCEPTED ANSWER
Score 14
The answer to the question as written: The code avoids a print statement by os.write()ing to stdout's file descriptor, which is 1:
getattr(__import__("os"), "write")(1, "Hello world!\n")
The rest of the explanation is detailed at https://benkurtovic.com/2014/06/01/obfuscating-hello-world.html. Instead of a summary here, just read the original!