Is there a way to make a python script output itself when compiled?

I have an arbitrary program that needs to output itself when compiled to bytecode/exe, although it doesn't need to be a quine that contains itself.

I tried having it access itself through open(__file__, 'rt'), but this doesn't work when it is compiled to bytecode.

An example program is this:

import random
if 1 == random.randint(0,1):
    print(source code)

The program prints the source code 50% of the time. What could I add in the print statement?



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation