Linked Questions

33 votes
3 answers
46k views

I want to assign : x0='123' x1='123' x2='123' x3='123' x4='123' x5='123' x6='123' x7='123' x8='123' x9='123' I write the code to express that i can get the ...
showkey's user avatar
  • 355
26 votes
4 answers
13k views

I want to define a Python function using eval: func_obj = eval('def foo(a, b): return a + b') But it return invalid syntax error? How can I make it? Btw, how can I transform a function obj to a ...
xunzhang's user avatar
  • 2,946
0 votes
1 answer
8k views

How to convert a=b=2 string into a=2, b=2 (actual assignments) in python? There are some python parsers which give output for expressions like 2+3+4. But how to use a=b=2 string into variable as a=2 b=...
Girish Ns's user avatar
  • 281
0 votes
2 answers
2k views

If I have a string containing some code in a python file. I want to run the code in the string, for example: program = "for i in range(100):\n\tprint(i)" eval(program) However, I'm pretty sure eval ...
Flat Earth Society Alabama's user avatar
-1 votes
4 answers
4k views

i just want to know how to turn a string expression into a normal expression, where I can solve it. Example: "1 + 1" i don't want the above in a string, I want it to be 1 + 1 Another ...
Sovereign's user avatar
2 votes
1 answer
3k views

I want to be able to take a string which describes a Python function and turn it into a function object which I can then call. For example, myString = "def add5(x): return x + 5" myFunc = ...
Noah Hunt-Isaak's user avatar
0 votes
1 answer
879 views

I want to execute python code in my browser. Now I enter code in text-field in template, took it to view, where doing following: source = request.POST.get('source', '').replace('"', r'\"') result = ...
Taras Zak's user avatar
0 votes
4 answers
487 views

I want to do following. Script has some python code as a string (saved in a variable) and is it possible to run that code ? Well, I know one way, writing that string to a file & running it, but ...
avi's user avatar
  • 9,666
0 votes
1 answer
91 views

If I have a srting inside my Python code that looks like this: x = "print('Hello World')" I want to execute it as if it is like a seperate .py file. Is there something like execute(x)
Omar's user avatar
  • 363
1 vote
1 answer
315 views

I have a .txt file that has the following text: "np.sqrt(2)**2" I can't get the answer to this mathematical equation because is a string, does anyone know how to convert that text to code (...
Juan C. Vecino's user avatar
1 vote
1 answer
195 views

I have a text file with 2 lines fyers.place_orders(token = token, data = {"symbol" : "NSE:SBIN-EQ","qty" : 1,"type" : 2,"side" : 1,"productType" : "INTRADAY","limitPrice" : 0,"stopPrice" : 0,"...
J-Jillu's user avatar
  • 65
0 votes
1 answer
203 views

I am trying to parse a textfile where a matrix is saved in the string format: "[[0,1],[1,0]]" To goal is to parse the .txt file and turn it into an actual matrix represented by an arrays of ...
user128226's user avatar
-1 votes
1 answer
141 views

I have a little problem, I have written a for loop as a string. In PHP, with the help of function exec(), we can run the string which will eventually run the for loop defined inside the string. Can ...
cleanet's user avatar
  • 91
-2 votes
2 answers
70 views

I mean I have this string var: mystr1 = "1==1 or 1==2" mystr2 = "1==1 and 1==2" if_logical_string(mystr1) must be True if_logical_string(mystr2) must be False How can I achieve this? Is there any lib ...
chickensoup's user avatar
-1 votes
2 answers
81 views

a = input('Enter something:') #e.g. input is print('Hello World') # some function print(a) #and then we get only `Hello World` out as we use print I already researched executing shell commands via ...
P-CAST's user avatar
  • 53

15 30 50 per page
1
2 3 4 5
7