473,659 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

python hello.py hello_msg("Hell o no", 3)??? Help, please!

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("Hell o 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("Hel lo no ", 3)

Carl
Jul 18 '05 #1
4 1339
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("Hell o 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("Hel lo no ", 3)


Use the -c option.

python -c "import modulename; modulename.hell o_msg('test', 5)"

Jul 18 '05 #2
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("Hell o 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("Hel lo no ", 3)


Use the -c option.

python -c "import modulename; modulename.hell o_msg('test', 5)"


Thanks, that was incredibly simple!

Carl

Jul 18 '05 #3
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("Hell o 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("Hel lo no ", 3)


Use the -c option.

python -c "import modulename; modulename.hell o_msg('test', 5)"


Or, from the command prompt, 'import modulename'

Jul 18 '05 #4
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("Hell o 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.hell o_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
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3487
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, because the dates must have quotes on each side. I just don't know how make the dates right. Well I'll just show you the code and some insert statements it generates. Could anyone please help me?
14
2142
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 Frame (File LeftEx8_2.html) a series of buttons, which when clicked prompt the user to enter information for background color, text color, link color, title and some text.
23
3260
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 to create certain textboxes, labels, and combo boxes? Any ideas would be appreciated. Thanks
1
3436
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. Before: ----------
5
2055
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 decided to re-write the software and replace the Acorn with a p.c. with new software The BBC is used for displaying callers to the host of a show. But I am difficulty figuring out how the company wrote a bit of the software.
0
1087
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 and not? I get really confused here. Please check my code and give me some idea or clue or help please :). Thanks in advance. My code is like this: Dim DBConnection As SqlConnection Dim WithEvents SPConnection As SerialPort = New...
0
1989
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 arbitrary number of topics, but always at least one.) this structure is repeated for other relationships such as doc_states, doc_types, et cetera. i want a query that uses one or more of the relationships as search criteria (example, return only...
6
3518
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 (empty) the form on (release) { _parent.getURL("contact.php","_blank", "GET"); _parent.name=""; _parent.phone="";
3
4837
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 Job_No, IFNULL((SELECT sum(Paying_Rate*Working_Hrs) FROM Labour WHERE Job_No = Job.Job_No),0) AS Labsubtotal,
0
1959
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 circular linked list works like this: (the number on the left represents the number of lists) o - (Header is empty class) 1 - header.next = first element (call this EL1) EL1.next = EL1
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8751
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8539
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4342
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.