def square(x):
"""Can you see me?"""
return x*x
Hover over square
and see an underline appear; press Ctrl to display tooltip with the docstring.
result = square(2)
This import is underlied as it should be placed at the top of the file; it has an orange underline as this is only a warning.
from statistics import mean
You can also hover over statistics
and mean
(while holding Ctrl) to see the documentation of those.
undefined_variable
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-4-4c6d5bf4bce5> in <module> ----> 1 undefined_variable NameError: name 'undefined_variable' is not defined
you will see red underline for an undefined variable (example above) or for an invalid syntax.
Also, spurious whitespaces can be highlighted (if server supports such diagnostic):
class Dog:
def bark(self):
print('🐕 woof woof')
Dog().bark()
🐕 woof woof
Empty cells will cause "too many blank lines" warning as each cell is padded with two new lines. If we remove the blank cell, everything will be perfect!
Search for "Show diagnostics panel" in the commands palette, or invoke it from the context menu to display all the diagnostics from the file in one place.
The diagnostics panel allows you to sort the inspections and go to the respective locations in the code (just click on the row of interest).
class Cat:
def miaow(self):
print('miaow')
Autocompletion works without the kernel - try completing "Cat" below using Tab, without running the cell above:
Ca
You can see that all the double-dunder methods of the class are immediately available:
Cat.__
It also automatically invokes the completion suggestions after typing a dot (.):
Cat
You can rename symbols by pressing F2 or selecting rename option from the context menu.
If you rename the test
variable below to test2
, both occurrences (in the two following cells) will be updated:
test = 1
test
However, a local reference from a different scope (inside the abc()
function) will be unafected:
def abc():
test = 2
test
Which is different to the simplistic behaviour of the built-in search-and-replace function.