Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialsathish
5,697 Pointswhat is the use of command python -i? why we use this ? thank you in advance
what is the use of command python -i? why we use this ? what is interactive mode? what does it mean? thank you in advance
3 Answers
Balazs Peak
46,160 PointsThis enables you to run python as a REPL, i.e. readโevalโprint loop.
What is REPL?
It's a common feature of programming language compilers, which enables developers to type code in a CLI fashion, and getting back the value immidiately, to which their code was evaluated. This does not serve production level software development, it is for experimenting with language syntax and testing single-line code snippets, most of the time.
Example:
- If I give 5, to the REPL, it immidiately prints out 5, because that's what 5 evaluates into.
- If I give len([4, 5, 6]) to the repl, it prints out 3, because I gave a list containing 3 items given into the "len" function, which returns its length, which is 3
sathish
5,697 Pointsthank you very much Balazs Pukli
cesarmatta
11,592 Pointsthanks you Balazs
cesarmatta
11,592 Pointscesarmatta
11,592 PointsSo it means that is some kind of way to "test" the code without altering it ?
Balazs Peak
46,160 PointsBalazs Peak
46,160 Pointsyes. You can check what a certain expression evaluates to, or what a function call returns.
Erkindjon Pulatov
1,118 PointsErkindjon Pulatov
1,118 PointsGreat answer! You are awesome!