1

In PHP like below

<?php

$a = 'b'
$b = 'c'

echo $$a

?>

Output: c

Is there any similar kind of implementation in Python like $$..?

1 Answers1

1

no .... not really you can do stuff like

a = 'b'
b = 'c'

globals().getattr(a,None)

or even better use a dict (you should really do this!!!)

env = {'a':5,'b':'a'}
env[env['b']]

but there is nothing like $$a

Joran Beasley
  • 110,522
  • 12
  • 160
  • 179