__pycache__ folder executes each time i run any other file in the folder
Question: I am learning python and I have a tutorial folder with 5 or 6 python files.
One of them contained regex functions say `file_regex.py`. The problem is when
I execute any other file in the folder, always `file_regex.py` is executed
thus giving the output of `file_regex.py`. I am not importing file_regex.py in
any of the other files.

`file_regex.py`

> import re
>
> sentence = ''' Jessica_is_27 year7s old, whereas John is 12 but Stephanie is
> 12 and Marco is 50 years '''
>
> ages = re.findall(r'\d{1,3}', sentence)
>
> names = re.findall('[A-Z][a-z]+', sentence) test = re.findall('\W',
> sentence)
>
> print(ages)
>
> print(names)
>
> print(test)

This is because of the `__pycache__` folder created which has a `.pyc` file
for `file_regex.py` file.

`regex.cpython-23.pyc`

> � Vo�U�@sjddlZdZejde�Zejde�Zejde�Zee�ee�ee�dS)�NzX Jessica_is_27 year7s old,
> whereas John is 12 but Stephanie is 12 and Marco is 50 years
> z\d{1,3}z[A-Z][a-z]+z\W)�re�sentence�findallZages�names�test�print�rr�!/home/sivasurya/tutorial/regex.py�s

I have two questions:

  1. Why does the `__pycache__` folder created only for `file_regex.py` file
  2. How can I delete `__pycache__` folder or a solution to this problem (I tried compiling the python file with `python -B file1.py` command, which didn't work)

P.S: I work in miniconda environment (python 3.x), if that helps


Answer: > This is because of the `__pycache__` folder . . .

This is incorrect. The existence of the `__pycache__` folder has nothing to do
with whether a file is run or not. It simply holds the compiled files, nothing
else.

If your `file_regex.py` keeps being executed it is because the other files
have

    
    
    import file_regex
    

or

    
    
    from file_regex import ...
    

in them.

