mikeckennedy / python-for-entrepreneurs-course-demos

Contains all the "handout" materials for Talk Python's Python for Entrepreneurs course. This includes notes and the final version of the website code.
https://training.talkpython.fm/courses/explore_entrepreneurs/python-for-entrepreneurs-build-and-launch-your-online-business
MIT License
286 stars 141 forks source link

'clear' is not recognized as an internal or external command #2

Closed ianmonat closed 7 years ago

ianmonat commented 7 years ago

Hi Michael,

I'm just starting your Python for Entrepreneurs course and am enjoying it so far.

I just finished the Python language refresher game and although my code runs, it contains this message about the word 'clear'. (see below)

I tried copying your code from github into my file and the message still displays, so I don't think it's a bug in my code, but perhaps some system setting that needs changing. I'm on Windows 7 and using PyCharm.

Couldn't find the exact fix on Stackoverflow so I thought I'd ask you how to get rid of it, it's more annoying than anything. Thank you. -Ian

C:\Users\imonat\AppData\Local\Programs\Python\Python35-32\python.exe C:/Users/imonat/Desktop/Python_Scripts/PyForEnt/program.py
'clear' is not recognized as an internal or external command,
operable program or batch file.
Blue  'clear' is not recognized as an internal or external command,
operable program or batch file.
1 moves:
Next [r,g,b,y]: b
'clear' is not recognized as an internal or external command,
operable program or batch file.
Blue  Yellow  'clear' is not recognized as an internal or external command,
operable program or batch file.
2 moves:
Next [r,g,b,y]: b
Next [r,g,b,y]: y
'clear' is not recognized as an internal or external command,
operable program or batch file.
Blue  Yellow  Yellow  'clear' is not recognized as an internal or external command,
operable program or batch file.
3 moves:
Next [r,g,b,y]: r
Sorry, that was wrong
Game over

Process finished with exit code 0
mikeckennedy commented 7 years ago

Hi,

The error is because I didn't check whether you're on Windows or a *nix based system. If you change clear to cls it will work.

mikeckennedy commented 7 years ago

The most recent check-in fixes the issue:

def clear(self):
    if os.name == 'nt':
        os.system('cls')
    else:
        os.system('clear')
mikeckennedy commented 7 years ago

Thanks for letting me know about this error.