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 trial

Python Introducing Lists Meet Lists Indexing

what 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
Balazs Peak
46,160 Points

This 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

So it means that is some kind of way to "test" the code without altering it ?

Balazs Peak
Balazs Peak
46,160 Points

yes. You can check what a certain expression evaluates to, or what a function call returns.

thank you very much Balazs Pukli

thanks you Balazs