pi in 0.1 seconds and 10,000 digits in 20 seconds.
"""
Standalone Program to calculate PI using python only
Nick Craig-Wood <[EMAIL PROTECTED]>
"""
import sys
from time import time
class FixedPoint
)
def pi_ferguson():
return 4*(3*arctan(_1/4) + arctan(_1/20) + arctan(_1/1985))
def pi_hutton():
return 4*(2*arctan(_1/3) + arctan(_1/7))
def pi_gauss():
return 4*(12*arctan(_1/18) + 8*arctan(_1/57) - 5*arctan(_1/239))
def pi_euler():
return 4*(5*arctan(_1/7) + 2*arctan(_3/79))
t?
You might want to check out this modification to subprocess which does
non-blocking pipes.
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554
I personally think something like that should be built into subprocess
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.crai
he python way of
enforcing self.member is much cleaner and never comes back to bite you!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
c/2.4.2/lib/module-subprocess.html
You'll probably find threading easier though.
http://www.python.org/doc/2.4.2/lib/module-threading.html
But it will use your multiple CPUs less efficiently than fork()-ing.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
__(self):
# FIXME is there a way to convert a long to binary?
content = ""
if self.i:
L = []
i = self.i
while i:
L.append(int(i & 1L))
i >>= 1
L.reverse()
content = str(L)
luca72 <[EMAIL PROTECTED]> wrote:
> Thanks for your help, but it don't solve the problem.
> I receive only the echo and full stop.
Try swapping pins 2 and 3 in the lead.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/
Peter Hansen <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> > luca72 <[EMAIL PROTECTED]> wrote:
> >
> >> Thanks for your help, but it don't solve the problem.
> >> I receive only the echo and full stop.
> >
> > Try swapping
yfile","w")
>>> fn=fd.write
>>> fn.im_self
Traceback (most recent call last):
File "", line 1, in ?
AttributeError: 'builtin_function_or_method' object has no attribute 'im_self'
>>> fn.__self__
>>>
I wonder why?
Is there a canonical way of doing it?
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
d be a little better
> able to use them appropriately.
;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
loped at the moment...
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
10 0.39
11 0.4
12 0.4
13 0.39
14 0.4
15 0.4
16 0.39
17 0.4
18 0.39
19 0.41
Note the first iteration is slower as it builds the tuple cache
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
retched up to 4k and M_MMAP_THRESHOLD was set to 4k then
you'd have the perfect memory allocator...
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
rying to achieve and we
can see if we can come up with a more pythonic solution? The fact
that you are running into limits of the language like this as a new
python programmer probably means you aren't thinking in python yet.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
rceforge.net/
Doesn't work on windows. Looks like you are doing OS X though so
should work fine there
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
finished or not, and no way to wait
on more than one Process() at once.
If there is an exception then you should return it to the parent (see
the subprocess module for an example).
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
d
deliver SIGPIPE to the child which may (or may not) kill it. At least
it got some sort of notification.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
here some place I can
> submit this as a feature request? (Python dev?)
The non-blocking subprocess would make a good start for a stdlib
submission.
It should really optionally use ptys under unix too otherwise you'll
never be able to script passwd etc. An interface a bit like pexpect
wpuld be useful too (ie scan for these regexps or timeout and return a
match object).
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
oriented buffer. You don't want block buffering
> on interactive applications.
Pty's probably aren't needed on Windows.
BTW I'd love to see pexpect working on windows and also in the
standard library. It is the proper answer to controlling other
interactive processes IMHO.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
dmoore <[EMAIL PROTECTED]> wrote:
> On Jun 8, 12:30 pm, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> > Windows has a really strange idea of non-blocking IO - it uses
> > something called overlapped io. You or in the FILE_FLAG_OVERLAPPED
> > flag when you create
e()
>>> open('lock.txt').read()
'ho'
>>>
The best cross platform way to create a lock is creating a directory.
It is atomic on both windows and linux anyway.
try:
os.mkdir("lock")
except OSError:
print "locked!"
else:
try:
do_stuff()
finally:
os.rmdir("lock")
(untested)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
You need flock under unix (this recipe shows windows flock equivalent also)
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65203
or use the directory idea I posted in another post.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ix locking method. Note that it may not
work if you are writing the lock file to an NFS mount!
Traditionally you write your os.pid() to the file also. You can then
send a signal to the running copy, detect stale lock files etc.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Tim Williams <[EMAIL PROTECTED]> wrote:
> On 18/06/07, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> On Windows the open-a-file-for-writing method works well, but as *nix
> doesn't work the same way then maybe the socket solution is the best
> cross-platform option
ch seperate "type"
a seperate class type and implement the methods for each one. All the
switches will disappear from your code like magic!
Post more details if you want more help!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ceforge.net/tracker/index.php?func=detail&aid=1163563&group_id=5470&atid=105470
> Is there any simple way to fix this damned bug??
Locking, locking and more locking ;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
(defaults)
self._sections = odict()
self._defaults = odict()
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
3.jpg 4.jpg 01.pdf
Which resizes each image to a max dimension of 1000 pixels and then
tiles them into a PDF.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
programs and system servers to the
minimum amount of privilege they require to do their jobs. When
confined in this way, the ability of these user programs and system
daemons to cause harm when compromised (via buffer overflows or
misconfigurations, for example) is reduced or eliminated.
--
memory_usage import memory
from cPickle import load
before = memory()
z = load(open("z.bin", "rb"))
after = memory()
print "Memory used to unpickle is %s kB" % (after-before)
print "Total size of repr(z) is ",len(repr(z))
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
algorithms if you want something for making a hash table. They make
very bad cryptographic hash generators since they are linear and thus
easily forgeable. That said you aren't going to be doing any serious
crypto with only 16 bits.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
mmands in os, ie os.setpgid and os.getpgid.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
te character).
b) That is a logical consequence of a)
> Note also that a single backslash followed by a newline is
> interpreted as those two characters as part of the string, not
> as a line continuation.
As I'd expect.
If we removed a) then we could remove b) also a
t; SyntaxError: EOL while scanning single-quoted string
> > >>> r"\ "
> > '\\ '
>
> One slash escapes the following character, so the proper way of
> writing it is either
>
> r"\\" or r"\""
I don't think so.
7;'
'\'"'
>>>
Neil is correct in saying that his example works for regexp matching
though, as the regexp matcher understands \" as being the same as ".
So r"" strings work well as Regexp-strings but not so well as
Raw-strings IMHO.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
behavior I want? (If you haven't guessed, I want a list of (no
> parameter) functions, each of which returns its index in the list.)
This is the traditional way :-
>>> x = [ lambda ind=ind: ind for ind in range(10) ]
>>> x[0]()
0
>>> x[2]()
2
>
d normally. With only a few
lines of extra code, Pyro takes care of the network communication
between your objects once you split them over different machines on
the network. All the gory socket programming details are taken care
of, you just call a method on a remote object as if it were a l
hinks it's HTML.
I suspect the former - we noticed exactly the same thing (can't
remember which tags we were having problems with), using the
declaration :-
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
I haven't tested this again recently though.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
s one way communication - it isn't
good at conversations. I'd suggest pexpect but it doesn't work on
windows.
You appear to be doing stuff with csound. There are several python
modules out there which interface with csound - did you investigate
those?
--
Nick Craig-Wood <
Miles <[EMAIL PROTECTED]> wrote:
> On Jul 9, 4:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> > Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> > > On Sun, 08 Jul 2007 22:23:20 +0200, Jan Danielsson wrote:
> > > >Fire
OK, but a bit clunky. it does
have the advantage that it is built into the language though.
> Do you think Python is the right language for these projects?
Yes!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
use pexpect which will connect to your prog with pseudo-ttys
I recommend c) - subprocess isn't really very good at interactive
conversations between the main process and the subprocess - buffering
will cause you problems. You may in this simple case get it to work
with a) or b) though!
--
Nick C
reduce(lambda x,y: x and (y>=10), counts):
break
continue
print "Child Process %d terminated, restarting" % i
processes[i] = Popen('sleep 1', shell=True, cwd='/home',
stdout=file(os.devnull,'w'))
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
False = False
If you want to do algebra with bools in python then use the logical
operators (and or not) and not the arithmetical operators.
Eg
>>> False or not True
False
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> b = dumps(a).encode("zip").encode("base64").strip()
>>> b
'eJzTyCkw5PI04Er0NARiIyA2BmITIDYFYjMgNgdiCyC25ErUAwD5DQqD'
>>> loads(b.decode("base64").decode("zip"))
[0, 1, 2, 3, 4, 5, 6, 7
same as 2**(3*2) or 2**6=64.
>
> Just for curiosity: This helps to find the answer to the problem "Which is
> the largest number that can be written with only 3 digits?"
> Some people stop at 999, others try 99**9 and 9**99, and the winner is
> 9**9**9, or:
Actually
Jason Zheng <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> > The problem you are having is you are letting Popen do half the job
> > and doing the other half yourself.
>
> Except that I never wanted Popen to do any thread management for me to
> begin wi
Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood <[EMAIL PROTECTED]> writes:
>
> >> I think your polling way works; it seems there no other way around this
> >> problem other than polling or extending Popen class.
> >
> > I thi
o poke
object code onto the heap which implements the method call to that
particular instance.
Looking at this page might give you some ideas
http://gcc.gnu.org/onlinedocs/gccint/Trampolines.html
This probably isn't a good approach in reality though as it is very
architecture / compiler depend
he cost of a bit of speed.
http://pyro.sourceforge.net/manual/9-security.html#pickle
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
e via subprocess) then it will buffer stuff as
you've seen.
So you can
a) modify the c++ prog to add fflush() in or use setvbuf()
b) use the pexpect module - http://pexpect.sourceforge.net/
c) use the pty module (unix only)
The pexpect module will connect to the subprogram with pseudo-ttys,
fool
en
> there is actual contention for a resource and you want to block when a
> resource is not available).
I'd dispute that. If you are communicating between threads use a
Queue and you will save yourself thread heartache. Queue has a non
blocking read interface Queue.get_nowait().
Josiah Carlson <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> > I'd dispute that. If you are communicating between threads use a
> > Queue and you will save yourself thread heartache. Queue has a non
> > blocking read interface Queue.get_nowait().
>
gt;> import os
>>> os.system("ls -l z")
-rw-r--r-- 1 ncw ncw 45010006 Apr 19 18:43 z
0
>>>
Indicating each float took 9 bytes to store, which is 1 byte more than
a 64 bit float would normally take.
The pickle dump / load each took about 2 seconds.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
x27;, '..', 'cdslib_cleanup.py', 'cadence.py', 'cdsinit_cdsenv_cleanup.py')
>>> b='("." ("cadence.py" "foo_cleanup.py") "cdslib_cleanup.py" "cadence.py"
>>> "cdsinit_cdsenv_cleanup.py")'
>>> eval(b.replace('" "', '", "').replace('" (', '", (').replace(') "', '), "'))
('.', ('cadence.py', 'foo_cleanup.py'), 'cdslib_cleanup.py', 'cadence.py',
'cdsinit_cdsenv_cleanup.py')
>>>
It made tuples rather than lists but I expect that won't matter.
Someone normally chimes in with pyparsing at this point...
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
why it "usually"
> works (and often enough not). This for example won't work:
>
> >>> False or '' and 0
> ''
You can use this if you want it to be bullet proof
(a and [b] or [c])[0]
Not exactly elegant though!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
00\x02\x00\x00\x03\x00\x00\x00\x00\x04\x00\x00'
>>>
You might also want to consider Construct
http://construct.wikispaces.com/
>From the web page: Construct is a python library for parsing and
building of data structures (binary or textual). It is based on the
concept of d
lding extensions. Using the
windows python build in a windows command windows always works though
(with mingw as the compiler).
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
actual = 1.02E-04
expected = 1.00E-05 actual = 1.19E-05
expected = 1.00E-06 actual = 2.66E-06
on my 250 HZ machine
You could then do run-time calibration to work out the overhead of the
function on any given machine to make it more accurate.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ave a shared library
(.so or .dll).
You'll end up writing python code rather than C code which you'll
enjoy!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Bart <[EMAIL PROTECTED]> wrote:
> What about C module with usleep,nanosleep?
Unlikely to help! It is an linux OS limit that the minimum sleep time
is 1/HZ.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ral things with twisted. It takes a bit of getting your
head round but you'll be impressed with the speed.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
nity.
c) the python keywords are in ASCII/English. I hope you weren't
thinking of changing them?
...
In summary, I'm not particularly keen on the idea; though it might be
all right in private. Unicode identifiers are allowed in java though,
so maybe I'm worrying too much ;-)
;, pipe.stdout.read()
---zz.py
#!/usr/bin/python
import sys
print >>sys.stdout, "Stdout"
print >>sys.stderr, "Stderr"
--------
Produces
$ ./z.py
Without shell
e else have any useful comments about python vs java
> without starting a flame war.
You'll be a lot more productive writing python code in my experience
so if development time is important to you, then go with python.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
001799'\np1\n."
>>> pickle.dumps('1001799')
"S'1001799'\np0\n."
>>> pickle.loads(pickle.dumps('1001799'))
'1001799'
>>> pickle.loads(cPickle.dumps('1001799'))
'1001799'
>>> cPickle.loads(pickle.dumps('1001799'))
'1001799'
>>> cPickle.loads(cPickle.dumps('1001799'))
'1001799'
>>>
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
mbda x: (dec2bin(x/2) + str(x%2)) if x else ''
>
> This is awesome. Exactly what I was looking for. Works for other
> bases too.
Just don't pass it a negative number ;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
) the leading candidate is to copy and paste the whole frigging
> zipfile module so I can patch it, but that's even uglier than it is
> stupid. "This battery is pining for the fjords!"
You don't need to do that, you can just "monkey patch" the _EndRecData
Martin Maney <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> > You don't need to do that, you can just "monkey patch" the _EndRecData
> > function.
>
> For a quick & dirty test, sure. If I were certain I'd onl
j in locals().values():
try:
if issubclass(obj, Definition):
objects.append(obj)
except TypeError:
pass
objects_sorted = sorted(objects, key=lambda x: x._class_sequence)
print objects
# Gives something like
# [, , , , , ]
print objects_sorted
# Gives
# [, , , , , ]
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
he moment and a python-mt
build which has the GIL broken down into a lock on each object.
python-mt would certainly be slower for non threaded tasks, but it
would certainly be quicker for threaded tasks on multiple CPU
computers.
The user could then choose which python to run.
This would of
g with binary data. I am looking for a any
> one with experience or ideas on the subject. Pointers any one?
Check out construct: http://construct.wikispaces.com/
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Bjoern Schliessmann <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> [GIL]
> > That is certainly true. However the point being is that running
> > on 2 CPUs at once at 95% efficiency is much better than running on
> > only 1 at 99%...
>
> How do you de
a very small
amount of time creating a dict you don't use.
$ python -m timeit '{}'
100 loops, best of 3: 0.247 usec per loop
On my machine 250 ns gets you a new dict...
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
mulate a perl hash then you would
want this which does the above but recursively.
from collections import defaultdict
class hash(defaultdict):
def __init__(self):
defaultdict.__init__(self, hash)
D=hash()
D[1][2][3][4]=5
D[1][4][5]=6
print D
--
Nick Craig-Wood <[EMA
27;ve got the 2nd edition.
Lutz concentrates on TK programming using classes, making re-usable
components which I found really helpful compared to the ad-hoc way I'd
seen TK presented previously.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
thout wishing to start a flame war, is there a way to do this in Python?
"""
for para in re.split(r"\.\n", input_data):
print "para = %r" % para
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
cording to python library reference, .Z file might not be
> supported by python, yet.
Unfortunately the python gzip library doesn't read .Z files.
I'd pipe the data to zcat using subprocess to decompress from python.
I haven't used a .Z files for many many years - where are you
total used free sharedbuffers cached
Mem: 1036396 587296 449100 0392 91284
# echo 3 > /proc/sys/vm/drop_caches
# free
total used free sharedbuffers cached
Mem: 1036396 588228 448168
eno()
3
>>> libc.readahead(f.fileno(), 0, 0x100)
0
>>>
(That example could do with more ctypes magic to set the types and the
return type of readahead...)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood <[EMAIL PROTECTED]> writes:
>
> > If you are running linux > 2.6.18 then you can use
> > /proc/sys/vm/drop_caches for exactly that purpose.
> >
> > http://www.linuxinsight.com/proc_sys_vm_dr
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
201 - 300 of 641 matches
Mail list logo