I have a rather odd question:
Is there a way Python can execute a command within a string ?
For example if I had something like:
_str = "fm=OptionMenu(root,xx,'string1','string2','string 3')"
And the execute _str.
The reason why I am trying to do this that as I am aware the OptionMenu
hasn't the ability insert options therefore the options would be inserted
by manipulating strings.
Pete 6 1553
Peter Moscatt wrote: I have a rather odd question:
Is there a way Python can execute a command within a string ?
For example if I had something like: _str = "fm=OptionMenu(root,xx,'string1','string2','string 3')"
And the execute _str.
exec _str
The reason why I am trying to do this that as I am aware the OptionMenu hasn't the ability insert options therefore the options would be inserted by manipulating strings.
does this do what you want?
strings = "string1", "string2", "string3"
fm = OptionMenu(root, xx, *strings)
</F>
Peter Moscatt wrote: I have a rather odd question:
Is there a way Python can execute a command within a string ?
For example if I had something like: _str = "fm=OptionMenu(root,xx,'string1','string2','string 3')"
And the execute _str.
The reason why I am trying to do this that as I am aware the OptionMenu hasn't the ability insert options therefore the options would be inserted by manipulating strings.
Pete
Look into the "eval" operation ...
--
----------------------------------------------------------------------------
Tim Daneliuk tu****@tundraware.com
PGP Key: http://www.tundraware.com/PGP/
</F>,
Thanks for the help on this. Yea the 'exec' did the trick.
The second example just placed all the strings in one option button.
Pete
On Wed, 13 Apr 2005 10:34:20 +0200, Fredrik Lundh wrote: Peter Moscatt wrote:
I have a rather odd question:
Is there a way Python can execute a command within a string ?
For example if I had something like: _str = "fm=OptionMenu(root,xx,'string1','string2','string 3')"
And the execute _str.
exec _str
The reason why I am trying to do this that as I am aware the OptionMenu hasn't the ability insert options therefore the options would be inserted by manipulating strings.
does this do what you want?
strings = "string1", "string2", "string3" fm = OptionMenu(root, xx, *strings)
</F>
Peter Moscatt wrote: Thanks for the help on this.**Yea*the*'exec'*did*the*trick. The second example just placed all the strings in one option button.
Peter, you most certainly do *not* need an exec statement. If you take the
time to explain what you want to do (as opposed to how you want to do it) a
bit more exhaustively, perhaps with some context code, the profit will be
all on your side.
Peter
Peter Moscatt wrote: strings = "string1", "string2", "string3" fm = OptionMenu(root, xx, *strings)
Thanks for the help on this. Yea the 'exec' did the trick. The second example just placed all the strings in one option button.
did you include the asterisk? if you remove that, you get one option. if you
include it, you get three options.
</F>
</F>,
No, I hadn't included the '*' Ya learn something every day.
Pete
On Wed, 13 Apr 2005 11:07:13 +0200, Fredrik Lundh wrote: Peter Moscatt wrote:
strings = "string1", "string2", "string3" fm = OptionMenu(root, xx, *strings)
Thanks for the help on this. Yea the 'exec' did the trick. The second example just placed all the strings in one option button.
did you include the asterisk? if you remove that, you get one option. if you include it, you get three options.
</F> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bernd Danberg |
last post by:
Hi,
I have a real strange problem with the command line arguments given to the
main-function and together with using std::string:
#include <string>
int _tmain(int argc, _TCHAR* argv)
{...
|
by: lkrubner |
last post by:
I'd like to write a PHP script to be used from the command line on a
Unix machine. I'd like for the script to put together a string, turn it
into a web page, print it, then return control the...
|
by: jlea |
last post by:
I'm trying to pass a filename, obtained with using the fileName property
from the OpenFileDialog, as a application parameter in
Process.StartInfo.Arguments and run a MFC/C++ application using the...
|
by: paul |
last post by:
I have a file type that is going to be associated with my
visual basic application and i want the user to be able
to double click on a file of said type and have it launch
the program and load the...
|
by: John Wildes |
last post by:
Hello All,
I've got a VB.net windows form app that I have created to solve some
recurring maintenance tasks. What I would like to do is build
functionality into this application so that accepts...
|
by: micahstrasser |
last post by:
I have been trying for days to send a command to the command prompt
through the shell() function in vb.net. For some reason it is not
working. Here is the code:
Private Sub Button1_Click(ByVal...
|
by: jimmy |
last post by:
Hi again,
sorry for posting two questions so close together but im working on a
school project which is due in soon and running into some difficulties
implementing the database parts. I have the...
|
by: czerwww |
last post by:
Can someone please help me? I have class for database connection and I need set command.commandTimeout. How can I do that?
Code:
Imports System.Data.SqlClient
Imports System.Data
Public Class...
|
by: creative1 |
last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
| |