Re: What's going on here?

2016-06-01 Thread Lawrence D’Oliveiro
On Monday, May 23, 2016 at 9:47:15 AM UTC+12, DFS wrote: > def splitrange(b,e,g): > sr=[] > for i in range(b,e,g): > bg=i;eg=min(e,bg+g-1) > sr.append((bg,eg)) > return sr To be more in keeping with the Python ethos, I would take out the “-1”. --

Re: function with list argument defaulting to [] - what's going on here???

2007-04-15 Thread Tim Leslie
On 14 Apr 2007 20:20:42 -0700, Paddy [EMAIL PROTECTED] wrote: On Apr 15, 3:58 am, Steven D'Aprano [EMAIL PROTECTED] wrote: On Sat, 14 Apr 2007 17:33:11 -0800, Troy Melhase wrote: On 4/14/07, Mike [EMAIL PROTECTED] wrote: While trying to write a recursive function involving lists, I came

function with list argument defaulting to [] - what's going on here???

2007-04-14 Thread Mike
While trying to write a recursive function involving lists, I came across some (to me) odd behavior which I don't quite understand. Here's a trivial function showing the problem. def f(l, r = []): for itm in l: r.append(itm) print r a = [1,2,3]

Re: function with list argument defaulting to [] - what's going on here???

2007-04-14 Thread Troy Melhase
On 4/14/07, Mike [EMAIL PROTECTED] wrote: While trying to write a recursive function involving lists, I came across some (to me) odd behavior which I don't quite understand. Here's a trivial function showing the problem. from http://docs.python.org/ref/function.html : Default parameter values

Re: function with list argument defaulting to [] - what's going on here???

2007-04-14 Thread Mike
Thanks, Troy. I never cease to be amazed at what can be discovered by reading the manual! self bangs head on wall Mike Troy Melhase wrote: On 4/14/07, Mike [EMAIL PROTECTED] wrote: While trying to write a recursive function involving lists, I came across some (to me) odd behavior which I

Re: function with list argument defaulting to [] - what's going on here???

2007-04-14 Thread Steven D'Aprano
On Sat, 14 Apr 2007 17:33:11 -0800, Troy Melhase wrote: On 4/14/07, Mike [EMAIL PROTECTED] wrote: While trying to write a recursive function involving lists, I came across some (to me) odd behavior which I don't quite understand. Here's a trivial function showing the problem. from

Re: function with list argument defaulting to [] - what's going on here???

2007-04-14 Thread Alex Martelli
Mike [EMAIL PROTECTED] wrote: ... Why is r not being reset to the empty list on subsequent calls? It seems like it should be reinitialized when not explicitly provided. http://www.python.org/doc/faq/general/#why-are-default-values-shared-be tween-objects Alex --

Re: function with list argument defaulting to [] - what's going on here???

2007-04-14 Thread Paddy
On Apr 15, 3:58 am, Steven D'Aprano [EMAIL PROTECTED] wrote: On Sat, 14 Apr 2007 17:33:11 -0800, Troy Melhase wrote: On 4/14/07, Mike [EMAIL PROTECTED] wrote: While trying to write a recursive function involving lists, I came across some (to me) odd behavior which I don't quite understand.

Re: function with list argument defaulting to [] - what's going on here???

2007-04-14 Thread BJörn Lindqvist
This comes up so often that I wonder whether Python should issue a warning when it sees [] or {} as a default argument. What do people think? A misuse or good use of warnings? I think Python should reevaluate the default values. -- mvh Björn --

Re: function with list argument defaulting to [] - what's going on here???

2007-04-14 Thread Steven D'Aprano
On Sun, 15 Apr 2007 05:29:01 +0200, BJörn Lindqvist wrote: This comes up so often that I wonder whether Python should issue a warning when it sees [] or {} as a default argument. What do people think? A misuse or good use of warnings? I think Python should reevaluate the default values.

Re: function with list argument defaulting to [] - what's going on here???

