es
of fd_set objects in select() calls.)
You will want to redesign the code that finds or creates a free
"FILE" object, and probably some of the things that work with
line-buffered FILEs (specifically calls to _fwalk() when reading
from a line-buffered stream).
--
In-Real-Life: Chris T
istinguish between a valid -1 value and
having encountered an EOF. The companion ferror() function tells
you whether an earlier EOF value was due to an error.)
--
In-Real-Life: Chris Torek, Wind River Systems
Intel require I note that my opinions are not those of WRS or Intel
Salt Lake City, UT, USA
>Chris Torek writes:
>[snip]
>> when you have [an] instance and call [an] instance or class method:
[note: I have changed the names very slightly here, and removed
additional arguments, on purpose]
>> black_knight = K()
>> black_knight.spam()
>> black
lot of CPython interpreter
overhead. Mileage in Jython, etc., may vary...
--
In-Real-Life: Chris Torek, Wind River Systems
Intel require I note that my opinions are not those of WRS or Intel
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out)
sion. :-)
--
In-Real-Life: Chris Torek, Wind River Systems
Intel require I note that my opinions are not those of WRS or Intel
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.p
rget(*self.args, **self.kwargs)
def join(self, timeout = None):
"join, then return value set by target function"
super(ValThread, self).join(timeout)
return self.value
--
In-Real-Life: Chris Torek, Wind River Systems
Intel require I note that my opinions are not those of WRS or Intel
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
r:
print 'name "magic" is not available here, as desired'
try:
print rlevel
except NameError:
print 'name "rlevel" is not available here, as desired'
class X(object):
def __mrap(self, *args, **kwargs):
def xset(arg):
se
W0622: 2:func: Redefining built-in 'list'
...
Your code has been rated at 6.67/10
If your shadowing is done on purpose, you can put in a pylint
comment directive to suppress the warning.
Pylint is the American Express Card of Python coding: "don't leave
$HOME without
ure would be nice to have a static analysis
tool that could answer questions about potential exceptions. :-) )
--
In-Real-Life: Chris Torek, Wind River Systems
Intel require I note that my opinions are not those of WRS or Intel
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277
ot;@classmethod" or "@staticmethod", but
the minor redundancy in the "def" statement seems, well, minor.
Also, as a bonus, it lets you obfuscate the code by using a name
other than "self" or "cls". :-)
--
In-Real-Life: Chris Torek, Wind River Systems
Intel require I note that my opinions are not those of WRS or Intel
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
ever here, by making those attributes "read-only" to
whatever extent the snapshot operation is defined as fixing the
binding (e.g., does it recurse into sub-attributes? does it bind
only the name-and-type, or does it bind name-and-type-and-value,
or name-and-type-and-function-address-if-fu
with Ben Finney though, and so does "import this":
...
Simple is better than complex.
...
Letting exceptions flow upward unchanged is (usually) simpler,
hence "better".
--
In-Real-Life: Chris Torek, Wind River Systems
Intel require I note that my opinions a
ist.append(Florg('fifth', 5))
for florg in flist:
florg.zormonkle()
if __name__ == '__main__':
example()
--
In-Real-Life: Chris Torek, Wind River Systems
Intel require I note that my opinions are not those of WRS or Intel
Salt Lake City, UT, USA (40°39.22&
mply writes:
lst.append(val)
(which also makes sure that there is *room* in the array-based
list, something that requires a separate step in C).
--
In-Real-Life: Chris Torek, Wind River Systems
Intel require I note that my opinions are not those of WRS or Intel
Salt Lake City, UT, USA (
-)
(Of course, +i followed by +i *also* increments i...)
--
In-Real-Life: Chris Torek, Wind River Systems
Intel require I note that my opinions are not those of WRS or Intel
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
perations,
though, the problem becomes NP-complete.
See http://pages.cs.brandeis.edu/~shapird/publications/JDAmoves.pdf
for instance. (They give an algorithm that produces "usually
acceptable" results in polynomial time.)
--
In-Real-Life: Chris Torek, Wind River Systems
Intel require I
#x27;big2'))
you will get two md5sum values for your two files, but the
md5sum value for big2 will not be the equivalent of "md5sum big2"
but rather that of "cat big1 big2 | md5sum". The reason is
that you are re-using the md5-sum-so-far on the second call
(for file &
ithout using import" but all you have to
do is arrange for python to import this module before running
any of your own code, e.g., with $PYTHONHOME and a modified
site file.
--
In-Real-Life: Chris Torek, Wind River Systems
Intel require I note that my opinions are not those of WRS or Intel
Sa
your own mkstemp() (this can be a bit of a challenge!).
Finally, as I implied above in talking about the os.link()-then-
os.rename() sequence, if the original file has multiple links to
it, note that this "breaks the links". If this is not what you
want, the problem has no fully general solut
al
for x in (
'1',
'1.00',
'1.23400e-8',
'0.003'
):
print 'sigdig(%s): %d' % (x, sigdig(D(x)))
--
In-Real-Life: Chris Torek, Wind River Systems
Intel require I note that my opinions are not those of WRS or Intel
Salt Lake City,
ent (not expression) has the form:
and the evaluation order is, in effect and using pseudo-Python:
1. -- the (single) RHS
tmp = eval()
2. for in : # left-to-right
= tmp
When there is only one item in the (i.e., just one
"x =" part in the whole stateme
>Chris Torek wrote:
>> I can then check the now-valid
>> pid via os.kill(). However, it turns out that one form of "trash"
>> is a pid that does not fit within sys.maxint. This was a surprise
>> that turned up only in testing, and even then, only because I
&g
the
above into an iterator, and handling container classes that have
an __iter__ callable that produces an iterator that defines an
appropriate index-and-value-getter, is left as an exercise. :-) )
--
In-Real-Life: Chris Torek, Wind River Systems
Intel require I note that my opinions are not those of W
In article <96gb36fc6...@mid.individual.net>,
Gregory Ewing wrote:
>Chris Torek wrote:
>
>> Oops! It turns out that os.kill() can raise OverflowError (at
>> least in this version of Python, not sure what Python 3.x does).
>
>Seems to me that if this happens it ind
== '__main__':
d = {'one': 1, 'two': 2, 'three': 3}
l = [9, 8, 7]
print 'modify dict %r' % d
for i in IndirectIter(d):
i.set(-i.get())
print 'result: %r' % d
print
print 'modify list %r' % l
while r == 0:
yield p
if q == 1:
return
num = q
q, r = divmod(num, p)
if __name__ == '__main__':
for arg in (sys.argv[1:] if len(sys.argv) > 1 else ['600851475143']):
try:
arg = int(arg)
ex
>On Tue, 21 Jun 2011 01:43:39 +0000, Chris Torek wrote:
>> But how can I know a priori
>> that os.kill() could raise OverflowError in the first place?
In article <4e006912$0$29982$c3e8da3$54964...@news.astraweb.com>
Steven D'Aprano wrote:
>You can't. Even i
came from, but note that on
Unix, the "os" module also provides os.WIFSIGNALED, os.WTERMSIG,
os.WIFEXITED, and os.WEXITSTATUS for dissecting the "status"
integer returned from the various os.wait* calls.
Again, if you use the subprocess module, you are insulated from
this sort of det
between child and parent here.
However, it would suffice to set subprocess.__exceptions__ to some
reasonable tuple, and leave the preexec_fn exceptions to the text
documentation. [Of course, strictly speaking, the fact that the
read cuts off at 1 MB means that even the pickle.loads() call might
fail! B
n classes that are only defined in
user-provided code -- but to raise them, those functions have to
include whatever code defines them, so I think this all just works.)
The key thing needed to make this work, though, is the base cases
for system-provided code written in C, which pylint by definitio
efore, you can subscript the return value to get either
element:
>>> divmod(99.6,30.1)[0]
3.0
Thus, you can call bool() on the subscripted value to convert
this to True-if-not-zero False-if-zero:
>>> bool(divmod(99.6,30.1)[0])
True
--
In-Real-Life: Chris Torek,
ight also want to take a look at PEP 302:
http://www.python.org/dev/peps/pep-0302/
If you use "subprocess" to run program B, it cannot affect program
A in any way that program A does not allow. This gives you a lot
more control, with the price you pay being that you need to open
some
dler(filehandler)
del logging.Logger.manager.loggerDict[self.logger.name]
del self.logger # optional
I am curious as to why you create a new logger for each thread.
The logging module has thread synchronization in it, so that you
can share one log (or several logs) amongst all threads
ng trick if that is necessary:
a[:] = merge_sorted(a, sorted(b), must_copy = False)
If list b is already sorted, leave out the sorted() step. If list
b is not sorted and is particularly long, use b.sort() to sort in
place, rather than making a sorted copy.
--
In-Real-Life: Chris Torek, Wind
epending on your data and other needs, though, it might be best
to use a red-black tree, an AVL tree, or a skip list. You might
also investigate radix sort, radix trees, and ternary search trees
(again depending on your data).
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, U
w.bitsavers.org/pdf/univac/1100/UE-637_1108execUG_1970.pdf
(Those of you who have never had to deal with these machines, as I
did in the early 1980s, should consider yourselves lucky. :-) )
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
; x.__reduce__()
(, (, , None), {'name': 'janet', 'substitute': False})
which is of course the same as:
>>> object.__reduce__(x)
(, (, , None), {'name': 'janet', 'substitute': False})
which means that CPython
In article
Chris Angelico wrote:
>If order and duplicates matter, then you want a completely different
>diff. I wrote one a while back, but not in Python. ...
If order and duplicates matter, one might want to look into
difflib. :-)
--
In-Real-Life: Chris Torek, Wind River Systems
Sal
whatever the
equivalent is for Windows) "eating" the wrong subprocess completion
notifications, but that one is harder to solve in general :-) so
if close_fds fixes things, it was just the pipes. If close_fds
does not fix things, you will probably need to defer the pool.close()
step until a
>On 03/06/2011 03:58, Chris Torek wrote:
>>> -
>> This is a bit surprising, since both "s1 in s2" and re.search()
>> could use a Boyer-Moore-based algorithm for a sufficiently-long
>> fixed string, and the time
dot?
I type them in this way sometimes, when poking at network issues. :-)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
rom what is written -- is useful.
As an interesting aside, even without the re.VERBOSE flag, one can
build complex, yet reasonably-understandable, REs in Python, by
breaking them into individual parts and giving them appropriate
names. (This is also possible in perl, although the perl syntax
ma
>> On Mon, Jun 6, 2011 at 8:54 AM, Chris Torek wrote:
>>> A signalling NaN traps at (more or less -- details vary depending on
>>> FPU architecture) load time.
>On Mon, 06 Jun 2011 09:13:25 +1000, Chris Angelico wrote:
>> Load. By this you mean the operation o
ht or
close-to-right per the (draft? final? I have not kept up with
decimal FP standards) standard. Internal Python floating point,
not quite so much.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
.
In article <94svm4fe7...@mid.individual.net>
Neil Cerutti wrote:
[lots of snippage]
>That is the opposite of my experience, but YMMV.
I suspect it depends on how familiar the user is with regular
expressions, their abilities, and their limitations.
People relatively new to REs
ere's a huge benefit to everybody following the rule.
This analogy perhaps works better than expected. Whenever I swap
between Oz or NZ and the US-of-A, I have a brief mental clash that,
if I am not careful, could result in various bad things. :-)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
llowing:
Warning: The Connection.recv() method automatically unpickles
the data it receives, which can be a security risk unless you
can trust the process which sent the message.
Therefore, unless the connection object was produced using Pipe()
you should only use the recv() and send() methods after performing
some sort of authentication. See Authentication keys.
(i.e., do that :-) -- see the associated section on authentication)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
>In article ,
> Chris Torek wrote:
>> Python might be penalized by its use of Unicode here, since a
>> Boyer-Moore table for a full 16-bit Unicode string would need
>> 65536 entries (one per possible ord() value).
In article
Roy Smith wrote:
>I'm not sure what
e values, a 256-element
table suffices; re.compile(), at least, could scan the pattern
and choose an appropriate underlying search algorithm.
There is an interesting article here as well:
http://effbot.org/zone/stringlib.htm
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
key)
...
Seems pretty straightforward. :-) Are you having some sort
of problem with "del"?
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
th 2**100 in each. (You will run out of memory first
unless you have a machine with more than 64 bits of address space. :-) )
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
"NextClass.method", *your* class
is definitely *not* ready for someone else to use in that MI
situation.
(I say "may" be ready for MI, because being "fully MI ready" requires
several other code discipline steps. The point of super() -- at
least when implemented nicely, as
>Chris Torek wrote:
>> In at least some versions of Python 2
[the "file"-type object iterators behave badly with pipes]
(This may still be true in Python 3, I just have no experience with
Py3k. "At least some version of Python 2" means "the ones I have
acc
imal, and complex, so that you do not need to worry about whether
to use math.isnan() vs cmath.isnan()? (I almost never work with
complex numbers so am not sure if the "or" behavior -- cmath.isinf
and cmath.isnan return true if either real or complex part are
Infinity or NaN respectivel
quot;)
(Of course, if something like this were adopted properly, it would
all be in the base "float" type anyway.)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.t
o on, do not
quite work right in all cases), with some performance penalty on
non-conformant hardware.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
e it as an actual
client and server, i.e., the client connects to the server and
writes the request directly (but then you have to decide about
security considerations, which the OS's local file system may
provide more directly).
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake Cit
pen(["ping", "-c5", "www.google.com"],
stdout = subprocess.PIPE)
for lineno, line in enumerate(line_at_a_time(p.stdout)):
if 1 <= lineno <= 5:
print line.split()[6]
else:
print line.rstrip('\n')
p.wait() # disca
special-case purposes at least) too. Of course a simple "classify
this float as one of normal, subnormal, zero, infinity, or NaN"
operator would suffice here (along with the usual "extract sign"
and "differentiate between quiet and signalling NaN" operations).
--
ion is
to call accept() on the listening socket it closed just before
it called self._talk_to_client().
If that socket is closed, you get an EBADF error raised. If not,
the child and parent compete for the next incoming connection.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
args.directory:
clean_dir(dirname, args.days)
def clean_dir(dirname, n_days):
"""
Clean one directory of files / subdirectories older than
the given number of days.
"""
time_to_live = n_days * 86400 # 86400 = seconds-per-day
current_time =
ck.
That *would* be a valid way to implement a timeout -- to return with
the condition variable lock itself no longer held -- but that would
require changing lots of other code structure.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
>Chris Torek wrote:
>> >>> x = [3, 1, 4, 1, 5, 9, 2, 6]
>> >>> list(set(x))
>> This might not be the best example since the result is sorted
>> "by accident", while other list(set(...)) results are not.
In article ,
Duncan Booth
e', 'five']
>>> x
['three', 'one', 'four', 'one', 'five']
>>> list(set(x))
['four', 'five', 'three', 'one']
>>> sorted(list(set(x)))
['five
turns the canonical bool
>values:
>
>not returns False
>not returns True
>
>Take note of the distinction between lower-case true/false, which are
>adjectives, and True/False, which are objects of class bool.
(At least as of current versions of Python -- in much older versions
here the result is defined as equivalent.
(The biggest problem with answering that tends to be deciding
what types x might take.)
[% Chocolate with raspberry, or mint, or similar.]
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
called (if ever), and so on. As
>with the Python-named-Monty, we have "rigidly defined areas of
>doubt and uncertainty". These exist for good reasons: to allow
>different implementations.
Oops, attribution error: this comes from Douglas Adams rather
than Monty Python.
--
In-R
is not promised, for instance, whether the "is" operator
is always True for small integers that are equal (although it is
in CPython), nor when __del__ is called (if ever), and so on. As
with the Python-named-Monty, we have "rigidly defined areas of
doubt and uncertainty". These
; be True
rather than False.
[% This is not at all obvious -- I have written an immutable class,
and it is pretty easy to accidentally mutate an instance inside
the class implementation. There is nothing to prevent this in
CPython, at least. If there were a minor bug in the decimal.Decimal
code suc
t; import subprocess
>>> p = subprocess.Popen('/tmp/echo $MYVAR', stdout=subprocess.PIPE)
>>> print p.communicate()[0]
this is a self-printing file
anything after the first line has NR > 1, so gets printed
>>> p.returncode
0
>&g
aluation just long enough:
self.assertRaises(AttributeError, lambda: c.foo)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
best of 3: 2.29 usec per loop
(It is easy enough to move the assignments to a and b into the -s
argument, but it makes relatively little difference since the list
comprehension and two-zip methods both have the same setup overhead.
The "import", however, is pretty slow, so it is not g
instance,
but then you run into the fact that math.isnan() is only in 2.6 and
later :-)
Workaround, assuming an earlier "from math import *":
try:
isnan(0.0)
except NameError:
def isnan(x): x != x
Of course you are still stuck with float('nan') faili
maxsize, backup_count)
fh.setFormatter(logging.Formatter(g.log_format))
except IOError, e:
logger.error('log to file: %s', e)
errs = True
fh = g.file_logger
i
an repeat the "import"
else:
print 'I am confused, maybe I got the wrong pid'
---
The same kind of thing can be done on other OSes, but all the details
will differ.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
log and sleep here
raise mailbox.ExternalClashError # or whatever
and now instead of dest.lock() you just do a dest.retried_lock().
Plumbing (including fitting this in as a context manager so
that you can just do "with dest" or some such) is left as an
exercise, :-)
--
s their dependencies.
# By indexing by cell, we can find cells from dependencies in visit().
for row in sheet:
for cell in row:
if cell:
r.S[cell] = cell
cell.visited = False
# Now simply (initial-)visit all the cells.
for cell i
the corresponding arguments were PIPE). In fact, thinking about it
now, I *would* argue that.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
iple-quote, this trivial
encoding technique will fail. (And of course, as others have noted,
it fails on some systems that distinguish betwen text and binary
file formats in the first place.) This is why using some
"text-friendly" encoding scheme, such as base64, is a good idea.
--
In-Real
read = stdin
else:
# Assuming file-like object
p2cread = stdin.fileno()
(this is repeated for stdout and stderr) and the resulting
integer file descriptors (or None if not applicable) are
passed to os.fdopen() on the parent side.
(On the child side, the code does the usual shell-like dance
to move the appropriate descriptors to 0 through 2.)
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
to
have _cleanup() read:
if inst.poll(_deadstate=sys.maxint) is not None:
(Note, this is python 2.5, which is what I have installed on my
Mac laptop, where I am writing this at the moment).
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
finally:
> fileobject.close()
>
>So you can sure `fileobject.close()` is called in *any* case.
Unfortunately "with" is newish and this code currently has to
support python 2.3 (if not even older versions).
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City,
field:
>>> x = SoLongAndThanksForAllTheFish('RIP DNA')
>>> x.message
'RIP DNA'
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: gmail (figure it out) http://web.torek.net/torek/index.html
--
http://mail.python.org/mailman/listinfo/python-list
think this is more a bug than a feature, you can always insert
assert statements in key locations, e.g.:
assert 'foo' not in inst.__class__.__dict__, \
'overwriting class var "foo"'
(you can even make that a function using introspection, although
it could
make copy of list and append something
f(new_arg, some_list + [elem])
elif other_condition:
# continue modifying same list
f(new_arg, some_list)
...
(Note: you can use also the fact that list1 + list2 produces a new
list to make a copy by writ
xy connection) to us,
# which reaches our dispatcher above. By registering this in
# our __init__, clients can do "if server:" to see if their
# connection is up. It's a frill, I admit
def __nonzero__(self):
return True
def register_admin_func
uot;""
iterable = iter(vec)
acc = iterable.next()
yield acc
for x in iterable:
acc = op(acc, x)
yield acc
def cumsum(vec):
"""Return a list of the cumulative sums of a vector."""
import operator
return list(iaccumulate(vec
87 matches
Mail list logo