how do you configure a command prompt for a python program and then execute it?

I don’t think you’ll see non-monospaced fonts in a console. However, the width and height of the console window could be an issue – in Windows, you can change the size of the console window by running mode width, height for example mode 120,40. You can issue that command from your Python script as well.

import os

os.system('mode 180,20')
print('Hello wide world!')
os.system('pause')

This example demonstrates the effect you appear to be after.

Note that this won’t affect specific consoles, for example the console your script will run in from an IDE like PyCharm – it assumes your code is running in a normal Windows console window.

Generally speaking, I’d recommend against solutions like these. They make your script specific to a particular OS and a particular way of running at that. It’s often better to come up with solutions that will work mostly anywhere.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top