Re: [Tutor] Beginner Question

2013-10-22 Thread Steven D'Aprano
On Tue, Oct 22, 2013 at 04:25:59PM +0200, Sven Hennig wrote: > Hello, I would like to learn a programming language and have decided to use > Python. I have some programming experience and doing well in Python. What > really causes me problems is OOP. > I'm just dont get it... I'm missing a really

Re: [Tutor] comma in an assignment

2013-10-22 Thread eryksun
On Tue, Oct 22, 2013 at 9:50 PM, Steven D'Aprano wrote: > However, there does have to be the same number of items on both sides: > > py> a, b, c = "xy" > Traceback (most recent call last): > File "", line 1, in > ValueError: need more than 2 values to unpack 3.x extends sequence unpacking to s

Re: [Tutor] How to Terminate a Popen call?

2013-10-22 Thread eryksun
On Tue, Oct 22, 2013 at 9:04 PM, SM wrote: > def run(self): > (process, err) = Popen(self.fwcmd, stdout=PIPE, > stderr=PIPE).communicate() > if len(err) > 0: > # print("Error") > # Error handling code > else: > # print("S

Re: [Tutor] comma in an assignment

2013-10-22 Thread Steven D'Aprano
On Tue, Oct 22, 2013 at 07:20:25PM +, Key, Gregory E (E S SF RNA FSF 1 C) wrote: > I understand that a comma in Python is a separator and not an > operator. In some of the MatPlotLib examples I see code like this: > > line1, = ax1.plot(t, y1, lw=2, color='red', label='1 HZ') > > What does

Re: [Tutor] comma in an assignment

2013-10-22 Thread eryksun
On Tue, Oct 22, 2013 at 3:20 PM, Key, Gregory E (E S SF RNA FSF 1 C) wrote: > I understand that a comma in Python is a separator and not an operator. In The comma operator creates a tuple. It has low precedence, so you usually need parentheses. But sometimes the parentheses are redundant such as

[Tutor] How to Terminate a Popen call?

