Ask coding questions

← Back to all posts
Replit Import List
h
BD103 (139)

Hi! I’ve been messing around with imports in Python, and saw the replit import thing. I know about the replit.clear() function, but I don’t know what any of the other imported code does. Can you give me a list of code that the replit import adds in? Thanks!

Answered by mat1 (4428) [earned 5 cycles]
View Answer
Comments
hotnewtop
mat1 (4428)

You can see all the packages that you can install for Python on the Python Package Index

SixBeeps (5221)

Which package are you talking about? The only one I see named 'replit' is by @mat1, which appears to only be memes.

BD103 (139)

When you are on the repl.it editor, you can type in the code import replit and it adds in some things like the replit.clear() code. @niorg2606

mat1 (4428)

@niorg2606 hehe (my package still has the clear function so it shouldn't break anything)

BD103 (139)

How does the clear() function work? @mat1

mat1 (4428)

@BD103 It just runs print('\033[2J\033[H', end=''). This is an ANSI escape sequence that first deletes all the text on the screen (\033[2J) and then moves the cursor to the start (\033[H). The end='' is just so it doesn't print anything extra, since by default it puts a new line (\n) after the message.

SixBeeps (5221)

@mat1 I hate ANSI with all my might but dang does it work like magic, like RegEx.