The code version of python -i <filename>
Peter Otten
__peter__ at web.de
Wed Sep 15 10:08:32 EDT 2021
On 15/09/2021 15:39, Abdur-Rahmaan Janhangeer wrote:
> Greetings,
>
> If i have a file name flower.py and i add x = 1 in it.
> When i run python -i flower.py i get a shell
>>>>
>
> If type x i get 1
>>>> x
> 1
>
> The values are auto injected.
>
> How do i start a shell by code with values already injected? Thanks
>
> Kind Regards,
I tried
import code
x = 42
code.interact(local=globals())
but didn't bother to read the documentation at
https://docs.python.org/3/library/code.html
and thus do not know what the limitations might be.
More information about the Python-list
mailing list