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”.
--
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
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]
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
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
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
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
--
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.
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
--
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.
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
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
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
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
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
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
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
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)
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
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.
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 ?
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
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
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
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
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
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
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
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
[...]
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
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
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
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
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
34 matches
Mail list logo