Python Forum

Full Version: Python coding in Spyder IDE
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey Guys,
I'm a coding beginner. I had some C# and C++ in school and I want to try python for some smaller projects.
I did not learn how to work with virtual envs, version management, site-packages and all that stuff so I try to become familiar with that also. Confused

After a few hours on Youtube I was able to install anaconda and create envs for my first projects. As IDE I use Spyder.
Here things happens that I do not understand.

First I wanted to find out how logging works because it will help me dealing with problems in the future. I used the examples to try this out and this works perfectly.

import logging
from datetime import datetime

logging.basicConfig(filename='example.log', level=logging.DEBUG)
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
logging.debug(now + ": " + 'debugging information')
My projects will have more than 1 file. This is why I want to create for each 'programname.py' a related log file called 'programname.log'.

To do so I changed the 'example.log' to 'programname.log' in my code.
But new informations are still written into 'example.log'. Even when I copy and execute my code to a new program no 'programname.log' file will be created.

After that I activated my env in a linux terminal and I run my code from there. Python creates my 'programname.log' file and write my informations in there. Dance

It's not directly a coding question, but do someone know why this is not working in Spyder IDE? Huh