In Python what is it called when you see the output of a variable without printing it?

python print variable name and value
python repl environment
repl shell in python
repl process

In Python you can see the value of a variable without printing it, like:

>>> a = 'hello world'
>>> a
hello world

This is different from printing print(a), yet I'm still able to see a similar output. What it the technical term for this type of variable printing?

As an example of the difference, below shows how a Jupyter Notebook prints a dataframe for both types of printing:

You're executing code in a REPL; the P stands for "print".

It's being implicitly printed by the console.

Your Guide to the Python print() Function – Real Python, Print Is a Function in Python 3; print Was a Statement in Python 2 Secondly, you could extract that message into its own variable with a meaningful name to You saw print() called without any arguments to produce a blank line and then called In order to save it to a file, you'd have to redirect the output. Output: 15 None. We can see that the sum is printed (because our function was called), but the result variable has a value of None instead of 15. In the next section let’s see how we can return values. Defining a Function That Returns a Result. We can use the return keyword to leave the current function call and to return a wanted result.

It's not Python but the Python shell's (IDLE) behavior you're seeing. The way it's built, it prints the type or value of the item you specify. The actual Python would be to have this code inside a .py file:

a = 'hello world'

and you do python then you'd see nothing, because the value returned by a would be silently discarded. The cli works as if there's an implicit print() statement there.

Printing variables in Python : keywords, function and type., Learn to print variables in Python. Now that you have a good command on previous chapter, let's do something Notice that simple 8 is an int but 8.0 is a float. 3.14 print(type(a)) print(type(b)) print(type(pi)) print(a) print(b) print(pi). Output Without comments, it would be a very difficult job for them to understand your� Python provides numerous built-in functions that are readily available to us at the Python prompt. Some of the functions like input() and print() are widely used for standard input and output operations respectively. Let us see the output section first.

What you are seeing if the repr of the last expression returned by the interpreter to the global namespace in interactive mode. This is fundamentally different from the a print output, although they do go to the same stream.

For simple objects such as integer they look the same.

>>> x = 1
>>> print(x)
>>> x

The difference is that print send the string representation of the object to the STDOUT. Inputting a variable and hitting enter shows you the repr of the object. To me the big difference is that the later can be easily captured by adding an assignment to the expression, i.e. y = x. While the print output is more complicated to capture.

That is why I use the phrase "returns the value for x" or "returns x". This indicates that if you wanted to capture the return as another variable, you could.

Here is a short example to show the difference between print and repr.

>>> class Foo:
...     def __repr__(self):
...         return f'<Foo at 0x{id(self):x}>'
...     def __str__(self):
...         return 'Foo-object'
>>> f = Foo()
>>> print(f)
>>> f
<Foo at 0x17416af3c18>

2. Variables, expressions and statements — How to Think Like a , is a string, so-called because it contains a string of letters. Python interprets 1,000,000 as a list of three items to be printed. If you give a variable an illegal name, you get a syntax error: produces the output: we have looked at the elements of a program — variables, expressions, and statements — in isolation, without� LISTING 4.13 Assigning a Value to a Python Variable >>> coffee_cup = 'coffee' >>> print (coffee_cup) coffee >>> As you see in Listing 4.13, the print function can output the value of the variable without any quotation marks around it. You can take output a step further by putting a string and a variable together as two print function arguments.

1.10. Input and Output — Hands-on Python Tutorial for Python 3, In the program this value is assigned to the variable person, for use later. Without the prompt, the user would not know what was happening, and the If you add a final field, sep='' , in the print function in , you get the We use this as an analogy: Python has a similar construction, better called � Python Version Note: Should you find yourself working with Python 2.x code, you might bump into a slight difference in the input functions between Python versions 2 and 3. raw_input() in Python 2 reads input from the keyboard and returns it. raw_input() in Python 2 behaves just like input() in Python 3, as described above.

Variables and scope — Object-Oriented Programming in Python 1 , To define a new variable in Python, we simply assign a value to a label. As we saw in the previous sections, the assignment operator in Python is a single us express it more cleanly, without having to write the name of the variable twice: When we call the function, the print statement inside outputs 3 – but why does the � @RCross In Python 2, this is indeed true – Unicode strings will be encoded using sys.stdout.encoding when printing them. So you will need to use u'Elys\xe9e'.encode(sys.stdout.encoding) to get the equivalent of what print is doing.

7. Input and Output — Python 3.8.5 documentation, You'll still use { and } to mark where a variable will be substituted and can provide When you don't need fancy output but just want a quick display of some variables for Formatted string literals (also called f-strings for short) let you include the value of import math >>> print(f'The value of pi is approximately { math.pi:.3f}. You can also include something in your code which won't be compiled and your computer will simply ignore that while running your code. Comments are written to make our code more readable. Comments are written after '#'. Comments written after '#' are single line comments. New line will not be a part of the comment. Python 2; Python 3

  • The returned value.
  • It's just the behavior of the interactive interpreter; the result of any expression is written to standard output. Nothing similar happens when you run a script outside of the interactive interpreter.
  • in an interactive interpreter, the REPL, you get essentially print(repr(whatever)), it's just printing, that is what a REPL is, a read, evaluate, print, loop
  • This isn't restricted to variables; type any expression at the prompt, and its value is printed to standard output. (The exception being an expression that evaluates to None; in that case, nothing is shown.)
  • @James, for something like print(a) I would say "I print the variable a". For typing a by itself would it be correct to say "I return the variable a"? Or something else?
  • For print(a) I would say "I print the variable a". For typing a by itself would it be correct to say "I implicitly print the variable a"? Or something else? Is there Python documentation that discusses this?
  • @NicScozzaro I can't say honestly that I've ever differentiated between whether an expression was explicitly or implicitly printed. It rarely (if ever?) matters. I'd just say "a was printed out".
  • It matters to me because for example, if you print a dataframe vs implicitly print a dataframe in Jupyter Notebook you get different results. The latter is nicely printed as a table. I'm just looking for the correct term to refer to this, since it's not printing.
  • @NicScozzaro Ah, that would likely be a difference in whether or not the object's __repr__ method was called. Your console might not properly call __repr__ if it's printing out differently. That method defines how objects are printed nicely.
  • print calls __str__, not __repr__.
  • Interesting. From the documentation,, repr is the "official" string representation while str is the "informal" string representation. Your answer seems the most correct to me, but I'm still not clear what terminology to use to refer to one vs the other succinctly though.