Addition of fixed processing when starting python interpreter

environment

Purpose

Because it was troublesome to write an import statement every time I started it with the python interpreter I investigated the setting method that automatically imports at the time of startup.

How to do

Create the following files in the home directory (C: \ Users \ <username> \)

python:.pythonstartup.py


from datetime import datetime
date = datetime.now()

Or something like that Set the following in the environment variables

setx PYTHONSTARTUP C:\Users\<username>\.pythonstartup.py

After that, just type python at the command prompt and the contents of the file will be executed.

>python
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
2020-12-23 20:35:52.167887
>>> 

It is convenient to write the module import statement that you often use in the pythonstartup.py file. After that, if you set the path of the module under test with the environment variable, it is convenient when you only test

Recommended Posts

Addition of fixed processing when starting python interpreter
Image processing? The story of starting Python for
Various processing of Python
Post processing of python (NG)
[Python] PyCharm environment settings (installation, interpreter settings, addition of packages) Mac environment
Eliminate WARNING when starting Python IDLE
Periodic execution processing when using tkinter [Python3]
(Java, JavaScript, Python) Comparison of string processing
Grayscale by matrix-Reinventor of Python image processing-
Rehabilitation of Python and NLP skills starting with "100 Language Processing Knock 2015" (Chapter 1)
Processing when the key input of Python pygame does not go well.
Drawing with Matrix-Reinventor of Python Image Processing-
A reminder of what I got stuck when starting Atcoder with python
The story of blackjack A processing (python)
Status of each Python processing system in 2020
Matrix Convolution Filtering-Reinventor of Python Image Processing-
Beware of disable_existing_loggers when setting up Python logging
View the result of geometry processing in Python
Character encoding when using csv module of python 2.7.3
[Note] Python, when starting machine learning / deep learning [Links]
Rehabilitation of Python and NLP skills starting with "100 Language Processing Knock 2015" (Chapter 2 second half)
Introduction of Python
Rehabilitation of Python and NLP skills starting with "100 Language Processing Knock 2015" (Chapter 2 first half)
python image processing
Python file processing
Basics of Python ①
Basics of python ①
Copy of python
Introduction of Python
[Language processing 100 knocks 2020] Summary of answer examples by Python
Image processing by matrix Basics & Table of Contents-Reinventor of Python image processing-
Implementation example of simple LISP processing system (Python version)
Full-width and half-width processing of CSV data in Python
[Chapter 5] Introduction to Python with 100 knocks of language processing
Note when putting lxml of python package in ubuntu 14.04
Summary of Pandas methods used when extracting data [Python]
Examine the close processing of Python dataset (SQLAlchemy wrapper)
[Chapter 3] Introduction to Python with 100 knocks of language processing
[Chapter 2] Introduction to Python with 100 knocks of language processing
Python asynchronous processing ~ Full understanding of async and await ~
Things to keep in mind when processing strings in Python2
Summary of date processing in Python (datetime and dateutil)
Things to keep in mind when processing strings in Python3
[Chapter 4] Introduction to Python with 100 knocks of language processing
[For beginners of competitive pros] Three input methods to remember when starting competitive programming in Python