2007-04-14 Thread Alex Martelli
Steven D'Aprano [EMAIL PROTECTED] wrote: On Sun, 15 Apr 2007 05:29:01 +0200, BJörn Lindqvist wrote: This comes up so often that I wonder whether Python should issue a warning when it sees [] or {} as a default argument. What do people think? A misuse or good use of warnings? I

Re: X class missing in Python :-) - Re: What's going on here?

2006-11-23 Thread robert
John Machin wrote: robert wrote: Dale Strickland-Clark wrote: Python 2.4.2 (#1, Oct 13 2006, 17:11:24) [GCC 4.1.0 (SUSE Linux)] on linux2 Type help, copyright, credits or license for more information. a = object() a object object at 0xb7bbd438 a.spam = 1 Traceback (most recent call

Re: What's going on here?

2006-11-23 Thread Dale Strickland-Clark
Thanks for the answers. I am informed but I don't feel enlightened. It does strike me as odd that an apparently empty subclass should add extra function to the base class. Not at all obvious. -- Dale Strickland-Clark We are recruiting Python programmers. Please see the web site. Riverhall

Re: What's going on here?

2006-11-23 Thread robert
Dale Strickland-Clark wrote: Thanks for the answers. I am informed but I don't feel enlightened. It does strike me as odd that an apparently empty subclass should add extra function to the base class. Not at all obvious. Yes. As said, there is missing a __builtin__.Object object is not

Re: What's going on here?

2006-11-23 Thread Carl Banks
Dale Strickland-Clark wrote: Thanks for the answers. I am informed but I don't feel enlightened. It does strike me as odd that an apparently empty subclass should add extra function to the base class. Not at all obvious. Remember that a class definition is syntax sugar for a direct call to

What's going on here?

2006-11-22 Thread Dale Strickland-Clark
Python 2.4.2 (#1, Oct 13 2006, 17:11:24) [GCC 4.1.0 (SUSE Linux)] on linux2 Type help, copyright, credits or license for more information. a = object() a object object at 0xb7bbd438 a.spam = 1 Traceback (most recent call last): File stdin, line 1, in ? AttributeError: 'object' object has no

Re: What's going on here?

2006-11-22 Thread Scott David Daniels
Dale Strickland-Clark wrote: Python 2.4.2 (#1, Oct 13 2006, 17:11:24) a = object() a.spam = 1 Traceback (most recent call last): File stdin, line 1, in ? AttributeError: 'object' object has no attribute 'spam' class B(object): pass a = B() a.spam = 1 What is subclassing adding to

Re: What's going on here?

2006-11-22 Thread Richie Hindle
What is subclassing adding to the class here? A __dict__: o = object() dir(o) ['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__'] class C(object): pass ... c = C() dir(c)

Re: What's going on here?

2006-11-22 Thread Fredrik Lundh
Dale Strickland-Clark wrote: Why can't I assign to attributes of an instance of object? it doesn't have any attribute storage. /F -- http://mail.python.org/mailman/listinfo/python-list

Re: What's going on here?

2006-11-22 Thread Gerald Klix
Perhaps this piece of code might explain the behaviour: class C( object ): ... __slots__ = () ... o = C() o.a = 1 Traceback (most recent call last): File input, line 1, in ? AttributeError: 'C' object has no attribute 'a' object behaves like having an implict __slots__ attribute.

X class missing in Python :-) - Re: What's going on here?

2006-11-22 Thread robert
Dale Strickland-Clark wrote: Python 2.4.2 (#1, Oct 13 2006, 17:11:24) [GCC 4.1.0 (SUSE Linux)] on linux2 Type help, copyright, credits or license for more information. a = object() a object object at 0xb7bbd438 a.spam = 1 Traceback (most recent call last): File stdin, line 1, in ?

Re: X class missing in Python :-) - Re: What's going on here?

2006-11-22 Thread John Machin
robert wrote: Dale Strickland-Clark wrote: Python 2.4.2 (#1, Oct 13 2006, 17:11:24) [GCC 4.1.0 (SUSE Linux)] on linux2 Type help, copyright, credits or license for more information. a = object() a object object at 0xb7bbd438 a.spam = 1 Traceback (most recent call last): File

Re: what's going on here?

2006-04-04 Thread Ant
You are along the right lines. Try printing out the content of each URL - one of the pages will match your expression, but has additional instructions... I think you are reaching the end of their false trail when you get None returned from the url. The set of pages themselves are the linked list

Re: what's going on here?

2006-04-04 Thread John Salerno
Ant wrote: You are along the right lines. Try printing out the content of each URL - one of the pages will match your expression, but has additional instructions... I think you are reaching the end of their false trail when you get None returned from the url. But the weird thing is that when

Re: what's going on here?

2006-04-04 Thread John Salerno
John Salerno wrote: Ant wrote: You are along the right lines. Try printing out the content of each URL - one of the pages will match your expression, but has additional instructions... I think you are reaching the end of their false trail when you get None returned from the url. But the

Re: what's going on here?

2006-04-04 Thread Roel Schroeven
John Salerno schreef: But thank god I'm passed this problem, although I'm sure it only gets worse now! Yes, I'm afraid it does. I got stuck at puzzle 27 and gave up temporarily. I'm going to try again though when I feel I need a challenge :) -- If I have been able to see further, it was

what's going on here?

2006-04-03 Thread John Salerno
Ok, long story: I'm trying to solve level 4 of the Python Challenge. I hate to post here, but the hint forum over there is dead. Here's the link: http://www.pythonchallenge.com/pc/def/linkedlist.php Apparently you need to use a linked list to solve it, so I read up on them but I still don't

Re: what's going on here?

2006-04-03 Thread John Salerno
John Salerno wrote: Ok, long story Ok, I guess I should have used a better title for the thread. I hope someone still sees this post! :) -- http://mail.python.org/mailman/listinfo/python-list

what's going on here?

2006-03-16 Thread John Salerno
This might be confusing to explain, because it's a question about an example in Beginning Python and I'll try to provide all the info I can. First off, I'm reading a chapter on using the ReportLab modules to create a line graph from a set of data. The first implementation of the program uses a

Re: what's going on here?

2006-03-16 Thread Schüle Daniel
[...] So finally here's my question: If you are using data.append(), doesn't that just put all the numbers into one long list? no, append appends extend does what you think How are the tuples still being created in this case so that the list comprehensions still work? It seems like there

Re: what's going on here?

2006-03-16 Thread Felipe Almeida Lessa
Em Qui, 2006-03-16 às 16:31 +, John Salerno escreveu: So finally here's my question: If you are using data.append(), doesn't that just put all the numbers into one long list? How are the tuples still being created in this case so that the list comprehensions still work? It seems like

Re: what's going on here?

2006-03-16 Thread John Salerno
Felipe Almeida Lessa wrote: # Suppose line is 200412 34.235.233.2 # for our comments # Creates a list, like [2004, 12, 34.2, 35.2, 33.2] splitted = line.split() Thanks guys! I think what I forgot was that split() returns a list, so that's when the 'rows' were being

Re: mod_python: what's going on here?

2005-09-05 Thread Steve Holden
Robert J. Hansen wrote: I'm not entirely certain comp.lang.python is the proper newsgroup for mod_python questions, but comp.lang.python.web doesn't seem to exist, so... my apologies in advance if this is considered off-topic. I'm attempting to get mod_python 3.1.4/python 2.4.1 working on

mod_python: what's going on here?

2005-09-04 Thread Robert J. Hansen
I'm not entirely certain comp.lang.python is the proper newsgroup for mod_python questions, but comp.lang.python.web doesn't seem to exist, so... my apologies in advance if this is considered off-topic. I'm attempting to get mod_python 3.1.4/python 2.4.1 working on Apache 2.0.54 running under OS