Python also requires the instance to refer to instance variables, unlike the examples in perlclass (as of now for v5.40.0).
import sys class X: def __init__( it, var ): it.var = var return def show( it ): print( f'{it.var = }' ) try: print( f'{var = }' ) except (NameError): sys.stderr.write( '(Should have qualified with the instance o +bject!)\n' ) raise return X( var = 'value' ).show() # python3.11 x.py it.var = 'value' (Should have qualified with the instance object!) Traceback (most recent call last): File "/home/aa/tmp/python/x.py", line 18, in <module> X( var = 'value' ).show() File "/home/aa/tmp/python/x.py", line 11, in show print( f'{var = }' ) ^^^ NameError: name 'var' is not defined. Did you mean: 'vars'?
In reply to Re^4: Using perlclass 'methods'
by parv
in thread Using perlclass 'methods'
by drudgesentinel
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |