[EMAIL PROTECTED] writes:
I want to calculate f(0) + f(1) + ...+ f(100) over some function f
which I can change. So I would like to create a function taking f as
argument giving back the sum. How do you do that in Python?
You can just pass f as an argument. The following is not the most
Joseph Garvin [EMAIL PROTECTED] writes:
And this way I can keep referring to j instead of myarray[i], but I'm
still forced to use myarray[i-1] and myarray[i+1] to refer to the
previous and next elements. Being able to do j.prev, j.next seems more
intuitive.
Is there some other builtin
Paul Rubin http://[EMAIL PROTECTED] writes:
elts = iter(myarray)
prev,cur,next = elts.next(),elts.next(),elts.next()
for next2 in elts:
do_something_with (prev, cur, next)
prev,cur,next = cur, next, next2
Of course these fail when there's less than 3 elements.
Ehh
[EMAIL PROTECTED] (Bengt Richter) writes:
or if the OP actually wants the specific function,
def sum100a(f): return sum(imap(f, xrange(101)))
...
sum100a(square)
338350
Similarly with generator comprehension, if I have the syntax right:
def sum100c(f): return sum(f(i) for i in
Russell E. Owen [EMAIL PROTECTED] writes:
I disagree. Once you've picked a database (not trivial in itself, of
course), you typically only have a few options for talking to in in
Python. Also, typically either:
- One stands out (because others have been abandoned or whatever), so
there's
Mike Meyer [EMAIL PROTECTED] writes:
What makes me think I need a database is a requirement that says
multiple simultaneous writers.
I'd go a little further and say multiple simultaneous writers doing
multi-step transactions with steps that can have high latency,
e.g. transactions that have to
Paul Rubin http://[EMAIL PROTECTED] writes:
If the transactions are simple and low-latency, then it can be enough
to have a single process own the whole database, and have every client
send all its requests to the db process.
Meant to say: it can be enough to let the clients lock the database
Andy Leszczynski [EMAIL PROTECTED] writes:
Short question: why (1,abc,0.3)+(2,def,10.2) != (3,abcdef,10.5)?
How to elegantly achieve (3,abcdef,10.5) as a result of addition ...
tuple([(a+b) for a,b in zip((1,abc,0.3),(2,def,10.2))])
--
http://mail.python.org/mailman/listinfo/python-list
Mike Meyer [EMAIL PROTECTED] writes:
map(operator.add, (1, abc, 0.3), (2, def, 10.2))
[3, 'abcdef', 10.5]
Not having to do the zip is win. operator.add is a lose. I'm not sure
either is what I'd call elegant.
Yeah, I didn't bother checking whether you could pass dyadic functions
to map.
Tolga [EMAIL PROTECTED] writes:
Is there anybody here interested in artificial intelligence (AI)? Yes,
perhaps this thread would be more suitable for an AI usenet group and I
have also posted my question there, but I want to know Python
community's opinion. Could you recommend me please a good
Luis M. Gonzalez [EMAIL PROTECTED] writes:
Perhaps you can tell us what's the problem with GPL and, if possible,
propose an alternative...
See:
http://www.gnu.org/philosophy/pragmatic.html
--
http://mail.python.org/mailman/listinfo/python-list
Tuvas [EMAIL PROTECTED] writes:
I have an image that is in a raw format,
Do you mean a RAW file from a digital camera? Those files have
complex and sometimes secret formats. Google dcraw.c for a decoding
program that works for many cameras.
--
Kent Johnson [EMAIL PROTECTED] writes:
I chose CherryPy in part because its license allows this. I
would have considered Karrigell if it had a different license.
Have you had to modify CherryPy in some substantive way that you
needed to keep proprietary, as opposed to simply developing content
Kent Johnson [EMAIL PROTECTED] writes:
I did make some changes to CherryPy. I wouldn't mind sharing those
changes back with the CherryPy community. But the product was the
server itself, not the web site. As I understand the GPL the server
software would be a work based on the [GPL-licensed]
Kent Johnson [EMAIL PROTECTED] writes:
You've lost me here. The server certainly would contain Karrigell
code, it wouldn't function without it. I don't understand the analogy
to GCC, the web site is not something that is compiled with
Karrigell. Karrigell is a library or framework that is an
Steve Holden [EMAIL PROTECTED] writes:
However the work I do is commercial and proprietary and I doubt
I could get approval to release it under GPL.
I see the GPL is a problem in this environment, and you are clearly
aware of the issues it raises. Do be aware, though, that not all GPL
Pierre Quentel [EMAIL PROTECTED] writes:
I am Karrigell's author. I have chosen the GPL licence almost at random
(I saw that the Python licence was GPL-compatible), so I don't mind
switching to another Open Source licence if the GPL is liable to cause
problems. Which one would you advice : BSD
Steve Holden [EMAIL PROTECTED] writes:
Indeed. But most software authors aren't lawyers and aren't likely to
trust their own judgment about these matters unless the situation is
pretty unambiguous. I suspect this may be evidence that Microsoft's
viral propaganda has had some effect.
Hmm,
Ben Sizer [EMAIL PROTECTED] writes:
Unfortunately, that doesn't really satisfy the GPL's concerns. The work
arguably contains or is derived from Karrigell,
I don't see that. The web app gets run by Karrigell like a CGI script
is run by Apache, like a Linux app is run by the Linux kernel. The
Richie Hindle [EMAIL PROTECTED] writes:
A good solution would be multiple-licensing. You state that the
code is (for example) triple-licensed under the GPL, LGPL and BSD
licenses. The user of your code decides which license to obey.
It's no more work for you, and you can please almost
Kent Johnson [EMAIL PROTECTED] writes:
Maybe so, but '15'.isdigit() == True:
isdigit(...)
S.isdigit() - bool
Return True if all characters in S are digits
and there is at least one character in S, False otherwise.
Auh!!
--
(Responding to several posts)
Ben Sizer [EMAIL PROTECTED] writes:
I don't see that. The web app gets run by Karrigell like a CGI script
is run by Apache, like a Linux app is run by the Linux kernel.
The web app uses parts of Karrigell though - things like the QUERY
variable or or Session
Erik Max Francis [EMAIL PROTECTED] writes:
The primary purpose of the .isdigit, etc. methods is to test whether a
single character has a certain property. There is, however, no
special character data type in Python, and so by necessity those
methods must be on strings, not characters.
Right,
Tuvas [EMAIL PROTECTED] writes:
What (I think) will happen is when you hit the button, until x=100, the
display will stop updating, and when the command has left it's thread,
it will return to updating again. Is there a way to make it so it
always will update, irreguardless if it's in a
Richie Hindle [EMAIL PROTECTED] writes:
Paul, you keep making comparisons between Python web frameworks and the
Linux kernel. Are you aware that there is a special note attached to the
Linux GPL[1] explaining that user-space code is not considered a derived
work of the Linux kernel? Without
py [EMAIL PROTECTED] writes:
Noah wrote:
You can give up on pickle, because pickle is only
guaranteed to work with the exact same version of the Python
interpreter.
:(
No that's confusing pickle with marshal. Pickle is supposed to work
across versions, though it has recently grown a
[EMAIL PROTECTED] (Aahz) writes:
What's wrong with
def foo():
if False: yield None
Does the following work?
def foo():
raise StopIteration
--
http://mail.python.org/mailman/listinfo/python-list
Jeff Rush [EMAIL PROTECTED] writes:
Your only solution would be a proprietary license that states you
purchased this program and don't have the right to pass it on to
others, similar to ActiveState or somesuch.
It sounds like that's what Kent wants to do with the apps that he's
building.
Robert Kern [EMAIL PROTECTED] writes:
RMS has said precisely the opposite, in fact.
http://lists.debian.org/debian-legal/2002/11/msg00217.html
I guess you mean:
[RMS:]
As for the more general question, we think that a program that uses
Emacs facilities needs to be GPL-covered, but a program
Fredrik Lundh [EMAIL PROTECTED] writes:
no, but all characters in the string belongs to the digit character
class, which is what the is predicates look for.
That description is not quite right. All characters in the empty
string belong to the digit character class, but isdigit returns
false
Fredrik Lundh [EMAIL PROTECTED] writes:
A: are there any blue cars on the street?
B: no. not a single one.
A: you're wrong! all cars on the street are blue!
B and A are both correct. It's just logic ;-).
--
http://mail.python.org/mailman/listinfo/python-list
Kent Johnson [EMAIL PROTECTED] writes:
[a] - [ (hash(a), a) ]
This won't work - elements with different hashes will sort by hash and
elements with the same hash will still be compared which is exactly
what the OP is trying to avoid.
ds = sorted([(hash(c), i) for i,c in enumerate(a)])
dsu =
Dan Stromberg [EMAIL PROTECTED] writes:
I've been using the following compare function, which in short checks, in
order:
1) device number
2) inode number
3) file length
4) the beginning of the file
5) an md5 hash of the entire file
6) the entire file
(If #1 and #2 are identical, then
Steven D'Aprano [EMAIL PROTECTED] writes:
http://www.iusmentis.com/technology/encryption/pgp/pgpattackfaq/hash/
the expected number of random unique files you would need to compare
before finding a single collision in the MD5 hashes is (very roughly)
10**70, or ten billion trillion trillion
Steven D'Aprano [EMAIL PROTECTED] writes:
There are also known ways of deliberately constructing md5 collisions
(i.e. md5 is broken). Whether the OP should care about that depends
on the application.
Sure, but I don't he is deliberately trying to sabotage his own files :-)
He might have
Steven D'Aprano [EMAIL PROTECTED] writes:
How do others handle something like this? What should I be looking for?
I'm after a lightweight solution, if any such thing exists.
Is something stopping you from using sigalarm?
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano [EMAIL PROTECTED] writes:
Is something stopping you from using sigalarm?
Pure ignorance of its existence.
Thanks, I'll check it out.
Two things to keep in mind:
- You can have only ONE alarm pending for the whole process. If
different things in the program need timeouts
Thomas Wouters [EMAIL PROTECTED] writes:
But the odds of such a message having the same MD5 as an existing
song on his disk is quite a lot higher than 2**64, unless he has a really,
really large music collection ;) In the case you propose, two files don't
just need to have the same MD5, but
DarkBlue [EMAIL PROTECTED] writes:
Now our authorized clients register themselves automatically with
computername,id and ip address via a small python script which sends this
information to a firebird database on our server...
Every client has a marker in the hosts.allow file
so if a change
DarkBlue [EMAIL PROTECTED] writes:
The markers are just there to have a static way to find the line
after the marker, which is the one which might have to be changed.
OK, why don't you store those changing lines in the database?
Can you arrange for those changeable lines to be fixed length,
Raven [EMAIL PROTECTED] writes:
Yes I am calculating hundreds of hypergeometric probabilities so I need
fast calculations
Can you use Stirling's approximation to get the logs of the factorials?
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] writes:
does anyone have sample code for scraping the actual url out of an href
like this one
a href=http://www.cnn.com; target=_blank
If you've got the tag by itself like that, just use a regexp to get
the href out.
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] writes:
The problem is that sometimes, depending on which file is the
shorter, a line ends up missing, appearing neither in the izip()
output, or in the subsequent direct file iteration. I would guess
that it was in izip's buffer when izip terminates due to the
exception on
[EMAIL PROTECTED] writes:
But that is exactly the behaviour of python iterator, I don't see what
is broken.
What's broken is the iterator interface is insufficient to deal with
this cleanly.
And because python iterator can only go in one direction, those
consumed do lose in the zip/izip
[EMAIL PROTECTED] writes:
map(None,[1,2,3],[4,5]) gives [(1,4),(2,5),(3,None)]
I didn't know that until checking the docs just now. Oh man, what a
hack! I always thought Python should have a built-in identity
function for situations like that. I guess it does the above instead.
Thanks. Jeez
Diez B. Roggisch [EMAIL PROTECTED] writes:
No. If you want that, use
list(iterable)
Then you have random access. If you _know_ there will be only so much data
needed to unget, write yourself a buffered iterator like this:
You can't use list(iterable) in general because the iterable may be
Michel Sanner [EMAIL PROTECTED] writes:
A google search about GPL and dynamic linking came up with an equal
number of pages saying that dynamic linking of GPL
code into non GPL applications is allowed as it is the end user who
cretes the derived work, as pages saying the opposite ! So does
Dr. Colombes [EMAIL PROTECTED] writes:
I'm looking for a good Python way to generate (enumerate) the 2**N
tuples representing all vertices of the unit hypercube in N-dimensional
hyperspace.
For example, for N=4 the Python code should generate the following 2**N
= 16 tuples:
Here's a
Heiko Wundram [EMAIL PROTECTED] writes:
def perm(n):
rv = []
for i in xrange(2L**n):
cur = []
for j in range(n):
cur.append(1-2*(bool(i (1j
# cur is in reversed order LSB first, but as you seemingly don't
# care about order of the
Raymond Hettinger [EMAIL PROTECTED] writes:
Feel free to submit a feature request to the SF tracker (surprisingly,
this behavior has not been previously reported, nor have there any
related feature requests, nor was the use case contemplated in the PEP
discussions:
Raven [EMAIL PROTECTED] writes:
The problem with Stirling's approximation is that I need to calculate
the hypergeometric hence the factorial for numbers within a large range
e.g. choose(14000,170) or choose(5,2)
Stirling's approximation to second order is fairly accurate even at
low values:
[EMAIL PROTECTED] writes:
All these web technologies I don't know where to start, have you got
any suggestions for getting started in the world of web development,
books maybe ?
This is out of date but may help get started.
http://philip.greenspun.com/panda/
--
Michael Spencer [EMAIL PROTECTED] writes:
for i in range(10):
result = []
...
Do you mean while True: ...?
def izip2(*iterables, **kw):
kw:fill. An element that will pad the shorter iterable
fill = repeat(kw.get(fill))
Yet another attempt (untested, uses
[EMAIL PROTECTED] writes:
def izip4(*iterables, **kw):
kw:fill. An element that will pad the shorter iterable
kw:infinite. Number of non-terminating iterators
That's a really kludgy API. I'm not sure what to propose instead:
maybe some way of distinguishing which iterables are
Paul Rubin http://[EMAIL PROTECTED] writes:
# quit if only discardables are left
dropwhile(lambda i,t: (not isinstance(i, Discardable)) and len(t)),
izip(t, iterables)).next()
Ehh, that should say dropwhile(lambda (t,i): ...) to use tuple
unpacking and get
[EMAIL PROTECTED] [EMAIL PROTECTED] writes:
Is there some easy way to somehow perhaps embed a minimal web server in
a Python tar ball
Yes, sure, see any of the HTTP server classes in the stdlib.
Just listen on a localhost socket and pop a browser to point to that socket.
--
Steven D'Aprano [EMAIL PROTECTED] writes:
def izip5(*iterables, fill=None):
Doesn't work: keyword arguments must be listed before * and ** arguments.
Eh, ok, gotta use **kw.
def function(*iterators, **kwargs):
if kwargs.keys() != [fill]:
raise ValueError
...
It
Martin v. Löwis [EMAIL PROTECTED] writes:
To my knowledge, ctypes has never been contributed to Python,
either, so its author apparently has no plan, either.
Has anyone from Python.org asked him or her?
--
http://mail.python.org/mailman/listinfo/python-list
Neil Hodgson [EMAIL PROTECTED] writes:
No. It is the responsibility of the extension author to ensure
that there is no possibility of crashing Python. With ctypes, you have
a generic mechanism that enables Python code to cause a crash.
http://docs.python.org/lib/module-dl.html
would seem
Steven D'Aprano [EMAIL PROTECTED] writes:
Duh. Next time I use a dictionary before freezing an API!
Can you please explain what you mean by that? Use a dictionary how?
Use a dictionary by looking up words in it to check the spelling.
--
http://mail.python.org/mailman/listinfo/python-list
Claudio Grondi [EMAIL PROTECTED] writes:
The question is if Python allows somehow access to the bytes of the
representation of a long integer or integer in computers memory?
No it doesn't, and that's a good thing, since the internal
representation is a little bit surprising (it stores 15 bits
[EMAIL PROTECTED] writes:
hi, does anyone know of any package that will download a full site for
offline viewing? It will change all url to match local urls and follow
a logical structure (the site's structure would be suffice).. Please
tell me if you have heard of such a package.. thanks alot
Heiko Wundram [EMAIL PROTECTED] writes:
I know this, and that's one of the reasons I'm a little at odds with Python
3000... some things are so basic (such as
xrange) I wouldn't want to have to implement them every time I need such a
beast.
Itertools.count could be extended to replace xrange.
Harlin Seritt [EMAIL PROTECTED] writes:
I would like to take milliseconds and convert it to a more
human-readable format like:
4 days 20 hours 10 minutes 35 seconds
# To iterate is human; to recurse, divine.
def dhms(m,t):
if not t: return (m,)
return rl(m//t[0], t[1:]) + (m % t[0],)
Paul Rubin http://[EMAIL PROTECTED] writes:
def dhms(m,t):
if not t: return (m,)
return rl(m//t[0], t[1:]) + (m % t[0],)
Editing error, sigh. Meant of course to say
return dhms(m//t[0], t[1:]) + (m % t[0],)
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] writes:
below you find my simple python version of MD2 algorithm
as described in RFC1319 (http://rfc1319.x42.com/MD2).
It produces correct results for strings shorter than 16 Bytes and wrong
results for longer strings.
Why do you want to use MD2? It's very slow and it's
Raymond Hettinger [EMAIL PROTECTED] writes:
I am evaluating a request for an alternate version of itertools.izip()
that has a None fill-in feature like the built-in map function:
map(None, 'abc', '12345') # demonstrate map's None fill-in feature
I think finding different ways to write it
[EMAIL PROTECTED] writes:
I want to understand it, and -- therefor ;-) -- I want to implement it
in pure Pyhton.
OK. It should be pretty easy to implement. You should find the
official rfc at ietf.org. I remember there was some minor erratum in
the original version that may or may not have
Raymond Hettinger [EMAIL PROTECTED] writes:
The generator version is plain, simple, boring, and uninspirational.
But it took only seconds to write and did not require a knowledge of
advanced itertool combinations. It more easily explained than the
versions with zip tricks.
I had this cute
[EMAIL PROTECTED] writes:
I thought I had build a proper implementation in Python. The error you
mention can be avoided by studying the C implementation in RFC 1319.
BUT: Some of the test vectors failed. That's my problem ;-(
And therefore I asked for help.
You might check PyCrypt against the
[EMAIL PROTECTED] writes:
Already done before my first posting. But the problem was there. I
studied the C sources of MD2 of that package, too. But all test cases
with more than 16 bytes failed.
Hmm, did the test cases work for the RFC 1319 reference code? What
about OpenSSL?
I thought when
Paul Rubin http://[EMAIL PROTECTED] writes:
Hmm, did the test cases work for the RFC 1319 reference code? What
about OpenSSL?
I just checked OpenSSL and all the test values it computes match the RFC.
--
http://mail.python.org/mailman/listinfo/python-list
Raymond Hettinger [EMAIL PROTECTED] writes:
iterator = check_empty(iterator)
There are so many varieties of iterator that it's probably not workable
to alter the iterator API for all of the them. In any case, a broad
API change like this would need its own PEP.
The hope was that it
Scott David Daniels [EMAIL PROTECTED] writes:
Recently there was a checkin of a test that _should_ work but
doesn't. The discussion got around to means of indicating such
tests (because the effort of creating a test should be captured)
without disturbing the development flow.
Do you mean
Fredrik Lundh [EMAIL PROTECTED] writes:
no, he means exactly what he said: support for expected failures
makes it possible to add test cases for open bugs to the test suite,
without 1) new bugs getting lost in the noise, and 2) having to re-
write the test once you've gotten around to fix the
Hallvard B Furuseth [EMAIL PROTECTED] writes:
'except None:' works for now, but I don't know if that's safe:
for ex in ZeroDivisionError, None:
try:
1/0
except ex:
print Ignored first exception.
class NeverRaised(Exception): pass
for ex in
Hallvard B Furuseth [EMAIL PROTECTED] writes:
class NeverRaised(Exception): pass
for ex in ZeroDivisionError, NeverRaised:
Heh. Simple enough. Unless some obstinate person raises it anyway...
Hmm, ok, how's this?:
def NeverRaised():
class blorp(Exception): pass
return blorp
Brian Cole [EMAIL PROTECTED] writes:
This is obviously the least efficient manner to do this as I'll always
be iterating over the entire 'strs'. I know I could make a binary tree
out of 'strs' but that's a little more work that don't have time to do
today. I know there should be something out
Szabolcs Nagy [EMAIL PROTECTED] writes:
there are iterators which has length:
i = iter([1,2,3])
len(i)
3
now isn't there a way to make this length inheritible?
I expect that's a __len__ method, which can be inherited.
eg. generators could have length in this case:
g = (x for x in
Andrew Koenig [EMAIL PROTECTED] writes:
Can anyone think of an easy technique for creating an object that acts like
a generator but has additional methods?
For example, it might be nice to be able to iterate through an associative
container without having to index it for each element.
Donn Cave [EMAIL PROTECTED] writes:
But you're asking for more than that. We're not just talking
about how people think about value, you want a definition that's
suitable for a language reference. Whereupon you would indeed
run into the kinds of questions you pose above, and more.
I know
[EMAIL PROTECTED] writes:
Got any ideas how that is to be accomplished short of jiggering the
names so they sort in the order you want them to run?
How about with a decorator instead of the testFuncName convention,
i.e. instead of
def testJiggle(): # test in the func name means it's a
Robin Becker [EMAIL PROTECTED] writes:
f([(x0,y0),(x1,y1),]) -- [x0,y0,x1,y1,]
import operator
a=[(1,2),(3,4),(5,6)]
reduce(operator.add,a)
(1, 2, 3, 4, 5, 6)
--
http://mail.python.org/mailman/listinfo/python-list
Paul Rubin http://[EMAIL PROTECTED] writes:
import operator
a=[(1,2),(3,4),(5,6)]
reduce(operator.add,a)
(1, 2, 3, 4, 5, 6)
(Note that the above is probably terrible if the lists are large and
you're after speed.)
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] writes:
First, can dictionaries contain dictionaries?
Yes.
Second, how to create each successive inner dictionary when populating
it? Python doesn't have constructors and (having all of 4 weeks of
Python experience) it isn't clear to me whether in nested while loops
that
Peter Hansen [EMAIL PROTECTED] writes:
My information about digest was either obsolete or simply wrong, as I
didn't realize it had all the nonce and anti-replay support it appears
to have. (I may have been remembering articles about how much of that
wasn't supported widely at some time in the
Mike Meyer [EMAIL PROTECTED] writes:
Only if the userid and password are part of the content. If you're
doing the usual form-based authentication, then they are. If you're
doing an HTTP-based authentication, then they aren't - the
authentication information is in the headers, and can be
Antoon Pardon [EMAIL PROTECTED] writes:
There is a use case for things like 1 (1,3) making sense and denoting
a total order. When you have a hetergenous list, having a total order
makes it possible to sort the list which will make it easier to
weed out duplicates. So why don't you demand a
Robin Becker [EMAIL PROTECTED] writes:
reduce(operator.add,a)
...
A fast implementation would probably allocate the output list just
once and then stream the values into place with a simple index.
That's what I hoped sum would do, but instead it barfs with a type
error. So much for duck
Steve Holden [EMAIL PROTECTED] writes:
Underlining your point, the difference between the two is that digest
offers *strong* authentication (i.e. is not subject to replay attacks)
As I mentioned in another post, that's really not enough, since digest
still exposes the password hash to offline
[EMAIL PROTECTED] writes:
Still, I'd love to hear how you guys would do it.
Make a subclass of dict, or an object containing a dictionary, that
has a special __setattr__ method that traps updates and sets that
modification flag. There are contorted ways the caller can avoid
triggering the flag,
Robert Hilkene [EMAIL PROTECTED] writes:
Can any body help, I wanna to hide input characters from user (when he
enters password)?
http://docs.python.org/lib/module-getpass.html
--
http://mail.python.org/mailman/listinfo/python-list
Antoon Pardon [EMAIL PROTECTED] writes:
The bisect module doesn't have an alternate comparison function
neither has the heapqueue module.
They could be extended. Care to enter a feature request?
1) Python could provide a seperare total ordering, maybe with operators
like '|' and '|' and
Brian van den Broek [EMAIL PROTECTED] writes:
It's broken in at least one way:
newmd = ModFlagDict(3=4, 1=5)
SyntaxError: keyword can't be an expression
newmd = ModFlagDict(**{3:4, 1:5})
--
http://mail.python.org/mailman/listinfo/python-list
Sion Arrowsmith [EMAIL PROTECTED] writes:
sum(sequence, start=0) - value
If you're using sum() as a 1-level flatten you need to give it
start=[].
Oh, right, I should have remembered that. Thanks. Figuring out
whether it's quadratic or linear would still take an experiment or
code
Steve Holden [EMAIL PROTECTED] writes:
Make a subclass of dict, or an object containing a dictionary, that
has a special __setattr__ method that traps updates and sets that
/__setattr__/__setitem__/ ?
Yes, thinkographical error. Thanks.
--
Amit Khemka [EMAIL PROTECTED] writes:
import signal
TIMEOUT = 5 # number of seconds your want for timeout
signal.signal(signal.SIGALRM, input)
signal.alarm(TIMEOUT)
def input():
try:
foo = raw_input()
return foo
except:
# timeout
return
This doesn't work with raw_input
Raymond Hettinger [EMAIL PROTECTED] writes:
I see at least a few cases of
map(None, field_names, values)
but it's not clear what the expectation is for the size of the two lists.
...
Thanks for the additional datapoint. I'm most interested in the code
surrounding the few cases with
Tim Chase [EMAIL PROTECTED] writes:
The closest hack I could come up with was
import random
s = abcdefg
a = []
a.extend(s)
random.shuffle(a)
s = .join(a)
You could use
import random
s = list(abcdefg)
random.shuffle(s)
s
Nick Craig-Wood [EMAIL PROTECTED] writes:
of is decrementing a reference count. Only one thread can be allowed to
DECREF at any given time for fear of leaking memory, even though it will
most often turn out the objects being DECREF'ed by distinct threads are
themselves distinct.
401 - 500 of 4752 matches
Mail list logo