Re: Newbie question. Are those different objects ?

2013-12-20 Thread 88888 Dihedral
On Saturday, December 21, 2013 1:10:37 AM UTC+8, rusi wrote: On Friday, December 20, 2013 9:30:22 PM UTC+5:30, Mark Lawrence wrote: On 20/12/2013 15:34, rusi wrote: On Friday, December 20, 2013 8:46:31 PM UTC+5:30, dec...@msn.com wrote: y = raw_input('Enter a number:') print

Re: Newbie question. Are those different objects ?

2013-12-20 Thread rurpy
On 12/20/2013 08:16 AM, dec...@msn.com wrote: y = raw_input('Enter a number:') print type y y = float(raw_input('Enter a number:')) print type y I'm assuming that y is an object. Rather than thinking that y is an object, it is more accurate to think of it as: y is a name that is bound to

Re: Newbie question. Are those different objects ?

2013-12-20 Thread Travis Griggs
On Dec 20, 2013, at 8:00 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: A good point. Shall I write a PEP asking for a language change which requires that that stupid = sign is replaced by a keyword reading something like thenameonthelefthandsideisassignedtheobjectontherighthandside ? Or

Re: Newbie question. Are those different objects ?

2013-12-20 Thread Terry Reedy
On 12/20/2013 10:16 AM, dec...@msn.com wrote: y = raw_input('Enter a number:') print type y y = float(raw_input('Enter a number:')) print type y I recommend starting with 3.3 unless your are forced to use 2.x. I also recommend trying code before posting it. I'm assuming that y is an object.

Re: Newbie question. Are those different objects ?

2013-12-20 Thread Gregory Ewing
rusi wrote: Good idea. Only you were beaten to it by about 2 decades. More than 2, I think. Lisp: (setq x y) Algol: x := y Smalltalk: x - y (where - is a left arrow character) Cobol: MOVE X TO Y -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Newbie question related to Boolean in Python

2013-09-05 Thread skwyang93
1. bear_moved = False 2. 3. while True: 4.next = raw_input( ) 5. 6.if next == take honey: 7.dead(The bear looks at you then slaps your face off.) 8.elif next == taunt bear and not bear_moved: 9.print The bear has moved from the

Re: Newbie question related to Boolean in Python

2013-09-05 Thread Neil Cerutti
On 2013-09-05, skwyan...@gmail.com skwyan...@gmail.com wrote: 1. bear_moved = False 2. 3. while True: 4.next = raw_input( ) 5. 6.if next == take honey: 7.dead(The bear looks at you then slaps your face off.) 8.elif next == taunt bear

Re: Newbie question related to Boolean in Python

2013-09-05 Thread Dave Angel
On 5/9/2013 16:08, skwyan...@gmail.com wrote: 1. bear_moved = False 2. 3. while True: 4.next = raw_input( ) 5. 6.if next == take honey: 7.dead(The bear looks at you then slaps your face off.) 8.elif next == taunt bear and not

Re: Newbie question related to Boolean in Python

2013-09-05 Thread Thomas Yang
bear_moved = False while True: next = raw_input( ) if next == take honey: dead(The bear looks at you then slaps your face off.) elif next == taunt bear and not bear_moved: print The bear has moved from the door. You can go through.

Re: Newbie question related to Boolean in Python

2013-09-05 Thread Steven D'Aprano
On Thu, 05 Sep 2013 16:36:55 -0700, Thomas Yang wrote: bear_moved = False while True: next = raw_input( ) if next == take honey: dead(The bear looks at you then slaps your face off.) elif next == taunt bear and not bear_moved:

Re: Newbie question related to Boolean in Python

2013-09-05 Thread Tim Roberts
skwyan...@gmail.com wrote: # This is just to show my understanding of Boolean. In line 8-9, if my input is taunt bear, the result is true and true, which will continue the loop. So what confused me is line 12-13. if my input is taunt bear, is it suppose to be taunt bear == taunt bear and

Re: newbie question

2013-06-25 Thread Gene Heskett
On Saturday 22 June 2013 22:46:51 christheco...@gmail.com did opine: Writing simple program asking a question with the answer being yes...how do I allow the correct answer if user types Yes, yes, or YES? Thanks AND each character coming in from the keyboard with $DF before adding it to

