Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Is there a way to actually take a well formatted input and execute it at an appropriate time?
Something like:
num = 5
command = input()
# do something with command
Now, if i enter "print(num)" as input, it should output
5
What you suggest actually works as is:
>>> x=1
>>> eval(input())
print(x)
1
Another method you can have a look at is the exec method (and above that is a detailed description for eval).
Depending on what you are going for this might be a bad idea though. Have a look at the local and global parameters to restrict the environment.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 20 days ago.
Improve this question
I am facing a problem when I write the code of python in vs-code. I write the same as showing in video code with harry. But I don't understand how to solve it. Just stop working never do any other task. Here is the code.
input
a = input("what is your name: ")
print("My name is zeeshan", a)
Output
what is your name:
after you run this code you need to type to the console your desired output:
after you see the output
what is your name:
type the name and press enter (then the rest of your code will run)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
Hi I'm trying to catch the change in the paperclip of my computer with the library pyperclip something same as
url=pyperclip.paste()
I want to create a thread which can append all the urls into a list my script, but I don't know how to could I do it
Thanks for your time and help c:
Did you check the documentation or the source code at all? That's all I did. pyperclip supports waitForPaste and waitForNewPaste methods that can do this.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
The questions are being asked but the if statements do not show up. What mistake am I making?
print() is a built-in function, if you want to call the function to print out text in the console, you have to use it like this:
print(arguments)
This
print = (arguments)
is not calling print(), but is assigning something to the name "print".
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I was just wondering if this is an clean way of writing code - if you define the same name of a variable (and precisely for a dictionary) that you use as an input and an output of some function e.g.:
my_dic = {}
my_dic = someFunction(my_dic,otherVariables)
**doing other things with my_dic **
The function someFunction only is meant to update the dictionary my_dic, so preferably the output should be the input but updated.
Is this a safe way of coding? or would that result in some possible bugs?
This should not result in any bugs in your program if you are just trying to update the dictionary using a function.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
why the python Cmd module command prompt not using multi-line? it's over writing the same line
example image
I am sorry I don't know, hw to answer ques in stackoverflow, but I found it finally
use self.use_rawinput = False this will fix the problem (If you want a given stdin to be used, make sure to set the instance’s use_rawinput attribute to False, otherwise stdin will be ignored.)
https://docs.python.org/2/library/cmd.html