Anything similar to __END__ in perl

Rustom Mody rustompmody at gmail.com
Fri Dec 8 05:19:13 EST 2017


On Friday, December 8, 2017 at 3:13:56 PM UTC+5:30, Karsten Hilbert wrote:
> On Thu, Dec 07, 2017 at 11:55:48PM -0600, Peng Yu wrote:
> 
> > Hi, perl has __END__ which ignore all the lines below it.
> > 
> > Is there anything similar to __END__ in python? Thanks.
> 
> Something similar is:
> 
> 	import sys
> 	sys.exit()

That will give syntax (or something) errors for what follows

I'd say something similar is """

eg
----
$ cat xyz.py
def f():
    print("hello world")

f()

"""
Tyger Tyger burning bright
In the forests of the night
What immortal hand or eye
Dare frame thy fearful symmetry
"""



More information about the Python-list mailing list