Re: newbie question

2013-06-25 Thread Ian Kelly
On Sat, Jun 22, 2013 at 8:49 PM, Gene Heskett ghesk...@wdtv.com wrote: On Saturday 22 June 2013 22:46:51 christheco...@gmail.com did opine: Writing simple program asking a question with the answer being yes...how do I allow the correct answer if user types Yes, yes, or YES? Thanks AND

Re: newbie question

2013-06-25 Thread Tim Rowe
On 23 June 2013 03:49, Gene Heskett ghesk...@wdtv.com wrote: On Saturday 22 June 2013 22:46:51 christheco...@gmail.com did opine: Writing simple program asking a question with the answer being yes...how do I allow the correct answer if user types Yes, yes, or YES? Thanks AND each

newbie question

2013-06-22 Thread christhecomic
Writing simple program asking a question with the answer being yes...how do I allow the correct answer if user types Yes, yes, or YES? Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie question

2013-06-22 Thread Chris Angelico
On Sun, Jun 23, 2013 at 12:39 PM, christheco...@gmail.com wrote: Writing simple program asking a question with the answer being yes...how do I allow the correct answer if user types Yes, yes, or YES? The thing you're looking for is case-folding, or possibly lower-casing. You should be able to

Re: newbie question

2013-06-22 Thread Rick Johnson
On Saturday, June 22, 2013 9:39:30 PM UTC-5, christ...@gmail.com wrote: Writing simple program asking a question with the answer being yes...how do I allow the correct answer if user types Yes, yes, or YES? Here is a clue. py 'e' == 'e' True py 'E' == 'E' True --

Re: newbie question

2013-06-22 Thread Steven D'Aprano
On Sat, 22 Jun 2013 19:39:30 -0700, christhecomic wrote: Writing simple program asking a question with the answer being yes...how do I allow the correct answer if user types Yes, yes, or YES? Take the user's input, strip off any whitespace from the beginning and end, then fold the case to a

Re: Newbie: question regarding references and class relationships

2013-06-13 Thread Rui Maciel
Rick Johnson wrote: On Monday, June 10, 2013 8:18:52 AM UTC-5, Rui Maciel wrote: [...] code class Point: position = [] def __init__(self, x, y, z = 0): self.position = [x, y, z] Firstly. Why would you define a Point object that holds it's x,y,z values

Re: Newbie: question regarding references and class relationships

2013-06-13 Thread Chris Angelico
On Thu, Jun 13, 2013 at 10:06 PM, Rui Maciel rui.mac...@gmail.com wrote: Rick Johnson wrote: Firstly. Why would you define a Point object that holds it's x,y,z values in a list attribute? Why not store them as self.x, self.y and self.z? snip/ The position in space is represented as a vector,

Re: Newbie: question regarding references and class relationships

2013-06-13 Thread Rui Maciel
Chris Angelico wrote: Just FYI, Rick Johnson (aka Ranting Rick) is a known troll. Don't let him goad you :) Follow other people's advice, and take Rick's posts with a grain of salt. Sometimes he has a good point to make (more often when he's talking about tkinter, which is his area of

Re: Newbie: question regarding references and class relationships

2013-06-11 Thread Rick Johnson
On Monday, June 10, 2013 8:18:52 AM UTC-5, Rui Maciel wrote: [...] code class Point: position = [] def __init__(self, x, y, z = 0): self.position = [x, y, z] Firstly. Why would you define a Point object that holds it's x,y,z values in a list attribute? Why

Re: Newbie: question regarding references and class relationships

