programs. Any ideas?
If you were running under unix I'd suggest you "strace" the process to
see what it is doing. There are windwows strace programs (which I've
never tried) too!
You'll probably find it is wedged in TCP socket code.
--
Nick Craig-Wood <[EMAIL
t; Python users. TIA
Go for it! Python is such an easy language to write stuff in
(escpecially compared to C++) that you'll have the prototype done very
quickly and you can evaluate the rest of your concerns with working
code!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
f doing things. It can't race under
unix at least (dunno about windows) unless your dir is on NFS.
If you want more security then make sure dir isn't publically
writeable.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
gt;
> You can do this under Linux as follows:
>
> os.readlink("/proc/%d/fd/%d" % (os.getpid(), fileno))
A good idea! You can write this slightly more succinctly as
os.readlink("/proc/self/fd/%d" % fileno)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Erik Jones <[EMAIL PROTECTED]> wrote:
> front, last = l[:len(l) - 1], l[len(l) - 1]
Normally written as
front, last = l[:-1], l[-1]
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
a go at fixing it!
Try editing zipfile.py and getting it to print out some debug info and
see if you can fix the problem. When you have done submit the patch
to the python bug tracker and you'll get that nice glow from helping
others! Remember python is open source and is made by *us* for *us
. ''' and ''' (if you normally use
""" """ for docstrings)
Python just ignores strings that lie around.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Robert Marshall <[EMAIL PROTECTED]> wrote:
> On Fri, 09 Mar 2007, Bruno Desthuilliers wrote:
>
> >
> > Nick Craig-Wood a ?crit :
> >> [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >>> What if 2 new 'special' comment-like character
t goes round the while loop on average 0.5 times.
If 0 isn't required then just test for it and go around the loop again
if found. That of course skews the distribution in difficult to
calculate ways!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http:/
ert data into dictionary
You could try Construct
http://construct.wikispaces.com/
This allows you to build a python class which will translate to and
from that datastructure.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
quot;ls -l")
6
>>> s.prompt()
True
>>> print s.before
ls -l
total 30944
-rw-r--r-- 1 user user 936 Nov 3 14:52 #z.c#
[snip]
-rw-r--r-- 1 user user 221 Jan 30 11:51 z~
>>> s.logout()
>>>
I'm using the debian packaged version 2.1-1 with python 2.4
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
any fragmentation worries.
However if you have lots of small allocations then the heap will be
fragmented and you'll never be able to return the memory to the OS.
However that is why we have virtual memory systems.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
password, eg...
$ svn ls svn+ssh://[EMAIL PROTECTED]/svn /dev/null 2>&1
Password:
I don't know exactly how it does that but I suspect it is to do with
the controlling terminal...
On my system
$ setsid svn ls svn+ssh://[EMAIL PROTECTED]/svn /dev/null 2>&1
Pops up a gui box askin
ss platform way!
>From my experiments with timeouts I suspect it won't be possible to
implement it perfectly in python 2.5 - maybe we could add some extra
core infrastructure to Python 3k to make it possible?
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/ni
; command as ordinary user.
>
> The workaround your ping command is using btw, is probably running
> suid root.
Under linux the only priviledge you need is CAP_NET_RAW. It is
possible to give this to a process - a bit of searching with google
will show you how!
--
Nick Craig-Wood <[EM
Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> On Mon, 26 Mar 2007 16:50:33 +0200, Thomas Dybdahl Ahle <[EMAIL PROTECTED]>
> wrote:
> >Den Mon, 26 Mar 2007 06:30:04 -0500 skrev Nick Craig-Wood:
> >> Under linux the only priviledge you need is CAP_NET_RAW. It i
to kill one thread from another thread. There is a
ctypes hack to do it, which sort of works... It needs some core
support I think.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
James Stroud <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> > Did anyone write a contextmanager implementing a timeout for
> > python2.5?
> >
> > I'd love to be able to write something like
> >
> > with timeout(5.0) as exceeded
Klaas <[EMAIL PROTECTED]> wrote:
> On Mar 26, 3:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> > Did anyone write a contextmanager implementing a timeout for
> > python2.5?
> >
> > I'd love to be able to write something li
interrupt. It may be possible - under unix you'd send a signal -
which python would act upon next time it got control back to the
interpreter, but I don't think it would buy us anything except a whole
host of problems!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Hendrik van Rooyen <[EMAIL PROTECTED]> wrote:
> "Nick Craig-Wood" <[EMAIL PROTECTED]> wrote:
> > Hendrik van Rooyen <[EMAIL PROTECTED]> wrote:
> > > But would be useful to be able to do without messing with
> > > threads and GUI
Hendrik van Rooyen <[EMAIL PROTECTED]> wrote:
> "Nick Craig-Wood" <[EMAIL PROTECTED]> wrote:
>
> > Well, yes there are different levels of potential reliability with
> > different implementation strategies for each!
>
> Gadzooks! F
lp you, as you are single-threaded here. The
> released lock won't prevent the called C-code from taking as long as it
> wants. |And there is nothing you can do about that.
I'm assuming that the timeout function is running in a thread...
--
Nick Craig-Wood <[EMAIL PROTECTED
Hendrik van Rooyen <[EMAIL PROTECTED]> wrote:
> "Nick Craig-Wood" <[EMAIL PROTECTED]> wrote:
>
> > I'd like there to be something which works well enough for day to day
> > use. Ie doesn't ever wreck the internals of python. It could ha
John Nagle <[EMAIL PROTECTED]> wrote:
> Diez B. Roggisch wrote:
> > Nick Craig-Wood wrote:
> >
> >
> >>Did anyone write a contextmanager implementing a timeout for
> >>python2.5?
> >>
> >>And have it work reliably and in a c
ramming Perl" that Larry Wall said it was
a serious mistake to add this feature to perl.
If it is a feature too far for perl then it is *definitely* a feature
too far for python ;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
use of preexec_fn is
preexec_fn=os.setsid
You seem to be thinking it is pre-pending something to your command
line which isn't how it works.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
y.is_prime(2**607-1)
1
>>> gmpy.is_prime(2**608-1)
0
Cheating perhaps! Note is_prime will be a probabalistic test for
large numbers...
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
er qemu
and do native builds.
Cross compilers work well though - we build our app which has python
embedded for ARM using a cross compiler running under debian.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Gigs_ <[EMAIL PROTECTED]> wrote:
> does anyone know some good tutorial for unittest? (with examples
> how unit work)?
There is one in Dive into Python
http://www.diveintopython.org/unit_testing/index.html
Buy the book is my advice!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -
Unix Environment) needed to implement it is rather
disconcerting! A python module to do it would be great!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ntry point to the local LAN, but would be harder to do
> if there are two points of entry, and packets could hit from
> outside on either..
It is all done in the kernel. The kernel has the state of the TCP
connection - it is just accessed from a different process.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
>>> mpq(1,3)+0.6
mpq(14,15)
>>> mpq(5,2)
mpq(5,2)
>>> mpq(1,3)*mpq(6,10)*mpq(4,10)+mpq(7,8)
mpq(191,200)
>>>
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
> processor families are truly multi-core, and which are HT.
On any unix/posix system (OSX and linux should both qualify) you can use
>>> import os
>>> os.sysconf('SC_NPROCESSORS_ONLN')
2
>>>
(From my Core 2 Duo laptop running linux)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
raise NotImplementedError
There is a bug in that code...
NotImplementedError will never be raised because num won't have been
set. It will raise "UnboundLocalError: local variable 'num'
referenced before assignment" instead
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ode, plus a sequence of steps to be followed to
replicate the problem and you'll get some real help. The above is
just too vague.
The above code has a syntax error in it so obviously isn't from
working code.
PS I really doubt the problem is windows not seeing the created file...
--
Nick
've actually typed "f.close" rather
> > than "f.close()",
>
> You are right, I forgot the () in f.close() !
> thanks for pointing that out.
>
> VB programmer!? Thats really harsh..
I used to make that mistake a lot as an ex-perl programmer.
application in Qt on Mac, Win or Linux look like a
> native app.
I'd recommend wxPython over those becase
1) native look and feel on all platforms
2) doesn't require expensive licensing for non-commercial apps (QT)
3) Isn't a pain to install on windows (GTK)
That said, times change an
return math.exp(-n)*(n**(n-0.5))*math.sqrt(2*math.pi)*(1. + 1./12/n +
1./288/n**2 - 139./51840/n**3)
Works for non integer factorials also...
See here for background
http://mathworld.wolfram.com/StirlingsSeries.html
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.cr
e a program to demonstrate the problem?
You are best off reporting bugs here - then they won't get lost!
http://bugs.python.org/
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
etty
>
> Removing this (or just disabling it for the user who must run the
> cron job) should eliminate the error. Note that you will also need
> to disable authentication either via the NOPASSWD tag or the
> "authenticate" Defaults option.
Check the PATH in cron also
--
:
number = myNumer[:]
random.shuffle(number)
if number == myNumer:
count+=1
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
e written out if dirty
and then dropped.
The OS will try to keep hold of pages as long as possible just in case
you need them again. The pages dropped should be the least recently
used pages.
I wouldn't have expected a MemoryError though...
Did you do mmap.flush() after writing?
--
Nick C
a MemoryError. It is asking for
a new bit of memory and it is failing so it throws a MemoryError.
Could memory allocation under windows be affected by a large chunk of
mmap()ed file which is physically swapped in at the time of the
allocation?
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- h
r there is something
going on in your program that we don't know about or there is a bug
somewhere, either in the OS or in python.
Can you make a short program to replicate the problem? That will help
narrow down the problem.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-
under windows you get a quite different
result :-
>>> from time import clock, time
>>> print clock(), time()
7.54285810068e-006 1169574534.84
>>> print clock(), time()
3.32073322168 1169574538.16
>>> print clock(), time()
7.32428004118 1169574542.15
ot;
total = x
power = x
divisor = 1
old_delta = None
while 1:
power *= x
power *= x
power = -power
divisor += 2
old_total = total
total += power / divisor
delta = abs(total - old_total)
if old_delta is not None and
016001
>>> start = cpu_time(); f(); dt = cpu_time() - start; print dt
0.012001
>>> start = cpu_time(); f(); dt = cpu_time() - start; print dt
0.008001
You'll see the result is quantised to 4 ms (not sure what the .01
bits are about!)
4ms is the clock rate of this machine,
it would be more elegant...
>>> n = 1
>>> for i in range(16):
... print ("%X" % n).replace('0', ' ').replace('1', '*')
... n = n ^ (n << 4)
...
*
**
* *
* *
** **
* * * *
* *
** **
* * * *
* * * *
** ** ** **
* * * * * * * *
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
nd for this -- perhaps another way to
> access the values of those RTLD flags?
Read stuff out of /usr/include/bits/dlfcn.h ?
It seems to be a constant 1 anyway
#define RTLD_LAZY 0x1
You could try compiling the dl module by hand.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http
John Pye <[EMAIL PROTECTED]> wrote:
> On Feb 19, 6:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> > John Pye <[EMAIL PROTECTED]> wrote:
> > > application from running on the Debian Etch AMD64 platform.
> > > It seems that the 'dl' mo
by a dummy request, which seems a bit awkward.
Can't you get SocketServer to timeout and return you control
regularly?
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
eError: can only concatenate list (not "tuple") to list
>>>
Ie
x += a
does not equal
x = x + a
which it really should for all types of x and a
(That is the kind of statement about which I'm sure someone will post
a perfectly reasonable counterexample ;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Delaney, Timothy (Tim) <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
>
> > x += a
> >
> > does not equal
> >
> > x = x + a
> >
> > which it really should for all types of x and a
>
> Actually, this will *never* be t
see
that in a daemonize recipe before?
> else:
> # time for child to die
> os._exit(0)
> else:
> # wait for child to die and then bail
> os.wait()
> sys.exit()
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
r own GUI in pygame
to do exactly what you want for your embedded device.
> I'm not really sure what the differences are between those two. The
> latter seems to be a little more active.
Pygame is the way I've always done SDL stuff in python - never even
heard of PySDL!
-
p
I've used py2exe and nsis quite a few times - works well.
Note that py2exe can bundle your app into a single exe which you can
just run which may be good enough (no need for an installer).
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
instances (about 1,000,000 in our case) and adding __slots__
to it!
I'd guess that if you __slot__-ed the Domain class then you'll find
the overhead of a type attribute is minimal (4 bytes per instance I
think).
No idea about Hessian or Stomp (never heard of them!) but classes with
__s
, "credits" or "license" for more information.
>>> from sqlite3 import dbapi2
>>> import sqlite3
>>> set(dir(sqlite3)) ^ set(dir(dbapi2))
set(['__path__', 'dbapi2'])
>>>
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
python expect module to work around these
problems. Unfortunately there isn't a windows version :-(
You could try the non blocking subprocess modification here
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554
You could also try wx.Process and wx.Execute from wxPython.
--
Nic
ines += 1
total += len(line)
print "Received %d lines of %d bytes total" % (lines, total)
#
Which runs like this on my machine
$ python subprocess-shell-nb.py
waiting on child...
waiting on child...
waiting on child...
waiting
latform (using a shared QT) and see how much extra RAM it uses.
> is there an exaample of going thru a passworded proxy using twisted
> client classes? i have trouble understanding how to adapt the
> proxy example on page 58 in the twisted book to my needs.
I advise looking at
quot;"
print >>sys.stderr, globals()['__doc__']
print >>sys.stderr, error
sys.exit(1)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
at
> those few posted code lines.
Actually any number >= 2**31 won't fit in a python int.
>>> 2**31
2147483648L
According to my headers DWORD is defined like this
typedef unsigned long DWORD;
So you might see longs returned when you expected ints if the result
was >= 0x800.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Hendrik van Rooyen <[EMAIL PROTECTED]> wrote:
> "Nick Craig-Wood" wrote:
> > So you might see longs returned when you expected ints if the result
> > was >= 0x800.
>
> did you mean 0x8000 ?
>
> ;-)
Yes - well spotted!
--
Nick Crai
r stuff comes all after the stdout stuff.
> How can I get ahold of all the out and err joined synchronously in the
> order, it is created ?
You need to either
1) change myapp to fflush() more often
2) investigate the python pty module to fool the app into thinking it
is talking to a termi
t this:
>
> series = [x/2 for x in range(200, 1, -1)]
That should be
series = [x//2 for x in range(200, 1, -1)]
to be "from __future__ import division" safe
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
(spread)
This is simpler, easier to prove correct and most likely quicker.
def distribution(N=2):
L = [ random.uniform(0,1) for _ in xrange(N) ]
sumL = sum(L)
return [ l/sumL for l in L ]
spread = distribution(10)
print spread
print sum(spread)
--
Nick Craig-Wood <[EMAIL PROTECTED
i)
m = Matcher()
t = 'blue socks and red shoes'
if m.search(r'(blue|white|red)', t):
print "Colour:", m[1]
elif m.search(r'(socks|tights)', t):
print "Garment:", m[1]
elif m.search(r'(boot|shoe|trainer)', t):
print "
sn't look so scary as 5k-10k LOC in Python.
I bet your C code doesn't have unit tests either... Make sure you
write those as you are going along in Python. It will make more code,
but it will give you a wonderful feeling of confidence that your code
will actually work, and
esn't
matter!
> The following quote sums things up nicely I think:
>
> "In theory there is no difference between theory and practice, but in
> practice there is."
;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
You might want to show him this too...if you happen to need cnt in the
loop, this is what you write
files = [a,b,c,d]
for cnt, fi in enumerate(files):
do_something(cnt, fi)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
d I have to close it.
> I cannot find the reason. Can somebody give me a hint to let it work
> well? Thanks
I tried it but it doesn't work at all on linux.
I suggest you use wxPython and stop re-inventing the wheel!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wo
>>> print a, b
[5, 6, 7] [5, 6, 7]
Using keywords[:] stops the creation of another temporary list. The
other behaviour may or may not be what you want!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
>
> > Using keywords[:] stops the creation of another temporary list.
>
> in CPython, "list[:] = iter" actually creates a temporary list object on
> the inside, in case "iter"
0118 kb downloaded 21.304672.1 kBytes/s
Sleep for 0.497982025146
40 kb of 10118 kb downloaded 19.979510.1 kBytes/s
Sleep for 0.497948884964
48 kb of 10118 kb downloaded 19.184721.1 kBytes/s
Sleep for 0.498008966446
...
1416 kb of 10118 kb downloaded 16.090774.1 kBytes/s
Sleep for 0.499262094498
1424
ursion depth exceeded
16 16 maximum recursion depth exceeded
17 False
[snip]
89 False
90 90 maximum recursion depth exceeded
91 False
92 False
93 93 maximum recursion depth exceeded
94 False
95 False
96 96 maximum recursion depth exceeded
97 False
98 False
99 99 maximum recursion depth exceeded
--
N
which becomes
effectively part of the OS. The package manager tracks every file it
installes to ensure ovewrites can't happen etc...
/usr/local/bin is for stuff installed from source, not using the
package manager.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
bject
the ftphandler code relies on.
I see you attempt to kill the ftp server with ftpd.stop(). That is
good, but you don't wait for the thread to finish (it might take up to
a second in ftpd.server_forever if I understand correctly).
I expect if you put a self.join() at the end of the stop() method the
problem will go away.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
> production of Debian packages using distutils.
Looks interesting though!
> [1] http://stdeb.python-hosting.com/
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
n't
that hard).
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ine)
This iterates over the lines of all files listed in sys.argv[1:],
defaulting to sys.stdin if the list is empty. If a filename is '-', it
is also replaced by sys.stdin. To specify an alternative list of
filenames, pass it as the first argument to input(). A single file
name is also allowed.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
or list size 1000
Read back 1000 items in 0.000352478027344 s
Written 50005 bytes for list size 1
Read back 1 items in 0.00165479183197 s
Written 55 bytes for list size 10
Read back 10 items in 0.0175776958466 s
Written 505 bytes for list size 100
Read back 100 i
'dummy' would both be OK.
As for me personally, I usually use '_' but sometimes use 'dummy'
depending on the surrounding code.
Note that this idiom is fairly common in python too
wanted, _, _, _, also_wanted = a_list
which looks quite neat to my eyes.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
tances.
The syntax isn't so great when you set things which aren't valid
keywords though...
eg
{ (1,2,3) : 'a', (4,5,6) : 'b' }
vs
dict([ ((1,2,3), 'a'), ((4,5,6), 'b') ])
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
n__.Y object at 0xb7d9fc2c>]
[<__main__.Y object at 0xb7d9fc8c>]
(It behaves slightly differently in the interactive interpreter for
reasons I don't understand - so save it to a file and try it!)
In fact I find most of the times I wanted __del__ can be fixed by
using a weakref.WeakValueDictionary or weakref.WeakKeyDictionary for a
much better result.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
20 job gets only 4%.
I think you are on to a loser here trying to normalise it across
OSes unfortunately :-(
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
this code? I looked
at the examples but I couldn't see one? Having a simple nameserver
written in python would be very useful indeed...
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
TimeHorse <[EMAIL PROTECTED]> wrote:
> On Feb 22, 4:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> > Interestingly enough this was changed in recent linux kernels.
> > Process levels in linus kernels are logarithmic now, whereas before
> > they weren'
sing the ptrace
interface.
Both those things will require the relevant rights and neither is
quite as easy as you might hope for!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
above and the original proposal
class InfiniteLoopError(Exception):
"""An 'infinite' loop has been detected"""
def infinite_loop(max=200):
for i in xrange(max):
yield i
raise InfiniteLoopError()
Use it like this
for i in infinite_loop():
if i > 10:
break
print "iteration", i
or
for i in infinite_loop(10):
print "iteration", i
> but I agree with Tim that a for ... else loop for the limit is
> clearer.
Probably yes
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
; Where is my fault?
You didn't (or you didn't show) defining the argument types of the
function.
myclib = CDLL("myclib.so") # or whatever
myclib.myfunction.argtypes = [ POINTER(INTERFACE) ]
myclib.myfunction.restype = c_int # or whatever
If you do that then you should be able to pass in myiface directly or
byref(myiface).
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
t):
cls.registry[cls.__name__] = cls
class ThingOne(BaseThing):
pass
class ThingTwo(BaseThing):
pass
class ThingThree(BaseThing):
pass
print BaseThing.registry["ThingOne"]
print BaseThing.registry["ThingTwo"]
print BaseThing.registry["ThingTh
Thread(target=test_lock_process,
args=(lock,i,queue,)))
for t in threads:
t.start()
for t in threads:
t.join()
if print_result:
try:
while True: print queue.get(block=False)
except Empty:
pass
if __name__ == "__
ossible to fix to me. I'd love to
be proved wrong though!
If you were thinking of passing time.time() /
clock_gettime(CLOCK_MONOTONIC) along in the Queue too, then you'll
want to know that it can differ by significant amounts on different
processors :-(
Good luck!
--
Nick Craig-Woo
t; raise Exception("Record not found")
>
>
> def changeRecord(self, record, type, target):
> """
> Changes a dns entry.
> @param record: which record to chance
> @param type: what type of record, A
flagg wrote:
> On Feb 3, 7:32?am, Nick Craig-Wood wrote:
> > flagg wrote:
> > > ?This xmlrpc server is designed to parse dns zone files and then
> > > ?perform various actions on said files. \
> > > ?It uses dnspython, and xmlrpclib
> > > ? I
t. It then uses that new
compiler to compile a gcc for the target architecture.
I could imagine a similar scheme for python, but it would involve lots
of fiddling about and some commitment from the python maintainers.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
kurt.forrester@googlemail.com wrote:
> Any ideas on how to suppress the warning output:
> __main__:1: Warning: No data - zero rows fetched, selected, or
> processed
You can use the warnings module to suppress these I would have
thought.
--
Nick Craig-Wood -- http://www.craig
debian, ubuntu and centos packages for it if you
look!
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
501 - 600 of 861 matches
Mail list logo