Re: ctypes, function pointers and a lot of trouble

2008-06-02 Thread Nick Craig-Wood
call last): File "", line 1, in TypeError: expected LP_c_char instance, got _ctypes.PointerType >>> databuftype = c_char * 10 >>> databuf = databuftype() >>> cbuffer.cpBuffer = databuf >>> databuf <__main__.c_char_Array_10 o

Re: ctypes, function pointers and a lot of trouble

2008-05-30 Thread Nick Craig-Wood
uint), ("open", cstreamopen), ("close", cstreamclose), # etc... This will involve you re-ordering your definitions. Or alternatively, you could cast the function pointer to a c_void_p first, eg data.u.pStream.open = c_void_p( c

Re: ctypes, function pointers and a lot of trouble

2008-05-28 Thread Nick Craig-Wood
an "Invalid Parameter" errorcode. there's also no useful > data whereas datainfo gets written correctly. I know that my cdStream > can't work, facing the C-code, but what'd be the right cdStream class? > What can I do? Any ideas? I've noted some obvious problems above. To get this to work will require some C knowledge. If they supply some example C code I'd work through that translating it line by line to python+ctypes. -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: array of 64-bit ints?

2008-05-23 Thread Nick Craig-Wood
this... from ctypes import * Array = c_int64 * 100 a = Array() for i in range(100): a[i] = 2**63 - i for i in range(100): print a[i] prints -9223372036854775808 9223372036854775807 9223372036854775806 [snip] 9223372036854775710 9223372036854775709 ctypes arrays are fixed len

Re: Advice from senior Members

2008-05-23 Thread Nick Craig-Wood
t is hard to write tests for wx GUIs though (but not impossible). When you've finished you'll have 3 files full of classes. You may have a few utility functions too. -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling class method by name passed in variable

2008-05-23 Thread Nick Craig-Wood
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood a ?crit : > > Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > >>> Can someone suggest an efficient way of calling method whose name is > >>> passed in a variable? > >>>

Re: Why is math.pi slightly wrong?

2008-05-23 Thread Nick Craig-Wood
de("hex") '400921fb54442d18' >>> struct.unpack(">d", "400921FB54442D18".decode("hex")) (3.1415926535897931,) >>> struct.unpack(">d", "400921FB54442D19".decode("hex")) (3.1415926535897936,) >>> -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: ctypes help

2008-05-23 Thread Nick Craig-Wood
4] OSCL_getCurrentStaticParams [ 5] OSCL_getErrorString [ 6] OSCL_getIdent [snip] This is a dll we used in a project, and those names exactly worked with ctypes, eg some snips from the ctypes code self.dll = cdll.LoadLibrary("OurSharedCodeLibrary") self.dll.OSCL_getErrorString.restype = c_char_p def getErrorString(self, status): return self.dll.OSCL_getErrorString(c_int(status)) -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling class method by name passed in variable

2008-05-23 Thread Nick Craig-Wood
nt call last): File "", line 1, in TypeError: 'int' object is not callable >>> getattr(obj, 'f')(1) False >>> -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and Flaming Thunder

2008-05-23 Thread Nick Craig-Wood
L). I think candygram is crying out to be married with stackless &or PyPy. It also needs an IPC channel to compete with Erlang directly. If you are interested in stackless python vs Erlang then take a look at this... http://muharem.wordpress.com/2007/07/31/erlang-vs-stackless-python-a-first-

Re: call f(a, *b) with f(*a, **b) ?

2008-05-23 Thread Nick Craig-Wood
y manipulation)... So instead of f(a, *args) have f(a, list_of_args). The f(*args) syntax is tempting to use for a function which takes a variable number of arguments, but I usually find myself re-writing it to take a list because of exactly these sort of problems. In fact I'd be as bold to

Re: Python and Flaming Thunder

2008-05-22 Thread Nick Craig-Wood
Mel <[EMAIL PROTECTED]> wrote: > Mensanator wrote: > > On May 22, 10:30??am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > >> Dave Parker <[EMAIL PROTECTED]> wrote: > >> > But after getting input from children and teachers, etc, it started > &g

