Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python underscore variable

In interactive python, there is the 'continuation variable', the underscore.

>>> import netlib
>>> netdev = netlib.netface('eth1')
>>> if netdev.getIP():
...    print _
... 
10.80.22.100
>>>

But using this in a script, it is undefined so this fails:

if netdev.getIP(): SetValue('ipaddress', _)

Is there something similar or a way to enable this for scripts?

like image 283
tMC Avatar asked Mar 03 '26 05:03

tMC


1 Answers

No. It is only available within the Python REPL.

like image 134
Ignacio Vazquez-Abrams Avatar answered Mar 04 '26 17:03

Ignacio Vazquez-Abrams



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!