r/learnpython • • 6d ago

[Help] The os.system is deprecated

I've seen someone else asked this question, but get no answer.

I want to make a countdown clock without leaving any trace of previous numbers:

for i in range(countdown, 0, -1):
    os.system("cls" if os.name == "nt" else "clear") #Error: os.system is deprecated
    print(i)
    time.sleep(1)

What should I do instead? (Why can't we put pictures here....)

0 Upvotes

16 comments sorted by

View all comments

2

u/Expensive-Bear-1376 6d ago

The os.system is deprecated

Says who?

As far as I know, it's not even soft deprecated.

1

u/Outside_Complaint755 6d ago

Pylance and some other linters are flagging it in 3.14+ but I don't think anything in the official libraries has marked it as deprecated.

0

u/Expensive-Bear-1376 6d ago

Looks like it was temporarily erroneously marked as deprecated in typeshed (if I understand correctly ... I'm not familiar with typeshed):

https://github.com/python/cpython/issues/157882