Re: Python and Flaming Thunder

2008-05-22 Thread Nick Craig-Wood
8. 8 2> X = 10. ** exception error: no match of right hand side value 10 3> That error message is the erlang interpreter saying "Hey I know X is 8, and you've said it is 10 - that can't be right", which is pretty much what math teachers say too... -- Nick Craig-Wood <[EM

Re: php vs python

2008-05-22 Thread Nick Craig-Wood
drummed into me to always use parameters for user input and I was really suprised PHP didn't have them. -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Write bits in file

2008-05-20 Thread Nick Craig-Wood
be stored at an arbitrary > > bit-position in the file > > Yes. I need arbitrary, 8bits, than 10 bits for something else, than > sequence of bytes, than 10 bits again, etc. You could try http://construct.wikispaces.com/ which could well do exactly what you want. -- Nick Cr

Re: scaling problems

2008-05-20 Thread Nick Craig-Wood
do more of those!" - as a battle scarred C programmer I'd agree ;-) -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: TPCServer and xdrlib

2008-05-20 Thread Nick Craig-Wood
hon with a bit of searching. Also I believe twisted supports them directly or you could easily roll your own. -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Get all the instances of one class

2008-05-19 Thread Nick Craig-Wood
est.instances() Which prints [] [<__main__.Test object at 0xb7d4eb6c>, <__main__.Test object at 0xb7d4eb4c>] [<__main__.Test object at 0xb7d4eb6c>] [] -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: TPCServer and xdrlib

2008-05-16 Thread Nick Craig-Wood
rd with xmlrpc. > > I have looked at various solutions including: > > - PyOrbit - too heavy weight > - Pyro - uses pickle, I do not trust it It is possible to change the serialization used by Pyro http://pyro.sourceforge.net/manual/9-security.html#pickle to the the 'g

Re: sys.excepthack...

2008-05-15 Thread Nick Craig-Wood
error_text = "".join(format_exception(type, value, traceback)) wx.MessageDialog(None, error_text, 'Custom Error:', wx.OK).ShowModal() def OnClick(self, evt): "Click with a deliberate mistake" adsfsfsdf if __name__ == "__main__": a

Re: Newbie question - probably FAQ (but not exactly answered by regular FAQ)

2008-05-06 Thread Nick Craig-Wood
vailable as a 3rd party module for 2.3 and 2.4. As is sqlite3. So in my opinion the real difference between the 2.2, 2.3, 2.4 and 2.5 are the built in modules. The actual language changes are very minor. If you write your code for 2.5 which is probably a good idea, you'll have no problem ba

Re: Script using generators produces different results when invoked as a CGI

2008-05-05 Thread Nick Craig-Wood
file size... > Are you sure the script runs to completion? Output a message at the > end, to be sure. Check the ownership of all the files too. Remember that the web server (and hence your cgi) will likely run as nobody or www-data. You are unlikely to be logging in as one of those users. -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: get the pid of a process with pexpect

2008-05-05 Thread Nick Craig-Wood
gt; Is there a way to get it using pexpect ? If I understand you correctly what you need to do is run "echo $$" on the remote shell then "exec tunnel_command". The $$ will print the pid and the exec will run tunnel_command without changing the pid. -- Nick Craig-Wood <[EMA

Re: ISBN Barecode reader in Python?

2008-05-04 Thread Nick Craig-Wood
SDK doing the same? As it is a hobby > project, I don't like to spend money on the SDK. Pick yourself up a cue-cat barcode reader, eg from here or ebay http://www.librarything.com/cuecat These appear as a keyboard and "type" the barcode in to your program. Cheap and eff

Re: Feature suggestion: sum() ought to use a compensated summation algorithm

2008-05-03 Thread Nick Craig-Wood
y! > I thought that it would be very nice if the built-in sum() function used > this algorithm by default. Has this been brought up before? Would this > have any disadvantages (apart from a slight performance impact, but > Python is a high-level language anyway ...)? sum() gets used for any numerical types not just floats... -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question - probably FAQ (but not exactly answered by regular FAQ)

2008-05-03 Thread Nick Craig-Wood
er idea ? Suggestions with > reasoning would be very helpful. Jython seems to be based off python 2.2 so you would be limited to 2.2 features in that case. No big deal in my opinion. -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with pyserial and sending binary data?

2008-05-03 Thread Nick Craig-Wood
immediately after plugging the port in. I do a lot of this sort of thing at work (not with cars though with satellite equipment) and it is always the first packet and the first response which is the hard part. After that it is usually plain sailing! -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: portable fork+exec/spawn

2008-05-03 Thread Nick Craig-Wood
ues since it's > event-driven. It took me a while but I found the documentation on this eventually http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IReactorProcess.html Looks interesting - I'll have to try it next time I'm reaching for pexpect Thanks N

python-list@python.org

2008-05-02 Thread CRAIG DALTON
t;): g=open(os.path.join(r+,files)) shutil.copyfileobj(g,f) g.close() f.close() Any help would be great. Thanks, Craig Dalton Business Applications Systems Analyst Sentara Healthcare Systems Information Technology [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: portable fork+exec/spawn

2008-05-02 Thread Nick Craig-Wood
eceive output, read exit code type jobs. For jobs which require interactivity ie send input, receive output, send input, receive output, ... it doesn't work well. There isn't a good cross platform solution for this yet. pyexpect works well under unix and is hopefully being ported to

Re: Best way to store config or preferences in a multi-platform way.

2008-05-01 Thread Nick Craig-Wood
= os.path.join(self.home, "."+self.NAME) if not os.path.isdir(self.config_dir): os.makedirs(self.config_dir, mode=0700) self.config_file = os.path.join(self.config_dir, "config") -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Receive data from socket stream

2008-04-29 Thread Nick Craig-Wood
lf.sock = None raise ServerDisconnectedException() self.rx_buf += rx return message Sorry I mis-understood your original post! -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Question regarding Queue object

2008-04-29 Thread Nick Craig-Wood
Terry <[EMAIL PROTECTED]> wrote: > On Apr 28, 5:30 pm, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > > David <[EMAIL PROTECTED]> wrote: > > > Another idea would be to have multiple queues, one per thread or per > > > message type "group

Re: Receive data from socket stream

2008-04-29 Thread Nick Craig-Wood
Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood <[EMAIL PROTECTED]> writes: > > >> Note that appending to a string is almost never a good idea, since it > >> can result in quadratic allocation. > > > > My aim was clear exposition

Re: Receive data from socket stream

2008-04-28 Thread Nick Craig-Wood
Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood <[EMAIL PROTECTED]> writes: > > > What you are missing is that if the recv ever returns no bytes at all > > then the other end has closed the connection. So something like this > > is the corr

Re: Regular Expression - Matching Multiples of 3 Characters exactly.

2008-04-28 Thread Nick Craig-Wood
7;, 'AUG', 'WWQWAWQWW', 'QWW', 'AGG') >>> > This way, I could scan for genes, remove the first letter, scan for > more genes, remove the first letter again, and scan for more genes. > This would hypothetically yield different genes, since the frame > would be shifted. Of you could just unconstrain the first match and it will do them all at once :- (AUG)((\w\w\w)*?)(AGG) You could run this with re.findall, but beware that this will only return non-overlapping matches which may not be what you want. I'm not sure re's are the best tool for the job, but they should give you a quick idea of what the answers might be. -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Receive data from socket stream

2008-04-28 Thread Nick Craig-Wood
impossible to tell how much data has been sent. There should really be a recvall for symmetry, but I don't think it would get much use! -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Question regarding Queue object

2008-04-28 Thread Nick Craig-Wood
o be put in and all the threads will have to do is Queue.get() and be sure they've got a message they can deal with. -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Receive data from socket stream

2008-04-28 Thread Nick Craig-Wood
new = client.recv(256) if not new: break data += new >From the man page for recv RETURN VALUE These calls return the number of bytes received, or -1 if an error occurred. The return value will be 0 when the peer has performed an orderly shutd

Re: Little novice program written in Python

2008-04-25 Thread Nick Craig-Wood
learning the > language idioms). When you are up to speed in python I suggest you check out gmpy for number theory algorithms. Eg :- import gmpy p = 2 while 1: print p p = gmpy.next_prime(p) -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.co