2013-06-11 Thread Rick Johnson
On Monday, June 10, 2013 2:56:15 PM UTC-5, Ian wrote: [...] There are a couple of ways you might get this to work the way you want. One is by adding as an extra layer a proxy object, which could be as simple as: class Proxy(object): def __init__(self, ref): self.ref = ref

Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Let: - class Point be a data type which is used to define points in space - class Line be a data type which possesses an aggregate relationship with objects of type Point - class Model be a container class which stores collections of Point and Line objects Essentially, a Model object stores

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Roy Smith
In article kp4jf4$5fu$1...@dont-email.me, Rui Maciel rui.mac...@gmail.com wrote: Essentially, a Model object stores lists of Point objects and Line objects, and Line objects include references to Point objects which represent the starting and ending point of a line. class Point:

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Peter Otten
Rui Maciel wrote: Let: - class Point be a data type which is used to define points in space - class Line be a data type which possesses an aggregate relationship with objects of type Point - class Model be a container class which stores collections of Point and Line objects

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Roy Smith wrote: Have you tried running the code you wrote? It does that already! When you do something like: my_list = [obj1, obj2] in Python, the objects are stored by reference (not just lists, all assignments are by reference). I've tested the following: code model = Model()

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Peter Otten wrote: Don't add position = [] to your code. That's not a declaration, but a class attribute and in the long run it will cause nothing but trouble. Why's that? Rui Maciel -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Rui Maciel wrote: # Case B: this doesn't work test.model.points[0] = test.Point(5,4,7) Disregard the test. bit. I was testing the code by importing the definitions as a module. Rui Maciel -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Peter Otten
Rui Maciel wrote: Peter Otten wrote: Don't add position = [] to your code. That's not a declaration, but a class attribute and in the long run it will cause nothing but trouble. Why's that? Especially with mutable attributes it's hard to keep track whether you are operating on the

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Peter Otten wrote: Rui Maciel wrote: Peter Otten wrote: Don't add position = [] to your code. That's not a declaration, but a class attribute and in the long run it will cause nothing but trouble. Why's that? Especially with mutable attributes it's hard to keep track whether

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Peter Otten
Rui Maciel wrote: How do you guarantee that any object of a class has a specific set of attributes? You don't. Such a guarantee is like the third wheel on a bike -- it doesn't improve the overall experience. PS: I'd rather not mention the memory-saving technique that is sometimes abused,

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Peter Otten wrote: Rui Maciel wrote: How do you guarantee that any object of a class has a specific set of attributes? You don't. What's your point regarding attribute assignments in class declarations, then? Rui Maciel -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Peter Otten
Rui Maciel wrote: Peter Otten wrote: Rui Maciel wrote: How do you guarantee that any object of a class has a specific set of attributes? You don't. What's your point regarding attribute assignments in class declarations, then? I don't understand the question. My original point

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Peter Otten wrote: I don't understand the question. My original point was that you should omit class attributes that don't fulfill a technical purpose. You've said the following: quote class Point: Don't add position = [] to your code. That's not a declaration, but a class

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Peter Otten
Rui Maciel wrote: Peter Otten wrote: I don't understand the question. My original point was that you should omit class attributes that don't fulfill a technical purpose. You've said the following: quote class Point: Don't add position = [] to your code. That's not a

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Peter Otten wrote: Have you read the code in the interpreter session I posted? If you do not agree that the demonstrated behaviour is puzzling I'll have to drop my claim... I don't see how it should be puzzling. You've deleted the attribute, so it ceassed to exist. Likewise if you can

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Dave Angel
On 06/10/2013 01:42 PM, Rui Maciel wrote: Peter Otten wrote: Have you read the code in the interpreter session I posted? If you do not agree that the demonstrated behaviour is puzzling I'll have to drop my claim... I don't see how it should be puzzling. You've deleted the attribute, so it

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Terry Jan Reedy
On 6/10/2013 12:09 PM, Rui Maciel wrote: We've established that you don't like attribute declarations, at least those you describe as not fulfill a technical purpose. What I don't understand is why you claim that that would cause nothing but trouble. Three answers: Look how much trouble it

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Terry Jan Reedy
On 6/10/2013 9:18 AM, Rui Maciel wrote: class Model: points = [] lines = [] Unless you actually need keep the points and lines ordered by entry order, or expect to keep sorting them by whatever, sets may be better than lists. Testing that a point or line is in the model

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Ian Kelly
On Mon, Jun 10, 2013 at 7:57 AM, Rui Maciel rui.mac...@gmail.com wrote: # Case A: this works model.points[0].position = [2,3,4] line.points # Case B: this doesn't work test.model.points[0] = test.Point(5,4,7) line.points /code Is there a Python way of getting the same effect with Case

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Terry Jan Reedy wrote: On 6/10/2013 9:18 AM, Rui Maciel wrote: class Model: points = [] lines = [] Unless you actually need keep the points and lines ordered by entry order, or expect to keep sorting them by whatever, sets may be better than lists. Testing that a

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Terry Jan Reedy wrote: Three answers: Look how much trouble it has already caused ;-) Since you are a self-declared newbie, believe us! Since, be definition, useless code can do no good, it can only cause trouble. Think about it. I don't doubt that there might good reasons for that, but it

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Rui Maciel
Dave Angel wrote: So why do you also have an instance attribute of the same name? Thanks to this thread, and after a bit of reading, I've finally managed to discover that in Python there are class attributes and instance attributes, the former working similarly to C++'s static member

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Terry Jan Reedy
On 6/10/2013 4:13 PM, Rui Maciel wrote: Terry Jan Reedy wrote: Three answers: Look how much trouble it has already caused ;-) Since you are a self-declared newbie, believe us! Since, be definition, useless code can do no good, it can only cause trouble. Think about it. I don't doubt that

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Grant Edwards
On 2013-06-10, Terry Jan Reedy tjre...@udel.edu wrote: Another principle similar to 'Don't add extraneous code' is 'Don't rebind builtins'. OK, we've all done it by accident (especially when starting out), but are there people that rebind builtins intentionally? -- Grant Edwards

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Chris Angelico
On Tue, Jun 11, 2013 at 8:39 AM, Grant Edwards invalid@invalid.invalid wrote: On 2013-06-10, Terry Jan Reedy tjre...@udel.edu wrote: Another principle similar to 'Don't add extraneous code' is 'Don't rebind builtins'. OK, we've all done it by accident (especially when starting out), but are

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Tim Chase
On 2013-06-11 08:54, Chris Angelico wrote: Another principle similar to 'Don't add extraneous code' is 'Don't rebind builtins'. OK, we've all done it by accident (especially when starting out), but are there people that rebind builtins intentionally? There are times when you don't

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Dave Angel
On 06/10/2013 06:54 PM, Chris Angelico wrote: On Tue, Jun 11, 2013 at 8:39 AM, Grant Edwards invalid@invalid.invalid wrote: On 2013-06-10, Terry Jan Reedy tjre...@udel.edu wrote: Another principle similar to 'Don't add extraneous code' is 'Don't rebind builtins'. OK, we've all done it by

