Ask coding questions

← Back to all posts
Replit Import List
h
BD103

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 [earned 5 cycles]
View Answer
Voters
aatishkotni
LucasYeung1
hokk
DynamicSquid
BD103
Comments
hotnewtop
mat1

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

SixBeeps

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

BD103

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

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

SixBeeps

@mat1 ahaha, nice.

BD103

How does the clear() function work? @mat1

mat1

@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

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

BD103

Thanks! @mat1