Re: [Tutor] Passing arguments?

2013-10-20 Thread Alan Gauld
On 20/10/13 05:20, Jenny Allar wrote: I've written the code below the assignment, and I think I have everything covered in terms of asking the user for the information I need and somehow calculating costs, but I'm just ridiculously confused on the order and placement of the functions and componen

Re: [Tutor] Passing arguments?

2013-10-20 Thread Jugurtha Hadjar
Hello, > the data from the user in main. You must print the name of the product, > the weight and the cost of shipping in a separate function. Your code printed that in main. > print('Product:', product) > > print('Weight:', weight) Also, you have an int(input("weight:")) Weight

Re: [Tutor] Passing arguments?

2013-10-20 Thread Dave Angel
On 20/10/2013 00:20, Jenny Allar wrote: Earlier, you have managed to send your emails as text, but this time you blew it and used html. That's probably what makes the code doublespaced in the newsgroup. It also means that most of us see > I've written the code below the assignment, and I think

Re: [Tutor] Passing arguments?

2013-10-20 Thread Mark Lawrence
On 20/10/2013 09:31, Dominik George wrote: Hi, Also, please reformat your code in a readable manner, i.e. remove the many empty lines, reformat function calls according to style guide, etc. Cheers, Nik Not another case of the infamous double spaced google disease? If yes it can be cured by

Re: [Tutor] Passing arguments?

2013-10-20 Thread Dominik George
Hi, > I've written the code below the assignment, and I think I have everything > covered in terms of asking the user for the information I need and somehow > calculating costs, but I'm just ridiculously confused on the order and > placement of the functions and components of this program- specifi

Re: [Tutor] Passing arguments to & running a python script on a remote machine from a python script on local machine .

2012-09-20 Thread Modulok
> I forgot you need to escape special characters in the arguments. You > can add quoting and escape special characters at the same time with > the undocumented function pipes.quote: > > import pipes > > args = tuple(pipes.quote(arg) for arg in (arg1, arg2, arg3)) > cmd = 'python test.py

Re: [Tutor] Passing arguments to & running a python script on a remote machine from a python script on local machine .

