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

Posted by FM on Stack Overflow See other posts from Stack Overflow or by FM
Published on 2010-03-18T17:18:46Z Indexed on 2010/03/18 17:21 UTC
Read the original article Hit count: 151

Filed under:

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.
"""

© Stack Overflow or respective owner

Related posts about python