Re: Newbie: question regarding references and class relationships

2013-06-10 Thread Jason Swails
On Mon, Jun 10, 2013 at 7:26 PM, Dave Angel da...@davea.name wrote: On 06/10/2013 06:54 PM, Chris Angelico wrote: On Tue, Jun 11, 2013 at 8:39 AM, Grant Edwards invalid@invalid.invalid wrote: On 2013-06-10, Terry Jan Reedy tjre...@udel.edu wrote: Another principle similar to 'Don't add

Re: Newbie question about evaluating raw_input() responses

2013-05-25 Thread Nobody
On Thu, 23 May 2013 17:20:19 +1000, Chris Angelico wrote: Aside: Why was PHP's /e regexp option ever implemented? Because it's a stupid idea, and that's the only requirement for a feature to be implemented in PHP. -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question about evaluating raw_input() responses

2013-05-25 Thread Chris Angelico
On Sun, May 26, 2013 at 4:27 AM, Nobody nob...@nowhere.com wrote: On Thu, 23 May 2013 17:20:19 +1000, Chris Angelico wrote: Aside: Why was PHP's /e regexp option ever implemented? Because it's a stupid idea, and that's the only requirement for a feature to be implemented in PHP. Hey, don't

Re: Newbie question about evaluating raw_input() responses

2013-05-25 Thread Fábio Santos
On 25 May 2013 19:37, Chris Angelico ros...@gmail.com wrote: Ah, who am I kidding. Be as rude as you like. I have to work with PHP all week. ChrisA -- http://mail.python.org/mailman/listinfo/python-list I have cried. -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question about evaluating raw_input() responses

