str(name)=input('Enter a name\n')
is there a better way than using raw_input() ?
Just use raw_input like you say yourself.
name = raw_input('Enter a name\n')
What is your problem, actually?
Im actually a beginner and was jus curious to know if using only input and then type casting it to string was possible...was jus trying to do something like this, for example ;
>>> input() 3 * 4 ** 5 3072
This cant be done with rawinput, so was just wondering...
In Python2 the input() function actually uses raw_input() and eval().
You can enter a string with input() if you put it in quotes.
The function eval can turn evil if you enter a command to whipe out your hard disk for instance.
With Python3 raw_input() turns into simply input() and gives a string, thus eliminating the dangers of eval().
My advice, in Python2 it is better not to use the input() function. If you don't want to type raw_input all the time start your code with something like this ...
>>> input = raw_input >>> >>> name = input("Enter your name: ") Enter your name: Clark Kent >>> name 'Clark Kent' >>>
... now you are in line with Python3 syntax.
Oh ok thanks I do have a much better understanding now :)