2012-09-20 Thread eryksun
On Thu, Sep 20, 2012 at 6:25 AM, eryksun wrote: > > I forgot you need to escape special characters in the arguments. You > can add quoting and escape special characters at the same time with > the undocumented function pipes.quote: > > import pipes > > args = tuple(pipes.quote(arg) for arg

Re: [Tutor] Passing arguments to & running a python script on a remote machine from a python script on local machine .

2012-09-20 Thread ashish makani
On Thu, Sep 20, 2012 at 3:43 AM, eryksun wrote: > On Wed, Sep 19, 2012 at 2:47 PM, ashish makani > wrote: > > > > I tried this > import os > os.system ("ssh remoteuser@remote python remote.py arg1 arg2 arg3") > > > > This worked, but if the arguments i tried to pass, had spaces, i was

Re: [Tutor] Passing arguments to & running a python script on a remote machine from a python script on local machine .

2012-09-20 Thread eryksun
On Wed, Sep 19, 2012 at 6:13 PM, eryksun wrote: > > cmd = 'python remote.py "%s" "%s" "%s"' % (arg1, arg2, arg3) > > try: > out = subprocess.check_output(['ssh', '%s@%s' % (user, hostname), > cmd]) I forgot you need to escape special characters in the arguments. You can add quoti

Re: [Tutor] Passing arguments to & running a python script on a remote machine from a python script on local machine .

2012-09-19 Thread eryksun
On Wed, Sep 19, 2012 at 2:47 PM, ashish makani wrote: > > I tried this import os os.system ("ssh remoteuser@remote python remote.py arg1 arg2 arg3") > > This worked, but if the arguments i tried to pass, had spaces, i was not > able to 'escape' the spaces. Presuming "remote" has an SSH

Re: [Tutor] Passing arguments to & running a python script on a remote machine from a python script on local machine .

2012-09-19 Thread Dave Angel
On 09/19/2012 03:45 PM, ashish makani wrote: > Thanks a ton for the prompt reply & the great suggestions, Dave. > Please don't top post. In this mailing list, the convention is to put your remarks after the part you're quoting (which usually isn't the entire message). That way, if the context g

Re: [Tutor] Passing arguments to & running a python script on a remote machine from a python script on local machine .

2012-09-19 Thread ashish makani
Thanks a ton for the prompt reply & the great suggestions, Dave. 1. A colleague gave this exact same suggestion os.system ('ssh remoteuser@remote python remote.py arg1 "arg 2 has spaces" arg3') I was thinking spaces is my problem, so i initially tested the following (no ssh) os.system('python r

Re: [Tutor] Passing arguments to & running a python script on a remote machine from a python script on local machine .

2012-09-19 Thread Dave Angel
On 09/19/2012 02:47 PM, ashish makani 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 st

Re: [Tutor] passing arguments to functions - problem with argument order

2008-03-11 Thread tetsuo2k6
Alan Gauld schrieb: > > Fine, but I would seriously consider learning dicts as a prioritry. > Certainly way higher that learning OOP. In fact being comfortable > with dictionaries will make understanding OOP much easier > since a class is really just a special type of dictionary!. > > Alan G. >

Re: [Tutor] passing arguments to functions - problem with argument order

2008-03-11 Thread Alan Gauld
<[EMAIL PROTECTED]> wrote >>> And I thought I might get away without using dicts... >> >> Why would you want to? Dicts are one of the most >> powerful data structures around. > Well, I know about dicts, however I want to go forward step by step > in > learning - once I feel really comfortable wi

Re: [Tutor] passing arguments to functions - problem with argument order

2008-03-11 Thread tetsuo2k6
Alan Gauld schrieb: > <[EMAIL PROTECTED]> wrote > >> And I thought I might get away without using dicts... > > Why would you want to? Dicts are one of the most > powerful data structures around. > > And besides Python is built from dicts so you can > never truly get away without using them. E

Re: [Tutor] passing arguments to functions - problem with argument order

2008-03-10 Thread Alan Gauld
<[EMAIL PROTECTED]> wrote > And I thought I might get away without using dicts... Why would you want to? Dicts are one of the most powerful data structures around. And besides Python is built from dicts so you can never truly get away without using them. Every time you access a feature from

Re: [Tutor] passing arguments to functions - problem with argument order

2008-03-10 Thread tetsuo2k6
That's it! Paul Andreas Kostyrka schrieb: > What you probably want is to pass: > > writer(None, "field1", "field2") > > Andreas > > Am Montag, den 10.03.2008, 16:28 +0100 schrieb [EMAIL PROTECTED]: >> And I thought I might get away without using dicts... >> >> Thanks, Greg >> >> >> >> Greg G

Re: [Tutor] passing arguments to functions - problem with argument order

2008-03-10 Thread Andreas Kostyrka
What you probably want is to pass: writer(None, "field1", "field2") Andreas Am Montag, den 10.03.2008, 16:28 +0100 schrieb [EMAIL PROTECTED]: > And I thought I might get away without using dicts... > > Thanks, Greg > > > > Greg Graham schrieb: > > Paul, > > > > Python does not allow mixing

Re: [Tutor] passing arguments to functions - problem with argument order

2008-03-10 Thread tetsuo2k6
And I thought I might get away without using dicts... Thanks, Greg Greg Graham schrieb: > Paul, > > Python does not allow mixing variable length arguments and keyword arguments > in that way. To accomplish what you want, you must add an argument preceded > by a "**" which will be a dict cont

Re: [Tutor] passing arguments to functions - problem with argument order

2008-03-10 Thread Greg Graham
Paul, Python does not allow mixing variable length arguments and keyword arguments in that way. To accomplish what you want, you must add an argument preceded by a "**" which will be a dict containing all of the keyword arguments as key, value pairs. You then have to retrieve the arguments from

Re: [Tutor] passing arguments via an instance of a class

2007-04-04 Thread Alan Gauld
"Che M" <[EMAIL PROTECTED]> wrote > > >def OnButton1Button(self, event): > > >self.weightplot = > > > PlotPanel(self.notebook1,xpoints,ypoints) > > > >But this needs to use self to access the member values: > > Doing it this way didn't work--it gave the error: > because, I think, self in

Re: [Tutor] passing arguments via an instance of a class

2007-04-04 Thread Che M
John Fouhy said: Can you post the full error message (including stack trace and line numbers) and the code for the last function in the stack trace? (i.e. the code where the NameError occurs) It is now working (so I won't post the code/errors unless you think it is useful for people to see),

Re: [Tutor] passing arguments via an instance of a class

2007-04-04 Thread Kent Johnson
Alan Gauld wrote: > "Kent Johnson" <[EMAIL PROTECTED]> wrote > #these are the points I want to be plotted when I push this button xpoints=[2,4,6] ypoints=[10,20,30] self.weightplot = PlotPanel(self.notebook1,xpoints,ypoints) >>> But this needs to use self t

Re: [Tutor] passing arguments via an instance of a class

2007-04-04 Thread Alan Gauld
"Kent Johnson" <[EMAIL PROTECTED]> wrote >>> #these are the points I want to be plotted when I push this button >>>xpoints=[2,4,6] >>>ypoints=[10,20,30] >>>self.weightplot = PlotPanel(self.notebook1,xpoints,ypoints) >> >> But this needs to use self to access the member val

Re: [Tutor] passing arguments via an instance of a class

2007-04-04 Thread Kent Johnson
Alan Gauld wrote: > #This is now the button which is supposed to feed the PlotPanel > #the points it needs. It is a method of the wxFrame (code not shown) >> def OnButton1Button(self, event): >> #these are the points I want to be plotted when I push this button >>xpoints=[2,4,6] >>

Re: [Tutor] passing arguments via an instance of a class

2007-04-04 Thread Alan Gauld
"Che M" <[EMAIL PROTECTED]> wrote > My problem is I don't understand how to create > the class such that it a) expects to be passed two lists, You've done that correctly by creating an init that takes xpoints and ypoints and storing those as members of self. > b) hands those lists off to its dr

Re: [Tutor] passing arguments via an instance of a class

2007-04-03 Thread John Fouhy
On 04/04/07, Che M <[EMAIL PROTECTED]> wrote: > As is, when I press that button I get this error: > > Name Error: global name xpoints is not defined. Can you post the full error message (including stack trace and line numbers) and the code for the last function in the stack trace? (i.e. the code

Re: [Tutor] passing arguments to a make a graph

2007-03-23 Thread Alan Gauld
"Che M" <[EMAIL PROTECTED]> wrote >>Instead of using the class create an instance(aka object) >>self.plotPanel = PlotPanel(mypoints,self.notebook1) > This worked great, thanks! One question: you mention that in this > way it > is passing in the mypoints list and also the notebook1. Wh

Re: [Tutor] passing arguments to a make a graph

2007-03-23 Thread Che M
>Instead of using the class create an instance(aka object) > >self.plotPanel = PlotPanel(mypoints,self.notebook1) > >That creates an instance passing the mypoints list in >to youir init method along with the notebook1 that you >pass when you create an instance later (see below). This wor

Re: [Tutor] passing arguments to a make a graph

2007-03-23 Thread Alan Gauld
"Che M" <[EMAIL PROTECTED]> wrote > Thank you, Alan. I started by adding a method called addPoints() > to my > class as you recommend. But now I don't know how to pass a list of > points > to the addPoints() method. You need to create an instance of a PlotPanel. > class PlotPanel(wx.lib.plo

Re: [Tutor] passing arguments to a make a graph

2007-03-23 Thread Che M
Thank you, Alan. I started by adding a method called addPoints() to my class as you recommend. But now I don't know how to pass a list of points to the addPoints() method. Here's the relevant code, adding in your suggestions: class PlotPanel(wx.lib.plot.PlotCanvas): def __init__(self,

Re: [Tutor] Passing Arguments

2005-07-09 Thread Alan G
> # Here I just created a couple of variables to print, and then > prt_Name returns g. >def prt_Name(): >g = 'foo' >print g >return g > > def get_Name(b): >print 'f' >print b > > get_Name(prt_Name) So you are passing a function object into your get_Name function. Is that what y

Re: [Tutor] Passing Arguments

2005-07-09 Thread Max Noel
On Jul 9, 2005, at 11:17, Don Parris wrote: get_Name(prt_Name) # Calling get_Name with prt_Name as the argument produces this: C:\Python24>python scripts\learning.py f At least it found the function. That's little shy of a miracle for me. :) However, I would like to see 'foo' printed out,