In Python, if a string represents a statement, to execute it we have to use eval.
In Bash, why is it not the same case?
$ cmd="ls"
$ $cmd
a.out company.png
In Python, if a string represents a statement, to execute it we have to use eval.
In Bash, why is it not the same case?
$ cmd="ls"
$ $cmd
a.out company.png
Python and Bash are entirely different languages. The main purpose of Python is to execute internal statements with the added capability to execute external programs. The main purpose of the shell is to execute external programs, with some control structures and internal commands added. Bash has more internal features than the original shell, but still maintains compatibility.
One of the features of the shell is that you can define variables and have them later expanded in commands. Basically you can think that the shell implicitly uses something like Python's eval for each statement, although there are of course differences.
There is also an eval command to the shell that can be useful and dangerous if the normal level of processing and substitution isn't enough and you need an additional level. It evaluates the rest of the line and feeds the result to the normal substitutions the shell performs. Until you have a better understanding and an actual need for it, it's best to forget about this feature.