Linked Questions

1 vote
2 answers
2k views

I'm trying to make a python program that when you input a code, it executes it. It has 2 problems and I need to fix it. I want it when you executed the code, it gets stored in a variable I want't the ...
Banana Code's user avatar
0 votes
0 answers
494 views

str() turns data into strings but is it possible to undo this with a built in function? exe: str1 = '{"a": 1, "b": 2}' is there a function that can turn this into a dictionary? ...
lugerman's user avatar
2 votes
0 answers
78 views

I want to evaluate an expression in Python 3.7 that is read as string from a config file. The application is a Datalogger and the user shall be able to define his own conversion of the raw ADC value ...
jnzerror's user avatar
350 votes
12 answers
545k views

The book that I am reading on Python repeatedly shows code like eval(input('blah')). How exactly does this modify the result from calling input? See also: Why is using 'eval' a bad practice? ...
Billjk's user avatar
  • 10.7k
188 votes
9 answers
166k views

Sometimes when I get input from a file or the user, I get a string with escape sequences in it. I would like to process the escape sequences in the same way that Python processes escape sequences in ...
dln385's user avatar
  • 12.2k
160 votes
9 answers
157k views

I have an n-by-m Pandas DataFrame df defined as follows. (I know this is not the best way to do it. It makes sense for what I'm trying to do in my actual code, but that would be TMI for this post so ...
Gyan Veda's user avatar
  • 6,629
59 votes
5 answers
187k views

I'm trying to read in a string representation of a Tuple from a file, and add the tuple to a list. Here's the relevant code. raw_data = userfile.read().split('\n') for a in raw_data : print a ...
Sinthet's user avatar
  • 903
23 votes
6 answers
50k views

I am using getopt to process a command line optional argument, which should accept a list. Something like this: foo.py --my_list=[1, 2, 3, 4,5] But this trims everything after "[1," My questions ...
cppb's user avatar
  • 2,429
27 votes
3 answers
139k views

Why do I get this error message: ValueError: malformed node or string when I pass data in the below format into the "parse_webhook" function? Thanks! webhook_data = {"side": "...
FM2020's user avatar
  • 313
5 votes
4 answers
70k views

How would I convert the following string to an array with Python (this string could have an indefinite number of items)? '["Foo","Bar","Baz","Woo"]' This is ...
GCien's user avatar
  • 2,359
23 votes
1 answer
16k views

if I have a string with characters ( 0x61 0x62 0xD ), the repr function of this string will return 'ab\r'. Is there way to do reverse operation: if I have string 'ab\r' (with characters 0x61 0x62 ...
Ivan Borshchov's user avatar
7 votes
5 answers
71k views

Here is my example: >>> a=input ('some text : ') # value entered is 1,1 >>> print (a) 1,1 I want as a result a tuple (1, 1) How can I do this?
user avatar
11 votes
5 answers
48k views

I have a file where on each line I have text like this (representing cast of a film): [{'cast_id': 23, 'character': "Roger 'Verbal' Kint", 'credit_id': '52fe4260c3a36847f8019af7', 'gender': 2, 'id': ...
revy's user avatar
  • 4,817
7 votes
7 answers
11k views

I would like to multiply all elements of a list by a number. I know the other ways to do it but I want to know Why isn't this working? I am getting the very same list as an output. lst = eval(input('...
AdR's user avatar
  • 305
21 votes
1 answer
29k views

I have a user entered string which is already in tuple format and would like to convert/cast it to a actual tuple in python. How can I do this? E.g: strTup = '(5, 6)' Would like to convert the above ...
oscilatorium's user avatar

15 30 50 per page
1
2 3 4 5
12