2013-05-23 Thread Chris Angelico
On Thu, May 23, 2013 at 2:47 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: But all joking aside, eval is dangerous, yes, but it is not evil. It needs to be handled with caution, but there are good uses for it. In fact, there are a few -- a very few -- things which can *only*

Re: Newbie question about evaluating raw_input() responses

2013-05-23 Thread Terry Jan Reedy
On 5/23/2013 12:47 AM, Steven D'Aprano wrote: On Wed, 22 May 2013 22:31:04 +, Alister wrote: Please write out 1000 time (without using any form of loop) NEVER use input in python 3.0 it is EVIL* But all joking aside, eval is dangerous, yes, but it is not evil. He put that label on

newbie question about subprocess.Popen() arguments

2013-05-23 Thread Alex Naumov
Hello, I'm trying to call new process with some parameters. The problem is that the last parameter is a string that has a lot of spaces and different symbols like slash and so on. I can save it in file and use name of this file as parameter, but my question is: how to make it without additional

Re: Newbie question about evaluating raw_input() responses

2013-05-23 Thread Chris Angelico
On Thu, May 23, 2013 at 5:11 PM, Terry Jan Reedy tjre...@udel.edu wrote: On 5/23/2013 12:47 AM, Steven D'Aprano wrote: On Wed, 22 May 2013 22:31:04 +, Alister wrote: Please write out 1000 time (without using any form of loop) NEVER use input in python 3.0 it is EVIL* But all joking

Re: newbie question about subprocess.Popen() arguments

2013-05-23 Thread Peter Otten
Alex Naumov wrote: I'm trying to call new process with some parameters. The problem is that the last parameter is a string that has a lot of spaces and different symbols like slash and so on. I can save it in file and use name of this file as parameter, but my question is: how to make it

Re: newbie question about subprocess.Popen() arguments

2013-05-23 Thread Alex Naumov
Thank you very much, Peter! It works! On Thu, May 23, 2013 at 9:32 AM, Peter Otten __pete...@web.de wrote: Alex Naumov wrote: I'm trying to call new process with some parameters. The problem is that the last parameter is a string that has a lot of spaces and different symbols like slash

Newbie question about evaluating raw_input() responses

2013-05-22 Thread C. N. Desrosiers
Hi, I'm just starting out with Python and to practice I am trying to write a script that can have a simple conversation with the user. When I run the below code, it always ends up printing response to if age 18: -- even if I enter a value below 18. Can anyone point me to what I am doing

Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Fábio Santos
You have to convert `age` to an integer. Use int() to do it. Then you can compare it to other numbers and obtain the expected results. On 22 May 2013 07:29, C. N. Desrosiers cndesrosi...@gmail.com wrote: Hi, I'm just starting out with Python and to practice I am trying to write a script that

Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Kevin Xi
On Wednesday, May 22, 2013 2:23:15 PM UTC+8, C. N. Desrosiers wrote: Hi, Hi, I'm just starting out with Python and to practice I am trying to write a script that can have a simple conversation with the user. So you may want to search the doc before you ask: http://docs.python.org When

Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread C. N. Desrosiers
Muchas gracias! On Wednesday, May 22, 2013 2:35:18 AM UTC-4, Fábio Santos wrote: You have to convert `age` to an integer. Use int() to do it. Then you can compare it to other numbers and obtain the expected results. On 22 May 2013 07:29, C. N. Desrosiers cndesr...@gmail.com wrote: Hi,

Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Chris Angelico
On Wed, May 22, 2013 at 4:52 PM, Kevin Xi kevin@gmail.com wrote: On Wednesday, May 22, 2013 2:23:15 PM UTC+8, C. N. Desrosiers wrote: age=raw_input('Enter your age: ') if age 18: You can either use `raw_input` to read data and convert it to right type, or use `input` to get an integer

Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Alister
On Tue, 21 May 2013 23:52:30 -0700, Kevin Xi wrote: On Wednesday, May 22, 2013 2:23:15 PM UTC+8, C. N. Desrosiers wrote: Hi, Hi, I'm just starting out with Python and to practice I am trying to write a script that can have a simple conversation with the user. So you may want to search

