'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.
project?
Regards,
Craig
--
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
On Oct 6, 2007, at 11:31 PM, goldtech wrote:
> Can anyone link me or explain the following:
>
> I open a file in a python script. I want the new file's location to be
> on the user's desktop in a Windows XP environment. fileHandle = open
> (., 'w' ) what I guess I'm looking for is an enviro
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
> 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
is sent to the plant operator's pager. Because of the nature
of the alarm system, extensive field testing was out of the question.
Unit testing was the only way to ensure it worked without disrupting
the plant operation.
Craig
--
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
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
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
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]> -
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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().
>
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().
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
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
>>Craig Howard schrieb:
>> Hello All:
>>
>> Is is possible to compile a code object and single-step through its
>> execution?
>import pdb; pdb.set_trace()
>
>Look up the pdb module documentation.
>
>Diez
Sorry, I didn't give enough deta
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
Hello All:
Is is possible to compile a code object and single-step through its
execution?
Craig
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
[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
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
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
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
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
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
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 <
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
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
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
>
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
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.
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
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
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
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
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.
--
(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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
) 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
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
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
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
;, pipe.stdout.read()
---zz.py
#!/usr/bin/python
import sys
print >>sys.stdout, "Stdout"
print >>sys.stderr, "Stderr"
----
Produces
$ ./z.py
Without shell
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 ;-)
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
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
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
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
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
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
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
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
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
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
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
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
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
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:
>
> > Well, yes there are different levels of potential reliability with
> > different implementation strategies for each!
>
> Gadzooks! F
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
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
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
401 - 500 of 861 matches
Mail list logo