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
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
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
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
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-
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
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
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
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
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?
> >>>
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
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
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
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
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
> dwCreationDisposition,
> FILE_ATTRIBUTE_NORMAL,
> NULL );
use os.read os.write and os.open which will give you OS handles rather
than python file objects, ie I think these are a fairly direct
interface to CreatFile etc
L or Expect nor does it require C extensions to be
compiled. It should work on any platform that supports the standard
Python pty module. The Pexpect interface was designed to be easy to
use.
You'll never get it to work with subprocess like this because of the
buffering.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
com/ASPN/Cookbook/Python/Recipe/496960
and
http://sebulba.wikispaces.com/recipe+thread2
Read the caveats!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ion layer (HAL). To specify processor
affinity for a thread, use the SetThreadAffinityMask function.
I would have said time.time is what you want to use anyway though
because under unix time.clock() returns the elapsed CPU time which is
not what you want at all!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Tim Roberts <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> >
> >time.clock() uses QueryPerformanceCounter under windows. There are
> >some known problems with that (eg with Dual core AMD processors).
> >
> >See http://m
Theo v. Werkhoven <[EMAIL PROTECTED]> wrote:
> The carbonbased lifeform Nick Craig-Wood inspired comp.lang.python with:
> > Theo v. Werkhoven <[EMAIL PROTECTED]> wrote:
> >> Output:
> >> Sample 1, at 0.0 seconds from start; Output power is: 8.967 dBm
>
but once you do you'll be writing a
killer crawler ;-)
As for Perl - once upon a time I would have done this with perl, but I
wouldn't go back now!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
SOURCE"
> redefined
>
> but if i do
>
> export C_INCLUDE_PATH=/usr/include/python2.4
>
> I do not face any compilation issues.
>
> I would like to know if there is anything i am missing on this.
Do it in your code with
#define _POSIX_C_SOURCE
instead of the Makefile
which was
from MSSQL->MySQL).
You'll find that different databases have subtly different ways of
doing things (eg autoincrement fields on mysql) so you'll most likely
need a custom script anyway.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
.mpq(123,1000)
>>> b = gmpy.mpq(12,100)
>>> a+b
mpq(243,1000)
>>> a*b
mpq(369,25000)
>>> a/b
mpq(41,40)
>>>
It is also *very* fast being written in C.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
'e']
> 2 : ['c']
> 3 : ['b', 'd']
> 4 : ['f']
>
Or use the little understood dict.setdefault method which has been
with us from time immemorial...
>>> d = {'a' : 1, 'b' : 3, 'c' : 2,'d' : 3,'e' : 1,'f' : 4}
>>> dd = {}
>>> for k, v in d.items():
... dd.setdefault(v, []).append(k)
...
>>> dd
{1: ['a', 'e'], 2: ['c'], 3: ['b', 'd'], 4: ['f']}
>>>
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
expensive than computer time,
> after all.
Good advice with one caveat: sorted() was only introduced in python
2.4 so if your code must run on earlier versions then use list.sort()
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
numerate(collatz(13)):
... last = x[:i+1]
... print x[:i+1]
... else:
... last.append(1)
... print last
...
[13]
[13, 40]
[13, 40, 20]
[13, 40, 20, 10]
[13, 40, 20, 10, 5]
[13, 40, 20, 10, 5, 16]
[13, 40, 20, 10, 5, 16, 8]
[13, 40, 20, 10, 5, 16, 8, 4]
[13, 40, 20, 10, 5, 16, 8,
vention.
I guess you've compiled your DLL with C++ and the above is a C++
mangled name.
Either compile it with C, or export the names in an extern "C" { }
block.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
if not os.path.exists('aaa'):
fd = open('aaa', 'w+')
else:
fd = open('aaa', 'r+')
fcntl.flock(fd,fcntl.LOCK_EX)
fd.truncate()
fd.write(data)
fd.close()
def check():
fd = open('aaa', 'r')
fcntl.flock(fd,fcntl.LOCK_EX)
data = fd.read()
fd.close()
if data not in ("sausage", "potato"):
raise AssertionError("Wrong data %r" % data)
if os.path.exists("aaa"):
os.unlink("aaa")
if len(sys.argv) < 2:
print "Syntax: %s " % sys.argv[0]
raise SystemExit(1)
method = globals()["method_"+sys.argv[1]]
if os.fork():
while 1:
method("sausage")
check()
else:
while 1:
method("potato")
check()
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
t;>> value
'\xc9\x11}\x8f?64\x83\xf3\xcaPz\x1d!\xddd'
>>> value.encode("hex")
'c9117d8f3f363483f3ca507a1d21dd64'
>>> long(value.encode("hex"), 16)
267265642849753964132104960801656397156L
>>>
> For unicode encoding, I can do, md5.update(value.encode('utf-8')) to
> give me ascii values.
Yes that would be fine
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
out.append(hex_to_binary[hex_digit])
... out = "".join(out).lstrip("0")
... if out == "":
... out = "0"
... return out
...
>>> to_binary(0)
'0'
>>> to_binary(10)
'1010'
>>> to_binary(100)
'1100100'
>>> to_binary(1000)
'101000'
>>> to_binary(1000)
'1000101011000111001000110100100010001000'
But don't try this ;-)
>>> to_binary(-1)
Traceback (most recent call last):
File "", line 1, in
File "", line 4, in to_binary
KeyError: '-'
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
)
Another VM to run python would be nice of course, but we already have
jython, ironpython and pypy.
Both jython and ironpython use JIT, pypy can compile to native code
and you can use psyco for JIT code also in normal python.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig
robably what you want is this...
from subprocess import call
rc = call(["mypath/myfile.exe",arg1,arg2])
rc will contain the exit status
See the subprocess module for more things you can do
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
t creates two lists
then joins them then throws the whole lot away!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
evidentemente.yo <[EMAIL PROTECTED]> wrote:
> On 24 jun, 14:32, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> > Probably what you want is this...
> >
> > from subprocess import call
> >
> > rc = call(["mypath/myfile.exe",arg1,arg2])
add a bit of C/C++
if some part of it was running too slowly. If there were existing
C/C++ libraries then I'd use ctypes to interface with them.
I don't think I ever want to start another large C++ app - been there,
done that, got the (mental) scars to prove it ;-)
All my humble opinio
e here for a python memoize which makes the recursive algorithm run
fast...
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52201
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
passing len(x) arguments to zip.
So if x = [1,2,3,4]
zip(*x) == zip(1,2,3,4)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Rich Harkins <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> [snip]
> > By definition any function in a functional language will
> > always produce the same result if given the same arguments, so you can
> > memoize any function.
> >
>
> Ah, s
ll, but I haven't found any way of doing that. Can anyone offer
> my some suggestions? Or, am I S.O.L.?
You could try loading C explicitly with ctypes.LoadLibrary() before
loading A, then you'll have a handle to unload it before you load B.
I think I'd probably split the c
n the old site!
Mind telling us how it is implemented? I'm guessing python/django by
the url and the fact that you have python stuff on your home pages but
I could be wrong!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
a.x
0
>>> memmove(addressof(a), packet, sizeof(a))
3083811008L
>>> a.x
258
I think the second of those methods is promoted by the ctypes
documentation. I'm not sure about the lifetimes of the .contents in
the first method!
And the reverse
>>>
---
class Test(object):
def __init__(self):
self.foo = []
def goo(self):
self.foo.append(2)
def moo(self):
print self.foo
test = Test()
>>> from test2 import test
>>> test.foo
[]
>>> test.goo()
>>> test.foo
[2]
>>> test.moo()
[2]
>>>
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
c_char_p(136692916)
>>> s.value
'hello'
>>>
or use ctypes.memmove to copy the data out to somewhere else.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
to script that with python.
See here for some more info on dcop :-
http://www.ibm.com/developerworks/linux/library/l-dcop/
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
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
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
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 &
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
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
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
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
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
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
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
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
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
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
= 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
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
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
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
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
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
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
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
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
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
inimize programming errors, simple code mistakes
> too.
And perl also
*ducks*
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
27;
> a.__argname__= new_value
Not quite sure what the above is supposed to achieve
> rather than :
>
> if arg == 'height':
>a.height = new_value
> elif arg == 'width';
>a.width = new_value
>
> Can I do this with python ? How ?
se
orting
it to python but looking at the regular expressions made me feel weak
at the knees ;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
#x27;d use select and run
asynchronously.
http://docs.python.org/lib/module-select.html
Actually if I really had to do this I'd use twisted. Right tool for
the job!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
= mydict['two']
v3 = mydict['two']
Either is only a couple more characters to type. It is completely
explicit and comprehensible to everyone, in comparison to
v1,v2,v3 = [ mydict[k] for k in ['one','two','two']] # 52 chars
v1,v2,v3 = [
Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> On Thu, 11 Sep 2008 03:36:35 -0500, Nick Craig-Wood wrote:
>
> > As an ex-perl programmer and having used python for some years now, I'd
> > type the explicit
> >
> > v1,v2,v3 = mydict['one
t the exact representations leak out anyway (which
causes a lot of FAQs in this list), eg
>>> 0.1
0.10001
IMHO We should put the exact conversions in for floats to Decimal and
Fraction by default and add a new section to the FAQ!
In that way people will see floats for what the
dn't read result from MyModule.SubModule.my_function");
goto out;
}
my_result = strdup(my_result); /* keep in our own memory */
out:;
Py_XDECREF(result);
Py_XDECREF(module);
return my_result;
}
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
that you actually opened the file, ie file_1 != 0.
This might be relevant
http://effbot.org/pyfaq/pyrun-simplefile-crashes-on-windows-but-not-on-unix-why.htm
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
getcontext().prec += 1
finally:
setcontext(oldcontext)
print "float(0.1) is", floatToDecimal(0.1)
--------
Prints this
float(0.1) is 0.155511151231257827021181583404541015625
On my platform
Python 2.5.2 (r252:60911, Aug 8 2008, 09:22:44),
[GCC 4.3.1] on linux2
Linux 2.6.26-1-686
Intel(R) Core(TM)2 CPU T7200
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
to build an rpm and converting to a .deb.
The app is then tested with "etch" or whatever.
If easy_install could build debs that would be really helpful!
> Suggestions on build/rollout tools (like zc.buildout, Paver, etc) would
> also be appreciated.
Use setup.py to build in
jangoproject.com/en/dev/ref/contrib/flatpages/
A bit more of a learning curve but you'll definitely be in charge.
Somebody used to Django could set up a flatpages site in 5 minutes
probably! It will take you a couple of hours the first time though.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
gt;
>>>
So just remove the parentheses and you'll be fine.
I have to say I prefer named functions, but I haven't done much
functional programming
def f(ai, bi):
return ai * bi
ci.addCallback(f)
def f(i, s):
return field(i + 1), s
map(f, enumerate(si))
perate the two then the documention
will lag the code.)
PS I've used reST and perldoc. reST is easier to use for the easy
things, but gets complicated for the hard things.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ython Modules (2.3)
* Python2.3-ext: (python2.3-ext). Extending & Embedding Python 2.3
* Python2.3-lib: (python2.3-lib). Python 2.3 Library Reference
* Python2.3-ref: (python2.3-ref). Python 2.3 Reference Manual
* Python2.3-tut: (python2.3-tut). Python 2.3 Tutorial
--
Nick
l and index finger does right clicks.
I'm now an ambidextrous mouse user. I still can't draw stuff with my
left hand quite as well as my right, but I don't attempt that very
often!
I can't actually think of any possible way of getting this on topic,
so I'll just mention
Enabled Size: Not Installed
Error Status: OK
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
amp()
>>> datetime.datetime.utcfromtimestamp(1.090516451769E+15/1E6).isoformat()[-15:]
'17:14:11.769000'
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
q/general/#why-are-floating-point-calculations-so-inaccurate
Eg
>>> a=1.090516455488E9 / 100
>>> print a
1090.51645549
>>> print repr(a)
1090.516455488
>>>
If you want a given number of decimal places you can use a formatter,
eg
>>> print &quo
which we can't
maintain any more into a django site, and we've been monstrously
impressed!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
I use which is easy and works just fine. I only type it
once and then press up arrow to get it back!
import workinprogress; reload(workinprogress); del(workinprogress); from
workinprogress import *
That gives you the module and all its globals rebound.
--
Nick Craig-Wood <[EMAIL PROTECTE
ooks as thought it almost, or maybe completely, does what you
want, ie an XMLRPC subclass which reads from stdin and writes to
stdout.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
whatever will they think of next ;-)
Thanks for maintaining gmpy - it is an excellent bit of software!
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
b = reshape(a, [3,3])
>>> linalg.det(b)
-9.5171266700777579e-16
>>>
Which is zero but with a bit of rounding errors which I guess numpy
doesn't notice.
Double checking like this
>>> a,b,c,d,e,f,g,h,i=range(1,10)
>>> a*e*i - a*f*h - b*d*i + b*f*g + c*d*h -
Gaudha wrote:
> Can anybody tell me what is meant by 'openhook' ?
http://docs.python.org/library/fileinput.html?highlight=openhook
Maybe ;-)
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
> re.sub('/?$', '/', 'aaabbb')
'aaabbb/'
>>>
That solution is very perl-ish I'd say, IMHO
if not url.endswith("/"):
url += "/"
is much more pythonic and immediately readable. In fact even someone
who doesn't know python could understand what it does, unlike the
regexp solution which requires a little bit of thought.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
501 - 600 of 641 matches
Mail list logo