This is perhaps a very simple and stupid question!
How do you run a specific function (with actual values for the parameters)
within a module from the command prompt? That is, with "python ..."
For instance, how do I run hello_msg("Hello no ", 3), which is a function
within the module hello.py, from the console?
def hello_msg(msg, num):
print msg + str(num ** 3) +'!'
#hello_msg("Hello no ", 3)
Carl 4 1323
Carl wrote: This is perhaps a very simple and stupid question!
How do you run a specific function (with actual values for the parameters) within a module from the command prompt? That is, with "python ..."
For instance, how do I run hello_msg("Hello no ", 3), which is a function within the module hello.py, from the console?
def hello_msg(msg, num): print msg + str(num ** 3) +'!' #hello_msg("Hello no ", 3)
Use the -c option.
python -c "import modulename; modulename.hello_msg('test', 5)"
Peter Hansen wrote: Carl wrote:
This is perhaps a very simple and stupid question!
How do you run a specific function (with actual values for the parameters) within a module from the command prompt? That is, with "python ..."
For instance, how do I run hello_msg("Hello no ", 3), which is a function within the module hello.py, from the console?
def hello_msg(msg, num): print msg + str(num ** 3) +'!' #hello_msg("Hello no ", 3)
Use the -c option.
python -c "import modulename; modulename.hello_msg('test', 5)"
Thanks, that was incredibly simple!
Carl
Peter Hansen wrote: Carl wrote:
This is perhaps a very simple and stupid question!
How do you run a specific function (with actual values for the parameters) within a module from the command prompt? That is, with "python ..."
For instance, how do I run hello_msg("Hello no ", 3), which is a function within the module hello.py, from the console?
def hello_msg(msg, num): print msg + str(num ** 3) +'!' #hello_msg("Hello no ", 3)
Use the -c option.
python -c "import modulename; modulename.hello_msg('test', 5)"
Or, from the command prompt, 'import modulename'
Chris wrote: Peter Hansen wrote:
Carl wrote:
This is perhaps a very simple and stupid question!
How do you run a specific function (with actual values for the parameters) within a module from the command prompt? That is, with "python ..."
For instance, how do I run hello_msg("Hello no ", 3), which is a function within the module hello.py, from the console?
def hello_msg(msg, num): print msg + str(num ** 3) +'!' #hello_msg("Hello no ", 3)
Use the -c option.
python -c "import modulename; modulename.hello_msg('test', 5)"
Or, from the command prompt, 'import modulename'
??
My example _was_ from the command prompt, and your approach
doesn't execute hello_msg() as the OP requested.
-Peter This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: duikboot |
last post by:
Hi all,
I'm trying to export a view tables from a Oracle database to a Mysql
database. I create insert statements (they look alright), but it all goes
wrong when I try to execute them in Mysql,...
|
by: TrvlOrm |
last post by:
OK. After much playing around, I managed to get my frame page this
far.. see code below.
BUT...there are still errors with it, and what I would like to have
happened is this:
1) On the Left...
|
by: Jason |
last post by:
Hi,
I was wondering if any could point me to an example or give me ideas on how
to dynamically create a form based on a database table? So, I would have a
table designed to tell my application...
|
by: Chua Wen Ching |
last post by:
Hi there,
I have some problems when reading XML file.
1. First this, is what i did, cause i can't seem to read "sub elements or
tags" values, so i place those values into attributes like this....
|
by: ukjock |
last post by:
Hi guys and Gals I need some serious help please. I can not get my
head around this problem.
At work we have a BBC Acorn computer (yep, I know what yer thinking),
and for the past month I have...
|
by: Lemune |
last post by:
Hello everyone. I'm creating windows service application to capture
data from my PABX, and send the data to sql server. My question is how
could my application know when that PABX is sending data...
|
by: plaidthermos |
last post by:
hello,
i have a database where there is a main table, documents, and then a
relationship table doc_topics with one entry for each topic into which
a document falls. (any document may have an...
|
by: Derek |
last post by:
Hi all any one please help, i have a buttin in flash 8 which gets a form contact.php but when it is pressed the emial ruturns empty as follows
1 the flash button
2 the form
3 the email outcome...
|
by: swanside |
last post by:
Hello all.
I am in the need of some help please.
I have an SQL statement that works on a MySQL Database, but I need to get it to work on an Access Database.
The statement is,
SELECT...
|
by: Joseph Guildino |
last post by:
Good afternoon all!
I have this program in Python that is really starting to make my head go crazy. It utilizes linked lists (circularly linked list).
Now, correct me if I am wrong, but a...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
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: 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: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| | |