In Python what's the best way to emulate Perl's __END__?

python

Solution

The triple-quote form you suggested will still create a python string, whereas Perl's parser simply ignores anything after `__END__`. You can't write:

"""
I can put anything in here...
Anything!
"""
import os
os.system("rm -rf /")

Comments are more suitable in my opinion.

#__END__
#Whatever I write here will be ignored
#Woohoo !

Problem

Am I correct in thinking that that Python doesn't have a direct equivalent for Perl's `__END__`? ``` print "Perl...\n"; __END__ End of code. I can put anything I want here. ``` One thought that occurred to me was to use a triple-quoted string. Is there a better way to achieve this in Python? ``` print "Python..." """ End of code. I can put anything I want here. """ ```

Original source