2013-10-22 Thread SM
Hello! I am trying to terminate a Popen session using Popen.terminate() ( using the info at http://docs.python.org/library/subprocess.html and some relevant answers from Stack Overflow). But it doesn't seem to work for me. I am calling Popen to run a command (which runs for a long time) from one t

Re: [Tutor] Howto handle pictures with pyqt

2013-10-22 Thread Alan Gauld
On 22/10/13 22:21, Ulrich Goebel wrote: for my first python program I try to build a user interface for a litle address database. Therefor I use pyqt to build the formular, and later I will connect it to an existing SQLite DB, using APSW. This list is for beginners to the python language and s

Re: [Tutor] Beginner Question

2013-10-22 Thread Alan Gauld
On 22/10/13 19:18, Sven Hennig wrote: Thank you! You guys helped me out alot. @Alan your website is great! Really clearly written. Especially the "Things to remember" part. Glad you like it. Someday (soon!) I'll get round to finishing the v3 version... So much to do, so little time! If you h

Re: [Tutor] comma in an assignment

2013-10-22 Thread Alan Gauld
On 22/10/13 20:20, Key, Gregory E (E S SF RNA FSF 1 C) wrote: I understand that a comma in Python is a separator and not an operator. In some of the MatPlotLib examples I see code like this: line1, = ax1.plot(t, y1, lw=2, color='red', label='1 HZ') What does the comma do in an assignment statemen

[Tutor] Howto handle pictures with pyqt

2013-10-22 Thread Ulrich Goebel
Hello, for my first python program I try to build a user interface for a litle address database. Therefor I use pyqt to build the formular, and later I will connect it to an existing SQLite DB, using APSW. Besides the "normal" things as name, address, email and others I want to store an imag

Re: [Tutor] Beginner Question

2013-10-22 Thread Sven Hennig
Thank you! You guys helped me out alot. @Alan your website is great! Really clearly written. Especially the "Things to remember" part. If you have exercises for me or have a Website with exercises, bring it on. I think this is the best way to learn. 2013/10/22 Dave Angel > On 22/10/2013 10:2

[Tutor] comma in an assignment

2013-10-22 Thread Key, Gregory E (E S SF RNA FSF 1 C)
I understand that a comma in Python is a separator and not an operator. In some of the MatPlotLib examples I see code like this: line1, = ax1.plot(t, y1, lw=2, color='red', label='1 HZ') What does the comma do in an assignment statement? Greg Key This message and any attachments are solely fo

Re: [Tutor] Beginner Question

2013-10-22 Thread Dave Angel
On 22/10/2013 10:25, Sven Hennig wrote: > Hello, I would like to learn a programming language and have decided to use > Python. I have some programming experience and doing well in Python. What > really causes me problems is OOP. > I'm just dont get it... I'm missing a really Practical example. I

Re: [Tutor] Beginner Question

2013-10-22 Thread Andy McKenzie
On Tue, Oct 22, 2013 at 10:25 AM, Sven Hennig wrote: > Hello, I would like to learn a programming language and have decided to > use Python. I have some programming experience and doing well in Python. > What really causes me problems is OOP. > I'm just dont get it... I'm missing a really Practica

Re: [Tutor] Beginner Question

2013-10-22 Thread Alan Gauld
On 22/10/13 15:25, Sven Hennig wrote: Hello, I would like to learn a programming language and have decided to use Python. I have some programming experience and doing well in Python. What really causes me problems is OOP. Don't worry this is common. The problem with OOP is that it only really b

Re: [Tutor] Fwd: Re: Passing arguments?

2013-10-22 Thread Alan Gauld
On 22/10/13 14:55, Ricardo Aráoz wrote: Sorry, meant try/except (I was thinking VFP). Wouldn't if/else be more difficult when validating if an input is a valid float? I find try/except easier. Maybe, but typical programming classes don't teach try/except till much later in the course. Since t

[Tutor] Beginner Question

2013-10-22 Thread Sven Hennig
Hello, I would like to learn a programming language and have decided to use Python. I have some programming experience and doing well in Python. What really causes me problems is OOP. I'm just dont get it... I'm missing a really Practical example. In every book I've read are the examples of such C

Re: [Tutor] Fwd: Re: Passing arguments?

2013-10-22 Thread Mark Lawrence
On 22/10/2013 03:23, Jenny Allar wrote: Plenty of sound advice as always so I'll just point out that... elif product_weight >= 10 and product_weight < 25: can be written as elif 10 <= product_weight < 25: -- Python is the second best programming language in the world. But the best has

Re: [Tutor] Fwd: Re: Passing arguments?

2013-10-22 Thread Ricardo Aráoz
El 22/10/13 10:44, Alan Gauld escribió: On 22/10/13 14:21, Ricardo Aráoz wrote: - Did you notice your assignment specifically asks for a "while" loop for validation? ... (tip: you should be using "while" and "on error") on error? You're not thinking of VB by any chance? :-) In Python it would

Re: [Tutor] Fwd: Re: Passing arguments?

2013-10-22 Thread Alan Gauld
On 22/10/13 14:21, Ricardo Aráoz wrote: - Did you notice your assignment specifically asks for a "while" loop for validation? ... (tip: you should be using "while" and "on error") on error? You're not thinking of VB by any chance? :-) In Python it would be a try/except block or maybe a straigh

Re: [Tutor] [OT] Programming practice was: Re: string list in alphabetical!

2013-10-22 Thread Alan Gauld
On 22/10/13 13:42, Sydney Shall wrote: trying to get him to adopt a workflow where he writes on paper an informal "use case" description of the solution and if necessary a pseudo code design. Could you please explain exactly what you mean by 'an informal "use case" description of the solution

Re: [Tutor] Fwd: Re: Passing arguments?

2013-10-22 Thread Ricardo Aráoz
- Did you notice your assignment specifically asks for a "while" loop for validation? That means you are expected to validate input. Run your program and when the program asks "Please enter the weight of the product in pounds: " answer "123...this is a mistake", what does it happen? Your progra

Re: [Tutor] Fwd: Re: Passing arguments?

2013-10-22 Thread Alan Gauld
On 22/10/13 03:23, Jenny Allar wrote: I ended up using the following code: One wee improvement you could consider: def cal_shiprate(product_name, product_weight): if product_weight < 10: ship_rate = 1.5 elif product_weight >= 10 and product_weight < 25: ship_rate = 1

Re: [Tutor] [OT] Programming practice was: Re: string list in alphabetical!

2013-10-22 Thread bob gailer
I am glad we are having this discussion. It helps me understand the plight of some of our posters. I had the benefit of a good school system, plus attending a technical high school and a college of engineering. In the early 90's I was an adjunct professor at the University of Denver's "Unive

Re: [Tutor] [OT] Programming practice was: Re: string list in alphabetical!

2013-10-22 Thread Sydney Shall
On 22/10/2013 00:42, Alan Gauld wrote: On 22/10/13 00:07, Steven D'Aprano wrote: I'd like to upgrade that process :D ... 1) think about your problem 2) if there are some heplful libraries that can make it way easier, use them 3) write some code 4) fix the bugs until it'll run 5) write unitte

Re: [Tutor] Fwd: Re: Passing arguments?

2013-10-22 Thread Jenny Allar
Thank you all for your help with this program. Each of your answers helped me piece together an understanding of the assignment. After several days and clearly over-thinking the entire process, I ended up using the following code: def main (): name = input("Please enter the name of the product

Re: [Tutor] [OT] Programming practice was: Re: string list in alphabetical!

2013-10-22 Thread ALAN GAULD
The interesting thing however is that the schools have not taught >>any kind of approach to problem solving, they just give a homework assignment >>and expect them to produce code. > > >I feel like we've had this conversation a long, long time ago.  :P > > >This is the sort of thing that we should