RE: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Carlos Nepomuceno
From: alister.w...@ntlworld.com [...] Kevin Please write out 1000 time (without using any form of loop) NEVER use input in python 3.0 it is EVIL* as Chris A point out it executes user input an can cause major damage (reformatting the hard disk is

Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Kevin Xi
Oh yes, you guys are right. Thank you very much for warning me that. On Thursday, May 23, 2013 6:31:04 AM UTC+8, Alister wrote: as Chris A point out it executes user input an can cause major damage (reformatting the hard disk is not impossible!) It definitely can cause major damage! I

Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Steven D'Aprano
On Wed, 22 May 2013 22:31:04 +, Alister wrote: Please write out 1000 time (without using any form of loop) NEVER use input in python 3.0 it is EVIL* as Chris A point out it executes user input an can cause major damage (reformatting the hard disk is not impossible!) Is he allowed to

RE: newbie question about confusing exception handling in urllib

2013-04-12 Thread Prasad, Ramit
Steven D'Aprano wrote: try: main() except Exception as err: log(err) print(Sorry, an unexpected error has occurred.) print(Please contact support for assistance.) sys.exit(-1) I like the traceback[0] module for logging last exception thrown. See

newbie question about confusing exception handling in urllib

2013-04-09 Thread cabbar
Hi, I have been using Java/Perl professionally for many years and have been trying to learn python3 recently. As my first program, I tried writing a class for a small project, and I am having really hard time understanding exception handling in urllib and in python in general... Basically,

Re: newbie question about confusing exception handling in urllib

2013-04-09 Thread Peter Otten
cab...@gmail.com wrote: Hi, I have been using Java/Perl professionally for many years and have been trying to learn python3 recently. As my first program, I tried writing a class for a small project, and I am having really hard time understanding exception handling in urllib and in python

Re: newbie question about confusing exception handling in urllib

2013-04-09 Thread cabbar
Ah, looks better. But, 2 questions: 1. I should also catch ConnectionResetError I am guessing. 2. How do I handle all other exceptions, just say Exception: and handle them? I want to silently ignore them. Thanks... On Tuesday, April 9, 2013 2:41:51 PM UTC+3, cab...@gmail.com wrote: Hi,

Re: newbie question about confusing exception handling in urllib

2013-04-09 Thread Terry Jan Reedy
On 4/9/2013 7:41 AM, cab...@gmail.com wrote: Hi, I have been using Java/Perl professionally for many years and have been trying to learn python3 recently. As my first program, I tried writing a class for a small project, and I am having really hard time understanding exception handling in

Re: newbie question about confusing exception handling in urllib

2013-04-09 Thread Peter Otten
cab...@gmail.com wrote: Ah, looks better. But, 2 questions: 1. I should also catch ConnectionResetError I am guessing. Does it need a special reaction? If so give it its own except suite. 2. How do I handle all other exceptions, just say Exception: and handle them? I want to silently

Re: newbie question about confusing exception handling in urllib

2013-04-09 Thread Steven D'Aprano
On Tue, 09 Apr 2013 06:19:09 -0700, cabbar wrote: How do I handle all other exceptions, just say Exception: and handle them? I want to silently ignore them. Please don't. That is normally poor practice, since it simply hides bugs in your code. As a general rule, you should only catch

Re: newbie question about confusing exception handling in urllib

2013-04-09 Thread Chris Angelico
On Wed, Apr 10, 2013 at 1:05 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: One exception to this rule (no pun intended) is that sometimes you want to hide the details of unexpected tracebacks from your users. In that case, it may be acceptable to wrap your application's main

Re: newbie question about confusing exception handling in urllib

2013-04-09 Thread Ian Kelly
On Tue, Apr 9, 2013 at 5:41 AM, cab...@gmail.com wrote: try: response = urllib.request.urlopen(request) content = response.read() except BaseException as ue: if (isinstance(ue, socket.timeout) or (hasattr(ue, reason) and

Newbie to python. Very newbie question

2013-04-07 Thread ReviewBoard User
Hi I am a newbie to python and am trying to write a program that does a sum of squares of numbers whose squares are odd. For example, for x from 1 to 100, it generates 165 as an output (sum of 1,9,25,49,81) Here is the code I have print reduce(lambda x, y: x+y, filter(lambda x: x%2, map(lambda x:

Re: Newbie to python. Very newbie question

2013-04-07 Thread Kruno Saho
On Sunday, April 7, 2013 9:16:27 PM UTC+10, ReviewBoard User wrote: Hi I am a newbie to python and am trying to write a program that does a sum of squares of numbers whose squares are odd. For example, for x from 1 to 100, it generates 165 as an output (sum of 1,9,25,49,81)

Re: Newbie to python. Very newbie question

2013-04-07 Thread Dave Angel
On 04/07/2013 07:16 AM, ReviewBoard User wrote: Hi I am a newbie to python Then why are you trying to do 7 or 8 things on one line? and am trying to write a program that does a sum of squares of numbers whose squares are odd. For example, for x from 1 to 100, it generates 165 as an output

Re: Newbie to python. Very newbie question

2013-04-07 Thread Miki Tebeka
I am a newbie to python Welcome! I hope you'll do great things with Python. and am trying to write a program that does a sum of squares of numbers whose squares are odd. OK. For example, for x from 1 to 100, it generates 165 as an output (sum of 1,9,25,49,81) I don't follow, you seem to be

Re: Newbie to python. Very newbie question

2013-04-07 Thread rusi
On Apr 7, 4:16 pm, ReviewBoard User lalitha.viswan...@gmail.com wrote: Hi I am a newbie to python and am trying to write a program that does a sum of squares of numbers whose squares are odd. For example, for x from 1 to 100, it generates 165 as an output (sum of 1,9,25,49,81) Here is the

Re: Newbie to python. Very newbie question

2013-04-07 Thread Ian Foote
On 07/04/13 20:09, Dennis Lee Bieber wrote: On Sun, 7 Apr 2013 04:16:27 -0700 (PDT), ReviewBoard User lalitha.viswan...@gmail.com declaimed the following in gmane.comp.python.general: Hi I am a newbie to python and am trying to write a program that does a sum of squares of numbers whose

Re: Newbie to python. Very newbie question

2013-04-07 Thread Arnaud Delobelle
On 7 April 2013 20:23, Ian Foote i...@feete.org wrote: I'm surprised no one has suggested: import math sum( x*x for x in range(1, int(math.sqrt(100)), 2)) Yeah! And I'm surprised no one came up with: from itertools import count, takewhile sum(takewhile((100).__gt__, filter((2).__rmod__,

Re: Newbie to python. Very newbie question

2013-04-07 Thread Miki Tebeka
I can't even read that mess... three nested lambda? I have to say this and other answers in this thread seem not that friendly to me. The OP said it's a newbie question, we should be more welcoming to newcomers. -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie to python. Very newbie question

2013-04-07 Thread Steven D'Aprano
On Sun, 07 Apr 2013 04:16:27 -0700, ReviewBoard User wrote: Hi I am a newbie to python and am trying to write a program that does a sum of squares of numbers whose squares are odd. For example, for x from 1 to 100, it generates 165 as an output (sum of 1,9,25,49,81) Here is the code I have

A newbie question

2013-02-12 Thread Alberto Salvati
Hi, All. I'm a (old) delphi developer. I want to learn Python. I've python 2.7 and django. For learning purpose I want to use firebird. But, package (egg) to use firebird needs easy_install for setup. When i run: python ez_setup.py install python says me error: Downloading

Re: A newbie question

2013-02-12 Thread Colin J. Williams
On 12/02/2013 10:06 AM, Alberto Salvati wrote: Hi, All. I'm a (old) delphi developer. I want to learn Python. I've python 2.7 and django. For learning purpose I want to use firebird. But, package (egg) to use firebird needs easy_install for setup. When i run: python ez_setup.py install

Re: A newbie question

2013-02-12 Thread Alberto Salvati
Hi, Colin. Thanks for your answer. But C:\Python27\Scripts is in my path and my trouble is about INSTALL easy_isntall. Bye A. -- http://mail.python.org/mailman/listinfo/python-list

newbie question : gedit as an ide

2012-09-16 Thread Mayuresh Kathe
new to the group, a quick hello to all. :-) does anyone use gedit as an 'ide' for python development? if yes, may i know the caveats against using 'idle', 'bpython', etc? thank you. -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie question : gedit as an ide

2012-09-16 Thread Chris Angelico
On Sun, Sep 16, 2012 at 9:52 PM, Mayuresh Kathe mayur...@kathe.in wrote: new to the group, a quick hello to all. :-) does anyone use gedit as an 'ide' for python development? if yes, may i know the caveats against using 'idle', 'bpython', etc? thank you. I never really liked gedit; when I

Re: newbie question : gedit as an ide

2012-09-16 Thread Devin Jeanpierre
On Sun, Sep 16, 2012 at 7:52 AM, Mayuresh Kathe mayur...@kathe.in wrote: new to the group, a quick hello to all. :-) does anyone use gedit as an 'ide' for python development? if yes, may i know the caveats against using 'idle', 'bpython', etc? bpython isn't an IDE, it's a good interactive

newbie question About O'Reilly Python for Unix and Linux System Administration ftp Mirror question

2012-09-16 Thread moonhkt
Hi All O'Reilly Book ISBN 978-986-6840-36-4. python --version Python 2.6.2 on AIX 5.3 Using this python to get files in ftp server. I got below error. What is the error meaning and how to fix ? ftp_mirror.py Traceback (most recent call last): File /xx../shell/ftpmirror.py, line 80, in

Re: newbie question About O'Reilly Python for Unix and Linux System Administration ftp Mirror question

2012-09-16 Thread Joel Goldstick
On Sun, Sep 16, 2012 at 11:09 AM, moonhkt moon...@gmail.com wrote: Hi All O'Reilly Book ISBN 978-986-6840-36-4. python --version Python 2.6.2 on AIX 5.3 Using this python to get files in ftp server. I got below error. What is the error meaning and how to fix ? ftp_mirror.py Traceback

Re: newbie question About O'Reilly Python for Unix and Linux System Administration ftp Mirror question

2012-09-16 Thread Chris Angelico
On Mon, Sep 17, 2012 at 1:09 AM, moonhkt moon...@gmail.com wrote: Hi All O'Reilly Book ISBN 978-986-6840-36-4. python --version Python 2.6.2 on AIX 5.3 Hi! Thanks for this, good information to open with. Using this python to get files in ftp server. I got below error. What is the error

Re: Newbie question on python programming

2012-07-21 Thread Tom P
On 07/21/2012 02:30 AM, Ian Kelly wrote: On Fri, Jul 20, 2012 at 5:38 PM, Chris Williams purplewel...@googlemail.com wrote: Hello I hope this is the right newsgroup for this post. I am just starting to learn python programming and it seems very straightforward so far. It seems, however,

Newbie question on python programming

2012-07-20 Thread Chris Williams
Hello I hope this is the right newsgroup for this post. I am just starting to learn python programming and it seems very straightforward so far. It seems, however, geared toward doing the sort of programming for terminal output. Is it possible to write the sort of applications you can

Re: Newbie question on python programming

2012-07-20 Thread Ian Kelly
On Fri, Jul 20, 2012 at 5:38 PM, Chris Williams purplewel...@googlemail.com wrote: Hello I hope this is the right newsgroup for this post. I am just starting to learn python programming and it seems very straightforward so far. It seems, however, geared toward doing the sort of programming

Re: Naming convention for in-house modules (Newbie question)

2012-02-09 Thread Laurent Claessens
Here is my question: I would like to start an in-house library of small modules to import, for things like error handling/logging. That's easy enough, but is there a recommended way of naming such modules? I am concerned about avoiding name clashes with standard modules and site packages.

Re: Naming convention for in-house modules (Newbie question)

2012-02-09 Thread Arnaud Delobelle
On 9 February 2012 14:00, Laurent Claessens moky.m...@gmail.com wrote: Here is my question: I would like to start an in-house library of small modules to import, for things like error handling/logging. That's easy enough, but is there a recommended way of naming such modules? I am concerned

<    1   2   3   4   5   6   7   8   9   10   >