Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > python hello.py hello_msg("Hello no", 3)??? Help, please!

Reply
Thread Tools

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

 
 
Carl
Guest
Posts: n/a
 
      05-20-2004
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
 
Reply With Quote
 
 
 
 
Peter Hansen
Guest
Posts: n/a
 
      05-20-2004
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)"

 
Reply With Quote
 
 
 
 
Carl
Guest
Posts: n/a
 
      05-20-2004
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

 
Reply With Quote
 
Chris
Guest
Posts: n/a
 
      05-21-2004
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'

 
Reply With Quote
 
Peter Hansen
Guest
Posts: n/a
 
      05-21-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 R. David Murray Python 0 01-17-2011 02:23 PM
Re: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 Senthil Kumaran Python 0 01-17-2011 10:31 AM
Re: [Python-Dev] [Python-3000] RELEASED Python 2.6a1 and 3.0a3 Martin v. L÷wis Python 0 03-01-2008 10:51 PM
Re: [Python-Dev] [Python-3000] RELEASED Python 2.6a1 and 3.0a3 Paul Moore Python 0 03-01-2008 10:39 PM
Searching comp.lang.python/python-list@python.org (was: UTF-8) skip@pobox.com Python 0 03-10-2007 02:50 PM



Advertisments