Skip to content

Commit cd813b4

Browse files
committed
deprecated eprint, get_char, and prompts
1 parent 12747c7 commit cd813b4

File tree

1 file changed

+6
-58
lines changed

1 file changed

+6
-58
lines changed

src/cs50/cs50.py

Lines changed: 6 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,7 @@ def write(self, x):
3333

3434

3535
def eprint(*args, **kwargs):
36-
"""
37-
Print an error message to standard error, prefixing it with
38-
file name and line number from which method was called.
39-
"""
40-
end = kwargs.get("end", "\n")
41-
sep = kwargs.get("sep", " ")
42-
(filename, lineno) = inspect.stack()[1][1:3]
43-
print("{}:{}: ".format(filename, lineno), end="")
44-
print(*args, end=end, file=sys.stderr, sep=sep)
36+
raise NotImplementedError("The CS50 Library for Python no longer supports eprint, but you can use print instead!")
4537

4638

4739
def formatException(type, value, tb):
@@ -71,24 +63,10 @@ def formatException(type, value, tb):
7163

7264

7365
def get_char(prompt=None):
74-
"""
75-
Read a line of text from standard input and return the equivalent char;
76-
if text is not a single char, user is prompted to retry. If line can't
77-
be read, return None.
78-
"""
79-
while True:
80-
s = get_string(prompt)
81-
if s is None:
82-
return None
83-
if len(s) == 1:
84-
return s[0]
85-
86-
# Temporarily here for backwards compatibility
87-
if prompt is None:
88-
print("Retry: ", end="")
66+
raise NotImplementedError("The CS50 Library for Python no longer supports get_char (because Python doesn't have a type for individual characters), but you can use get_string instead!")
8967

9068

91-
def get_float(prompt=None):
69+
def get_float(prompt):
9270
"""
9371
Read a line of text from standard input and return the equivalent float
9472
as precisely as possible; if text does not represent a double, user is
@@ -104,12 +82,8 @@ def get_float(prompt=None):
10482
except ValueError:
10583
pass
10684

107-
# Temporarily here for backwards compatibility
108-
if prompt is None:
109-
print("Retry: ", end="")
11085

111-
112-
def get_int(prompt=None):
86+
def get_int(prompt):
11387
"""
11488
Read a line of text from standard input and return the equivalent int;
11589
if text does not represent an int, user is prompted to retry. If line
@@ -127,34 +101,8 @@ def get_int(prompt=None):
127101
except ValueError:
128102
pass
129103

130-
# Temporarily here for backwards compatibility
131-
if prompt is None:
132-
print("Retry: ", end="")
133-
134-
135-
if sys.version_info.major != 3:
136-
def get_long(prompt=None):
137-
"""
138-
Read a line of text from standard input and return the equivalent long;
139-
if text does not represent a long, user is prompted to retry. If line
140-
can't be read, return None.
141-
"""
142-
while True:
143-
s = get_string(prompt)
144-
if s is None:
145-
return None
146-
if re.search(r"^[+-]?\d+$", s):
147-
try:
148-
return long(s, 10)
149-
except ValueError:
150-
pass
151-
152-
# Temporarily here for backwards compatibility
153-
if prompt is None:
154-
print("Retry: ", end="")
155-
156-
157-
def get_string(prompt=None):
104+
105+
def get_string(prompt):
158106
"""
159107
Read a line of text from standard input and return it as a string,
160108
sans trailing line ending. Supports CR (\r), LF (\n), and CRLF (\r\n)

0 commit comments

Comments
 (0)