Python Forum
initializing interactive mode
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
initializing interactive mode
#3
(May-29-2024, 07:58 PM)Gribouillis Wrote: Here is a third untested way, if you don't want to define PYTHONSTARTUP (I never define permanently python-related environment variables). In file usercustomize.py write this
# in usercustomize.py
import sys
if hasattr(sys, 'ps1'): # we are in interactive mode
    with open('spam.py') as ifh:
        exec(ifh.read(), vars(sys.modules['__main__']))

could i just put some other code in place of open+exec lines, under the test for interactive, to do what i want to happen in interactive?

can file usercustomize.py be put in the user's home directory?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
initializing interactive mode - by Skaperen - May-29-2024, 07:20 PM
RE: initializing interactive mode - by Gribouillis - May-29-2024, 07:58 PM
RE: initializing interactive mode - by Skaperen - May-29-2024, 11:48 PM
RE: initializing interactive mode - by Gribouillis - May-30-2024, 06:25 AM
RE: initializing interactive mode - by Skaperen - Jun-02-2024, 03:29 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020