Re: function that accepts any amount of arguments?

2008-04-25 Thread Nick Craig-Wood
return v/len(x) > >> > > > > think you want total/len(x) in return statement > > > Yes indeed, how glad I am I wrote "untested". I clearly wasn't pair > programming when I wrote this post ;-) Posting to comp.lang.python is pair programming wit

Re: subprocess module is sorely deficient?

2008-04-23 Thread Nick Craig-Wood
uses pexpect fairly extensively to > interface with all sorts of other systems. We recently received > funding from Microsoft to do a native port of Sage (and all of its > components to Windows. Part of this will most likely be a port of > pexpect to Windows. Hooray! -- Nick Craig-Wood &

Re: [Python 2.4/2.5] subprocess module is sorely deficient?

2008-04-22 Thread Nick Craig-Wood
Mark Wooding <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > > Harishankar <[EMAIL PROTECTED]> wrote: > >> 1. Create non-blocking pipes which can be read in a separate thread > >> [...] > > > > You are correct o

Re: [Python 2.4/2.5] subprocess module is sorely deficient?

2008-04-22 Thread Nick Craig-Wood
if killpg: os.killpg(pgid, signal.SIGKILL) else: os.kill(pid, signal.SIGKILL) except OSError: return -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: I just killed GIL!!!

2008-04-18 Thread Nick Craig-Wood
dict unshareable, while immutable int and str objects can still be shared. Further, mutable objects that provide an explicit API for use between threads are also shareable. ---- -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: is file open in system ? - other than lsof

2008-04-17 Thread Nick Craig-Wood
if not os.path.exists(link): continue open_files.setdefault(link, []).append(pid) for link in sorted(open_files.keys()): print "%s : %s" % (link, ", ".join(map(str, open_files[link]))) You m

Re: bsddb3 thread problem

2008-04-02 Thread Nick Craig-Wood
ying to use it in thread Y which won't work". You can probably make bsddb work with threads, but I wasted too much time trying without success! -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: bsddb3 thread problem

2008-04-01 Thread Nick Craig-Wood
I spent weeks trying to get it to behave when threading. I gave up in the end and changed to sqlite :-( At least if you make a mistake with sqlite and use the wrong handle in the wrong place when threading it gives you a very clear error. -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://ww

Re: Homework help

2008-04-01 Thread Nick Craig-Wood
function howMany(item,lst) which accepts > an item and a lst of items and returns the number of times item occurs > in lst. For example, howMany(3,[1,2,3,2,3]) should return 2. Read section 4.1, 4.2 and 4.6 from here http://docs.python.org/tut/node6.html -- Nick Craig-Wood <[EMAIL

Re: Need help calling a proprietary C DLL from Python

2008-03-26 Thread Craig
On Mar 26, 12:24 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Tue, 25 Mar 2008 08:24:13 -0700 (PDT), Craig <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > 41 0 0 0 > > 7 0 0 0 > > Which makes sense for two reasons: > >

Re: Need help calling a proprietary C DLL from Python

2008-03-25 Thread Craig
On Mar 25, 2:02 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Mon, 24 Mar 2008 15:21:11 -0700 (PDT), Craig <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > And this is what I got: > > VmxGet test - looking for valid record... &g

Re: Need help calling a proprietary C DLL from Python

2008-03-24 Thread Craig
On Mar 24, 3:45 pm, Craig <[EMAIL PROTECTED]> wrote: > On Mar 24, 12:27 pm, Craig <[EMAIL PROTECTED]> wrote: > > > > > On Mar 23, 7:59 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > > > > On Sun, 23 Mar 2008 14:24:52 -0700 (PDT), Craig <

Re: Need help calling a proprietary C DLL from Python

2008-03-24 Thread Craig
On Mar 24, 12:27 pm, Craig <[EMAIL PROTECTED]> wrote: > On Mar 23, 7:59 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > > > > > On Sun, 23 Mar 2008 14:24:52 -0700 (PDT), Craig <[EMAIL PROTECTED]> > > declaimed the following in comp.lang.python: >

Re: Need help calling a proprietary C DLL from Python

2008-03-24 Thread Craig
On Mar 23, 7:59 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Sun, 23 Mar 2008 14:24:52 -0700 (PDT), Craig <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > > > This dll was designed to be used from either C or Visual Basic 6. > &

Re: Need help calling a proprietary C DLL from Python

2008-03-23 Thread Craig
On Mar 23, 4:48 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Sat, 22 Mar 2008 19:05:31 -0700 (PDT), Craig <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > I got back exactly what I expected for TypeDef, but SecKey and PriKey > >

Re: Anomaly in time.clock()

2008-03-22 Thread Craig
On Mar 22, 10:03 pm, Tim Roberts <[EMAIL PROTECTED]> wrote: > Godzilla <[EMAIL PROTECTED]> wrote: > > >Just found out that win32api.GetTickCount() returns a tick count in > >milli-second since XP started. Not sure whether that is reliable. > >Anyone uses that for calculating elapsed time? > > What

Re: Need help calling a proprietary C DLL from Python

2008-03-22 Thread Craig
On Mar 22, 9:40 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Sat, 22 Mar 2008 15:12:47 -0700 (PDT), Craig <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > > > > > Anyway, I have the following for "types": > >

Re: Need help calling a proprietary C DLL from Python

2008-03-22 Thread Craig
On Mar 22, 3:13 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Fri, 21 Mar 2008 23:21:48 -0700 (PDT), Craig <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > Sorry, I wasn't trying to exclude any credit from Dennis, I just > >

Re: Need help calling a proprietary C DLL from Python

2008-03-21 Thread Craig
On Mar 21, 4:04 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Thu, 20 Mar 2008 16:50:18 -0700 (PDT), Craig <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > > > I received a direct email from someone, and I came up with the > >

Re: Need help calling a proprietary C DLL from Python

2008-03-20 Thread Craig
On Mar 20, 6:26 pm, sturlamolden <[EMAIL PROTECTED]> wrote: > On 20 Mar, 19:09, Craig <[EMAIL PROTECTED]> wrote: > > > The following is the C++ prototype for one of the functions: > > short FAR PASCAL VmxOpen(BSTR*Filespec, > >

Re: Need help calling a proprietary C DLL from Python

2008-03-20 Thread Craig
On Mar 20, 4:55 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > On Thu, Mar 20, 2008 at 3:42 PM, Craig <[EMAIL PROTECTED]> wrote: > > > On Mar 20, 2:38 pm, Craig <[EMAIL PROTECTED]> wrote: > > > On Mar 20, 2:29 pm, sturlamolden <[EMAIL PROTECTED

Re: Need help calling a proprietary C DLL from Python

2008-03-20 Thread Craig
On Mar 20, 2:38 pm, Craig <[EMAIL PROTECTED]> wrote: > On Mar 20, 2:29 pm, sturlamolden <[EMAIL PROTECTED]> wrote: > > > On 20 Mar, 19:09, Craig <[EMAIL PROTECTED]> wrote: > > > The culprit i here: > > > > Before - X = 0, CacheSize = 0, OpenMo

Re: Need help calling a proprietary C DLL from Python

2008-03-20 Thread Craig
On Mar 20, 2:29 pm, sturlamolden <[EMAIL PROTECTED]> wrote: > On 20 Mar, 19:09, Craig <[EMAIL PROTECTED]> wrote: > > The culprit i here: > > > Before - X = 0, CacheSize = 0, OpenMode = 3, vHandle = 0 > > This binds these names to Python ints, but byref ex

Need help calling a proprietary C DLL from Python

2008-03-20 Thread Craig
I use a proprietary dll from Software Source (vbis5032.dll). I have successfully used it from Visual Basic 6, Fujitsu Cobol and from Perl. I would now like to use it from Python. The following is the C++ prototype for one of the functions: short FAR PASCAL VmxOpen(BSTR*Filespec,

Re: Writing Memory to File

2008-03-10 Thread Nick Craig-Wood
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

Re: Adding Priority Scheduling feature to the subprocess

2008-02-25 Thread Nick Craig-Wood
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'

Re: ANN: Strangle 0.3.0 DNS parsing library based on BIND9

2008-02-25 Thread Nick Craig-Wood
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

Re: Adding Priority Scheduling feature to the subprocess

2008-02-22 Thread Nick Craig-Wood
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

Re: Garbage collection

2008-02-19 Thread Nick Craig-Wood
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

Re: ways to declare empty set variable

2008-02-13 Thread Nick Craig-Wood
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

Re: best(fastest) way to send and get lists from files

2008-02-05 Thread Nick Craig-Wood
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

Re: Does anyone else use this little idiom?

2008-02-05 Thread Nick Craig-Wood
'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

Re: piping into a python script

2008-01-25 Thread Nick Craig-Wood
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

Re: A GUI framework for running simulations

2008-01-24 Thread Nick Craig-Wood
n't that hard). -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list

Re: where do my python files go in linux?

2008-01-14 Thread Nick Craig-Wood
> 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

Re: where do my python files go in linux?

2008-01-14 Thread Nick Craig-Wood
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

Re: Threaded server

2008-01-14 Thread Nick Craig-Wood
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

Fwd: newbie question regarding int(input(:)) - sorry for the spam

2008-01-11 Thread Craig Ward
have a second input and I can't put the int(input(":") in the function because I get the error 'int' is not callable plus my choice variable is not defined. can someone please enlighten me? :-) -- Forwarded message -- From: Craig Ward <[EMAIL PROTEC

newbie question regarding int(input(:))

2008-01-11 Thread Craig Ward
Hi experts! I am trying to write a menu script that will execute bash scripts. Everything is fine until the script executes and I want to see if there are any more options to run before quitting. Example: def menu(opt1 = "something", opt2 = "something else"): -- Computers are like air condition

Re: python recursive function

2008-01-11 Thread Nick Craig-Wood
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

Re: urllib2 rate limiting

2008-01-11 Thread Nick Craig-Wood
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

Re: "Canonical" way of deleting elements from lists

2008-01-09 Thread Nick Craig-Wood
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"

Re: "Canonical" way of deleting elements from lists

2008-01-09 Thread Nick Craig-Wood
>>> 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

Re: Why python says "unexpected parameter 'mini.py'" for my code?

2008-01-04 Thread Nick Craig-Wood
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

Re: int vs long

2007-12-20 Thread Nick Craig-Wood
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

Re: int vs long

2007-12-17 Thread Nick Craig-Wood
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

Re: Equivalent of perl's Pod::Usage?

2007-12-10 Thread Nick Craig-Wood
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

Thought you would enjoy some funny math cartoons!!!

2007-12-06 Thread craig . snodgrass
enjoy. Thanks, Craig -- http://mail.python.org/mailman/listinfo/python-list

Re: trouble selling twisted

2007-11-27 Thread Nick Craig-Wood
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

Re: spawning a process with subprocess

2007-11-27 Thread Nick Craig-Wood
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

Re: Subprocess and 16-bit FORTRAN

2007-11-25 Thread Nick Craig-Wood
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

Re: import pysqlite2 or import sqlite3?

2007-11-25 Thread Nick Craig-Wood
, "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

Re: Which uses less memory?

2007-11-17 Thread Nick Craig-Wood
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

Re: Creating Installer or Executable in Python

2007-11-15 Thread Nick Craig-Wood
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

Re: Low-overhead GUI toolkit for Linux w/o X11?

2007-11-04 Thread Nick Craig-Wood
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! -

Re: Iteration for Factorials

2007-10-30 Thread Nick Craig-Wood
: 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

Re: cron, python and samba restart

2007-10-29 Thread Nick Craig-Wood
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 --

Re: bug: subprocess.Popen() hangs

2007-10-26 Thread Nick Craig-Wood
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

Re: Iteration for Factorials

2007-10-24 Thread Nick Craig-Wood
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

Re: Cross-platform GUI development

2007-10-12 Thread Nick Craig-Wood
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

<    1   2   3   4   5   6   7   8   9   >