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

后端 未结 6 1687
醉酒成梦
醉酒成梦 2021-01-17 07:38

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 c         


        
6条回答
  •  -上瘾入骨i
    2021-01-17 07:51

    I use __END__ all the time for multiples of the reasons given. I've been doing it for so long now that I put it (usually preceded by an exit('0');), along with BEGIN {} / END{} routines, in by force-of-habit. It is a shame that Python doesn't have an equivalent, but I just comment-out the lines at the bottom: extraneous, but that's about what you get with one way to rule them all languages.

提交回复
热议问题