Timeline for Execute a string as a command [duplicate]
Current License: CC BY-SA 3.0
Post Revisions
13 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 24, 2015 at 18:20 | history | closed | Community Bot | Duplicate of Running Python code contained in a string | |
| Mar 24, 2015 at 17:35 | comment | added | jumbi533 | I did consider writing the script so the program saves everything into a text file and works from there. The thing is though, I have already made it so the program can rewrite itself, although if it were to create anoth 'def' then it would need to (obviously) make a new 'def' function that was not named the same name as the others, and the easiest way to do that is with strings. | |
| Mar 24, 2015 at 17:21 | comment | added | Joran Beasley | if you are trying to write a program that can write its own code ... that is not like AI... that is AI ... and very complicated stuff... if thats not really what you are trying to do you should come up with a better way of doing this than eval and exec | |
| Mar 24, 2015 at 17:17 | review | Close votes | |||
| Mar 24, 2015 at 18:21 | |||||
| Mar 24, 2015 at 17:10 | vote | accept | jumbi533 | ||
| Mar 24, 2015 at 17:03 | answer | added | vks | timeline score: 3 | |
| Mar 24, 2015 at 17:02 | comment | added | jumbi533 | A better example would be something like this. x = "def name():" x | |
| Mar 24, 2015 at 17:00 | comment | added | jumbi533 | I was trying to create a program the seems like artificial intelligence (it's really not) that helps me out with my computer and can learn new things and create new functions based on what it has learned. I mean like the 'def' function, I wanted my program to be able to define new functions with the 'def' command, and the name of that definition is going to be the string. | |
| Mar 24, 2015 at 16:59 | answer | added | Luke | timeline score: 3 | |
| Mar 24, 2015 at 16:59 | comment | added | Eric Hughes | Simple answer: yes. Better answer: yes, but you probably don't actually want to. | |
| Mar 24, 2015 at 16:56 | comment | added | user1907906 | What are you really trying to do? | |
| Mar 24, 2015 at 16:56 | history | edited | user1907906 | CC BY-SA 3.0 |
added 20 characters in body
|
| Mar 24, 2015 at 16:55 | history | asked | jumbi533 | CC BY-SA 3.0 |