hey did you find the answer for this
--
https://mail.python.org/mailman/listinfo/python-list
On Wednesday, October 26, 2016 at 5:31:18 PM UTC-5, MRAB wrote:
> On 2016-10-26 21:44, pic8...@gmail.com wrote:
> > On Monday, October 24, 2016 at 12:39:47 PM UTC-5, Thomas Nyberg wrote:
> >> On 10/24/2016 12:45 PM, pic8...@gmail.com wrote:
> >> > Thanks for the reply.
> >> >
> >> > The code
On 2016-10-26 21:44, pic8...@gmail.com wrote:
On Monday, October 24, 2016 at 12:39:47 PM UTC-5, Thomas Nyberg wrote:
On 10/24/2016 12:45 PM, pic8...@gmail.com wrote:
> Thanks for the reply.
>
> The code snippet given by Peter is not very clear
>
> I would like to multiprocess a function which
On Monday, October 24, 2016 at 12:39:47 PM UTC-5, Thomas Nyberg wrote:
> On 10/24/2016 12:45 PM, pic8...@gmail.com wrote:
> > Thanks for the reply.
> >
> > The code snippet given by Peter is not very clear
> >
> > I would like to multiprocess a function which is written in python of the
> > form
On 10/24/2016 12:45 PM, pic8...@gmail.com wrote:
Thanks for the reply.
The code snippet given by Peter is not very clear
I would like to multiprocess a function which is written in python of the form
bar(**kwargs) which returns a value. This example does not return anything
Would you please
On Sunday, October 23, 2016 at 3:44:16 PM UTC-5, Thomas Nyberg wrote:
> On 10/23/2016 03:12 AM, pic8...@gmail.com wrote:
> > import multiprocessing as mp
> >
> > def bar(**kwargs):
> >for a in kwargs:
> > print a,kwargs[a]
> >
> > arguments={'name':'Joe','age':20}
> >
On 10/23/2016 03:12 AM, pic8...@gmail.com wrote:
import multiprocessing as mp
def bar(**kwargs):
for a in kwargs:
print a,kwargs[a]
arguments={'name':'Joe','age':20}
p=mp.Pool(processes=4)
p.map(bar,**arguments)
p.close()
p.join()
What are you trying to do? The map method is similar
import multiprocessing as mp
def bar(**kwargs):
for a in kwargs:
print a,kwargs[a]
arguments={'name':'Joe','age':20}
p=mp.Pool(processes=4)
p.map(bar,**arguments)
p.close()
p.join()
Errors:
Traceback (most recent call last):
File "post.py", line 9, in
p.map(bar,**arguments)
import multiprocessing as mp
def bar(**kwargs):
for a in kwargs:
print a,kwargs[a]
arguments={'name':'Joe','age':20}
p=mp.Pool(processes=4)
p.map(bar,**arguments)
p.close()
p.join()
Errors:
Traceback (most recent call last):
File "post.py", line 9, in
p.map(bar,**arguments)
Greetings,
I am trying to write a python script that, when called from the DOS prompt,
will call another python script and pass it input variables. My current code
will open the other python script but doesn't seem to pass it any values:
import os,sys,subprocess
On Tue, Apr 16, 2013 at 7:14 AM, PEnergy prqu...@gmail.com wrote:
Greetings,
I am trying to write a python script that, when called from the DOS prompt,
will call another python script and pass it input variables. My current code
will open the other python script but doesn't seem to pass
On Tue, 16 Apr 2013 12:10:09 -0700, Chris Rebert wrote:
On Tue, Apr 16, 2013 at 7:14 AM, PEnergy prqu...@gmail.com wrote:
Greetings,
I am trying to write a python script that, when called from the DOS
prompt, will call another python script and pass it input variables.
My current code will
On 04/16/2013 08:14 AM, PEnergy wrote:
Greetings,
I am trying to write a python script that, when called from the DOS
prompt, will call another python script and pass it input variables.
My current code will open the other python script but doesn't seem to
pass it any values:
import
Chris Rebert c...@rebertia.com wrote:
2. Glob/wildcard (*) expansion is done by the shell, but
subprocess.Popen does not use the shell by default (for good reason!).
This is only true in Linux. In Windows, the wildcard characters are passed
to the program, so each app must do its own glob
On Thursday, September 20, 2012 10:39:28 AM UTC+5:30, Chris Angelico wrote:
On Thu, Sep 20, 2012 at 2:27 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
On Wed, 19 Sep 2012 12:46:33 -0700, ashish wrote:
2. I have a python script, local.py, running on local which
On 9/19/2012 12:50 PM ashish said...
Hi c.l.p folks
Here is my situation
1. I have two machines. Lets call them 'local' 'remote'.
Both run ubuntu both have python installed
2. I have a python script, local.py, running on 'local' which needs to pass
arguments ( 3/4 string arguments,
On Wed, Sep 19, 2012 at 12:50 PM, ashish ashish.mak...@gmail.com wrote:
snip
2. I have a python script, local.py, running on 'local' which needs to pass
arguments ( 3/4 string arguments, containing whitespaces like spaces, etc )
to a python script, remote.py running on 'remote' (the remote
Ismael Farfán sulfur...@gmail.com writes:
How about something like this:
os.system ( 'ssh remoteuser@remote python remote.py arg 1 arg 2 arg 3' )
That won't work. You need an additional level of quoting because ssh is
also a shell so it adds another level of interpretation.
The following
Chris Rebert c...@rebertia.com writes:
Use the `subprocess` module instead (with shell=False). You then won't
need to worry about escaping.
http://docs.python.org/library/subprocess.html
You will still need to worry about escaping because on the remote end
you invoke ssh which is a shell. The
Hi PyTutor Folks
Here is my situation
1. I have two machines. Lets call them local remote.
Both run ubuntu both have python installed
2. I have a python script, local.py, running on local which needs to pass
arguments ( 3/4 string arguments, containing whitespaces like spaces, etc ) to
a
Hi c.l.p folks
Here is my situation
1. I have two machines. Lets call them 'local' 'remote'.
Both run ubuntu both have python installed
2. I have a python script, local.py, running on 'local' which needs to pass
arguments ( 3/4 string arguments, containing whitespaces like spaces, etc ) to
2012/9/19 ashish ashish.mak...@gmail.com:
Hi c.l.p folks
Here is my situation
1. I have two machines. Lets call them 'local' 'remote'.
Both run ubuntu both have python installed
2. I have a python script, local.py, running on 'local' which needs to pass
arguments ( 3/4 string
ashish ashish.mak...@gmail.com wrote:
Here is my situation
1. I have two machines. Lets call them 'local' 'remote'.
Both run ubuntu both have python installed
2. I have a python script, local.py, running on 'local' which needs to pass
arguments ( 3/4 string arguments, containing whitespaces
On Wed, 19 Sep 2012 12:46:33 -0700, ashish wrote:
Hi PyTutor Folks
Here is my situation
1. I have two machines. Lets call them local remote. Both run ubuntu
both have python installed
2. I have a python script, local.py, running on local which needs to
pass arguments ( 3/4 string
On Thu, Sep 20, 2012 at 2:27 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
On Wed, 19 Sep 2012 12:46:33 -0700, ashish wrote:
2. I have a python script, local.py, running on local which needs to
pass arguments ( 3/4 string arguments, containing whitespaces like
spaces, etc )
Hi,
I am trying to figure out how to implement a QThread class that
will handle GUI event while keeping the GUI responsive.
I want to call thread's methods by their names and start() the
thread from inside that method.
My problem is with passing methods their arguments since
start() wont take
HI all,
i have two python programs as 1.py and 2.py
1.py
import os
import sys
processID=os.spawnl(os.P_WAIT,'/usr/local/bin/python','python','/
mywork/2.py ' + 'hi')
2.py
import sys
domain= str(sys.argv[1] )
print domain
IN LINUX
while executing 1.py,the argument 'hi' is not passed to the 2.py
gaurav kashyap wrote:
HI all,
i have two python programs as 1.py and 2.py
1.py
import os
import sys
processID=os.spawnl(os.P_WAIT,'/usr/local/bin/python','python','/
mywork/2.py ' + 'hi')
2.py
import sys
domain= str(sys.argv[1] )
print domain
IN LINUX
while executing 1.py,the
Thanks for the help Peter.Its working fine now
--
http://mail.python.org/mailman/listinfo/python-list
i want to execute a python script using exec open('script.py'). how do
I pass arguments?
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 25 Aug 2008 06:31:53 -0700 (PDT), Alexandru Mosoi wrote:
i want to execute a python script using exec open('script.py'). how do
I pass arguments?
Take a look at subprocess module. It comes with a set of examples.
--
Regards,
Wojtek Walczak,
http://tosh.pl/gminick/
--
But if you couldn't find readily available confirmation of what you presumed
to be true, weren't the responses showing how you might come that answer
using the interpreter helpful, rather than harsh?
The Python interpreter is the shizzit.
On Mon, Jun 23, 2008 at 12:17 PM, John Dann [EMAIL
May I ask a simple newbie question, which I presume is true, but for
which I can't readily find confirmation:
Let's say I have a parent class with an __init__ method explicitly
defined:
class ParentClass(object):
def __init__(self, keyword1, keyword2):
etc
and I subclass
John Dann a écrit :
May I ask a simple newbie question, which I presume is true, but for
which I can't readily find confirmation:
Let's say I have a parent class with an __init__ method explicitly
defined:
class ParentClass(object):
def __init__(self, keyword1, keyword2):
John Dann wrote:
May I ask a simple newbie question, which I presume is true, but for
which I can't readily find confirmation:
Let's say I have a parent class with an __init__ method explicitly
defined:
class ParentClass(object):
def __init__(self, keyword1, keyword2):
Thanks for the responses - they're much appreciated. And I understand
the slight impatience with questions that could possibly be answered
without recourse to a forum - I'm usually in the opposite position of
fielding many newbie questions in a forum in a completely different
field!
But don't be
John Dann wrote:
... the answer might have been of the 'yes, but' kind.
Well, if you really care, there is a 'yes, but' answer, but it
only has to do with multiple inheritance, and hence is a bit
esoteric for the issues you are currently addressing.
This is not meant to be a tease; I think it
On Dec 15, 6:46 pm, Dennis Lee Bieber [EMAIL PROTECTED] wrote:
On Fri, 14 Dec 2007 16:38:28 -0800 (PST), [EMAIL PROTECTED] declaimed
the following in comp.lang.python:
The executable runs, but no argument appears to get passed into it. Of
course, I don't really know that for sure as the
On Dec 14, 8:06 pm, John Machin [EMAIL PROTECTED] wrote:
snipped
The executable runs,
how do you know it runs?
because the program's GUI appears on-screen.
but no argument appears to get passed into it.
appears??
Since the TO field doesn't get populated with the email address, it
I have created what amounts to a simple GUI email sending program
using Python + wxPython. I have modified the mailto registration in
the Windows Registry so that it launches the script when someone
clicks on someone's email link in a web page.
While this works great if I create a convoluted path
On Dec 15, 9:01 am, [EMAIL PROTECTED] wrote:
I have created what amounts to a simple GUI email sending program
using Python + wxPython. I have modified the mailto registration in
the Windows Registry so that it launches the script when someone
clicks on someone's email link in a web page.
On Dec 14, 4:51 pm, John Machin [EMAIL PROTECTED] wrote:
On Dec 15, 9:01 am, [EMAIL PROTECTED] wrote:
I have created what amounts to a simple GUI email sending program
using Python + wxPython. I have modified the mailto registration in
the Windows Registry so that it launches the script
On Dec 15, 11:38 am, [EMAIL PROTECTED] wrote:
On Dec 14, 4:51 pm, John Machin [EMAIL PROTECTED] wrote:
On Dec 15, 9:01 am, [EMAIL PROTECTED] wrote:
I have created what amounts to a simple GUI email sending program
using Python + wxPython. I have modified the mailto registration in
Hi,
Is there a way to pass arguments to TestCases when running tests? I have
a test suite that need to be configured slightly differently for 3
different products, and rather than do a hack I wondered if there was a
canonical way to do it.
I _know_ that py.test can do it trivially. I am
Tom Harris schrieb:
Hi,
Is there a way to pass arguments to TestCases when running tests? I have
a test suite that need to be configured slightly differently for 3
different products, and rather than do a hack I wondered if there was a
canonical way to do it.
I _know_ that py.test can
that was the problem. when i manually reassociated the extension, i somehow
didnt quote the argument for the filename. my bad.
thanks for the various explanations and options for this :)
cheers.
2007/8/20, Gabriel Genellina [EMAIL PROTECTED]:
En Sat, 18 Aug 2007 09:24:35 -0300, SHY [EMAIL
En Sat, 18 Aug 2007 09:24:35 -0300, SHY [EMAIL PROTECTED] escribi�:
theres no special portion of code, just the one that handles filenames
with
spaces.
the problem is that when i associate a file extension to my application
and
i open it, the filename is not quoted before passed as an
Sorry for ignoring the thread.
the problem is that when i associate a file extension to my application and
i open it, the filename is not quoted before passed as an arguement. i dont
If it is not quoted by default, you can quote it explicit. If this be the case
where the filename is obtained
hey,
i have a win32 gui application that accepts filenames as arguments (either
via command line or via associating an extension to the application) which
are then opened in it. the problem is that as soon as the filename contains
characters like '', the process fails at the very beginning
Quote:D:\ftp\Music\Mixes Compilations\Above Beyond - Essential
Mix\001_Essential_Mix_2004-06-06_-_Above_and_Beyond.txt
when i put 'print sys.argv[1:]' at the very beginning of the script, all i
get is this:
Quote:['D:\\ftp\\Music\\Mixes']
Can you share the portion of the code?
Are you
O.R.Senthil Kumaran wrote:
Quote:D:\ftp\Music\Mixes Compilations\Above Beyond - Essential
Mix\001_Essential_Mix_2004-06-06_-_Above_and_Beyond.txt
when i put 'print sys.argv[1:]' at the very beginning of the script, all i
get is this:
Quote:['D:\\ftp\\Music\\Mixes']
Can you share the
theres no special portion of code, just the one that handles filenames with
spaces.
the problem is that when i associate a file extension to my application and
i open it, the filename is not quoted before passed as an arguement. i dont
know if its the problem of windows or something, or it was
Great -- thanks! (and also to J. Ezequiel).
Mark T wrote:
Eric Spaulding [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Is there an easy way to pass arguments to a handler class that is used by
the standard TCPServer?
normally -- srvr =SocketServer.TCPServer(('',port_num),
Is there an easy way to pass arguments to a handler class that is used
by the standard TCPServer?
normally -- srvr =SocketServer.TCPServer(('',port_num), TCPHandlerClass)
I'd like to be able to: srvr =SocketServer.TCPServer(('',port_num),
TCPHandlerClass, (arg1,arg2))
And have arg1, arg2
On Jun 13, 10:19 pm, Eric Spaulding [EMAIL PROTECTED] wrote:
Is there an easy way to pass arguments to a handler class that is used
by the standard TCPServer?
normally -- srvr =SocketServer.TCPServer(('',port_num), TCPHandlerClass)
I'd like to be able to: srvr
Eric Spaulding [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Is there an easy way to pass arguments to a handler class that is used by
the standard TCPServer?
normally -- srvr =SocketServer.TCPServer(('',port_num), TCPHandlerClass)
I'd like to be able to: srvr
Please forgive me if what I'm asking is non sense...
I created a little program to authomate the creation of the setup.py
script for py2exe.
It simply prompts for the main executable script name and then creates
setup.py, as follows:
# this is makesetup.py
nombre = raw_input('File name?: ')
f
En Mon, 19 Mar 2007 20:46:56 -0300, Luis M. González [EMAIL PROTECTED]
escribió:
What I want now is execute the script I just created.
As far as I know, the only way to execute the script is from a command
line and typing setup.py py2exe.
A few ways:
- os.system(commandline). Simplest way,
Genellina
I'm sorry, but still I can't figure out this...
Would you please show me a sample usage of os.system or os.popen for
passing arguments to the command line?
In this case, I should pass to the command line setuppy py2exe.
Thanks!
Luis
--
http://mail.python.org/mailman/listinfo/python
module - the most complete way, but simple enough for
most cases.
--
Gabriel Genellina
I'm sorry, but still I can't figure out this...
Would you please show me a sample usage of os.system or os.popen for
passing arguments to the command line?
In this case, I should pass to the command line
.
- os.popen[234]? or the functions in the popen2 module
- the subprocess module - the most complete way, but simple enough for
most cases.
--
Gabriel Genellina
I'm sorry, but still I can't figure out this...
Would you please show me a sample usage of os.system or os.popen for
passing
Luis M. González wrote:
On Mar 19, 10:49 pm, zacherates [EMAIL PROTECTED] wrote:
This implies that `os.system(setuppy py2exe)` should do what you
want.
It works!
Thank you, this is just what I wanted.
You'll get better error checking if instead you do::
import subprocess
On Mar 19, 11:52 pm, Steven Bethard [EMAIL PROTECTED] wrote:
Luis M. González wrote:
On Mar 19, 10:49 pm, zacherates [EMAIL PROTECTED] wrote:
This implies that `os.system(setuppy py2exe)` should do what you
want.
It works!
Thank you, this is just what I wanted.
You'll get better
New to Python ... this should be an easy question to answer.
INPUT
import sys
print 'The command line arguments are:'
for i in sys.argv:
print i
print '\nThe PYTHONPATH is', sys.path
OUTPUT
The command line arguments are:
C:\Python25\using_sys.py
The PYTHONPATH is
It works fine when I 'Run Module'...but when I type in interactive mode
in the Python Shell
python using_sys.py test1 test2 test3
I get the following error:
SyntaxError: invalid syntax
By using proper syntax... :*)
To pass parameters, you do it when *starting* python[*]. Thus,
you'd
Problem solved. use 'command = Calc' to call my Calc function but ignore
the argument passed to it. Create a list with the following elements -
a.get(), b.get() and c.get(). Every time a scale slider is moved, Calc
will retrieve the current scale values and I can do with them whatever I
On Sun, 21 Aug 2005 08:09:55 +0100, m7b52000 oh_no_you_don'[EMAIL PROTECTED]
wrote:
It is proving most difficult in Python. How do I pass the .get() values
to my calculating function? Do I use the command option for each slider?
e.g command = Calc(a.get()). Obviously not cos it doesn't
Matt Hammond wrote:
On Sun, 21 Aug 2005 08:09:55 +0100, m7b52000
oh_no_you_don'[EMAIL PROTECTED] wrote:
It is proving most difficult in Python. How do I pass the .get()
values to my calculating function? Do I use the command option for
each slider? e.g command = Calc(a.get()).
On Mon, 22 Aug 2005 12:16:01 +0100, m7b52000 [EMAIL PROTECTED]
wrote:
command = lambda : Calc(a.get())
I get the following message when I use lambda as above:
TypeError: lambda() takes no arguments (1 given)
Oops, forgot! The Scale widget outputs a single argument - the value of
the
Matt Hammond wrote:
On Mon, 22 Aug 2005 12:16:01 +0100, m7b52000 [EMAIL PROTECTED]
wrote:
command = lambda : Calc(a.get())
I get the following message when I use lambda as above:
TypeError: lambda() takes no arguments (1 given)
Oops, forgot! The Scale widget outputs a single
A. Partial success with : command = Calc. A slider will now pass its
argument to a function without problem. My Calc function however is
expecting 3 arguments - 1 from each slider i.e moving any of the 3
sliders should cause a recalculation. I am now getting the following
error:
Matt Hammond wrote:
A. Partial success with : command = Calc. A slider will now pass
its argument to a function without problem. My Calc function however
is expecting 3 arguments - 1 from each slider i.e moving any of the
3 sliders should cause a recalculation. I am now getting the
Some time ago I wrote a little program in Tcl/Tk that took the values
from 3 sliders and performed a calculation using these values. The
calculation was of course automatically repeated each time a slider was
moved.
It is proving most difficult in Python. How do I pass the .get() values
to my
Hey guys, would someone mind giving me a quick rundown of how
references work in Python when passing arguments into functions? The
code below should highlight my specific confusion:
code
bool1=True
lst1=[1,2,3]
def func1(arg1): arg1.append(4)
def func2(arg1): arg1=False
func1(lst1)
lst1
Gregory Piñero wrote:
Hey guys, would someone mind giving me a quick rundown of how
references work in Python when passing arguments into functions? The
code below should highlight my specific confusion:
All arguments are passed by reference, but in Python equality rebinds
the name.
code
Christopher Subich wrote:
Gregory Piñero wrote:
Hey guys, would someone mind giving me a quick rundown of how
references work in Python when passing arguments into functions? The
code below should highlight my specific confusion:
This URL is always tossed out:
http://starship.python.net
in Python equality rebinds the name
Assignment (=) rebinds the name. Equality (==) is something else
entirely.
--
http://mail.python.org/mailman/listinfo/python-list
Does that mean Python functions aren't always byref,
but are sometimes byval for nonmutables?
Don't think of it as byref or byval (as they are used in Visual Basic).
All parameters are passed the same way: by reference instead of by copy.
It's a little difficult to get your head around, but I
Gregory Piñero wrote:
Ahh, so it's a mutable thing. That makes sense that I can't change a
mutable object and thus can't affect it outside of the function.
If you meant immutable for the second mutable, you're right.
Does
that mean Python functions aren't always byref, but are sometimes
Dennis Lee Bieber wrote:
In a more simplistic view, I'd reverse the phrasing... The name
x is assigned to the object y (implying it is no longer attached to
whatever used to have the name)
No, because that'd imply that the object 'y' somehow keeps track of the
names assigned to it,
Dennis Lee Bieber wrote:
On Tue, 09 Aug 2005 10:39:29 -0500, Rocco Moretti
[EMAIL PROTECTED] declaimed the following in comp.lang.python:
Change it to the object referenced by y is assigned to the name of x,
and you're closer to the truth.
In a more simplistic view, I'd reverse the
Christopher Subich wrote:
Rocco Moretti wrote:
Variables in Python are names. They aren't the cubbyholes into which
you put values, they are sticky notes on the front of the cubby hole.
+1 MOTW (Metaphor of the Week)
Thanks, but please note it's not really mine - I've seen it somewhere
Gregory Piñero [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
how references work in Python
'references' are an implementation detail and a metaconcept used to talk
about Python but are not part of the language spec itself.
when passing arguments into functions?
Python does
Christopher Subich [EMAIL PROTECTED] wrote in
message news:[EMAIL PROTECTED]
Dennis Lee Bieber wrote:
In a more simplistic view, I'd reverse the phrasing... The name
x is assigned to the object y (implying it is no longer attached to
whatever used to have the name)
I agree that this is the
Gregory Piñero [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Ahh, so it's a mutable thing. That makes sense that I can't change a
mutable object and thus can't affect it outside of the function.
You of course meant immutable, but this is still confused. It is a
name-binding
Hello,
I got a newbie question, I have written the following distance function:
def distance(self,element1, element2):
dist = 0
for n in range(len(element1)):
dist = dist + pow((element1[n] - element2[n]),2)
print 'dist' + dist
return sqrt(dist)
and
(You posted your question as a followup to oen of Xah Lee's musings.
That is not the best of ideas, since people with threaded newsreaders
tend not to see it. Just post (creating a new thread) next time.)
On Sun, 10 Jul 2005 11:19:31 +0100 (BST), Philipp H. Mohr [EMAIL PROTECTED]
wrote:
Hello,
Philipp H. Mohr [EMAIL PROTECTED] wrote:
Hello,
I got a newbie question, I have written the following distance function:
def distance(self,element1, element2):
dist = 0
for n in range(len(element1)):
dist = dist + pow((element1[n] - element2[n]),2)
On Sun, 10 Jul 2005 11:19:31 +0100, Philipp H. Mohr wrote:
Hello,
I got a newbie question, I have written the following distance function:
Great. Now, how about you tell us what you expect it to do? I assume
it calculates the Euclidean distance between two points. (If you
don't know what
Is getCenter a function? If so, you need to invoke distance using:
dist = self.distance( n.getCenter(), newElement )
Of course, that is assuming that newElement is a local variable of type
list/tuple/etc.
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
thank you very much for all your help. I have solved the problem - you
guys where right, the problem was some where else.
I have another class which got an accessor:
def getCenter(self):
global center
return center
and I called it by saying n.getCenter, but this
Hi,
look at sys.argv
Regards,
Philippe
Jeff Elkins wrote:
I'm sure this is obvious, but how the heck do pass an argument(s) to a
python script from the command line?
Thanks,
Jeff Elkins
--
http://mail.python.org/mailman/listinfo/python-list
Steven Bethard wrote:
James Stroud wrote:
import sys
try:
arg1 = sys.argv[1]
except IndexError:
print This script takes an argument, you boob!
sys.exit(1)
Also possible, to guarantee that exactly one argument was given:
try:
arg1, = sys.argv
except ValueError:
print This
Dennis Lee Bieber wrote:
On Sun, 22 May 2005 16:12:06 -0400, Steve Holden [EMAIL PROTECTED]
declaimed the following in comp.lang.python:
Aren't we forgetting argv[0] here, or am I overlooking something (like,
you chopped it off without telling me?)?
argv[0] is often just the
Steve Holden wrote:
Steven Bethard wrote:
Also possible, to guarantee that exactly one argument was given:
try:
arg1, = sys.argv
except ValueError:
print This script takes an argument, you boob!
sys.exit(1)
Aren't we forgetting argv[0] here
Oops. Yup. Change all sys.argv to
import sys
try:
arg1 = sys.argv[1]
except IndexError:
print This script takes an argument, you boob!
sys.exit(1)
OR, way better: See the optparse module.
On Friday 20 May 2005 03:26 pm, Jeff Elkins wrote:
I'm sure this is obvious, but how the heck do pass an argument(s) to a
python
On Friday 20 May 2005 06:46 pm, James Stroud wrote:
import sys
try:
arg1 = sys.argv[1]
except IndexError:
print This script takes an argument, you boob!
sys.exit(1)
OR, way better: See the optparse module.
On Friday 20 May 2005 03:26 pm, Jeff Elkins wrote:
I'm sure this is
An even better way would be to use the optparse module.-- Daniel Bickettdbickett at gmail.comhttp://heureusement.org/
--
http://mail.python.org/mailman/listinfo/python-list
James Stroud wrote:
import sys
try:
arg1 = sys.argv[1]
except IndexError:
print This script takes an argument, you boob!
sys.exit(1)
Also possible, to guarantee that exactly one argument was given:
try:
arg1, = sys.argv
except ValueError:
print This script takes an argument,
Casey Bralla [EMAIL PROTECTED] writes:
I've got a python cgi-bin application which produces an apache web page. I
want to pass arguments to it on the URL line, but the parameters are not
getting passed along to python properly.
I've been using sys.argv to pick up command line arguments, and
1 - 100 of 103 matches
Mail list logo