which is faster" question which probably isn't
helpful for new Python programmers to focus on.
PS I enjoyed your book :-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Restore file position
> self.f.seek(initial_pos)
> # Unbind lazy attributes
> del self.f
> del self.ver
> del self.file_position
> del self.samples
>
> This seems to work out well. No infinite loops in __getattr__!
:-)
I would probably factor out the contents of the if statement into a
seperate method, but that is a matter of taste!
> At least it passes the unit test cases I have come up with so far.
>
> No guarantees though, as I may simply not have been smart enough to
> bring forth unit test cases which make it crash.
>
> Comments on the code is still appreciated though.
Looks fine!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Slaunger <[EMAIL PROTECTED]> wrote:
> On 3 Dec., 11:30, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> > > ? ? ? ? ?cls = self.__class__
> > > ? ? ? ? ?if attr_name in cls.data_attr_names:
> >
> > self.data_attr_names should do instead of cls.data_attr_
in Python?
With a class is the best way IMHO.
class make_counter(object):
def __init__(self, start_num):
self.x = start_num
def __call__(self):
x = self.x
self.x += 1
return x
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
careful with nonlocal args & kwargs
return result
vs
def closure(*args, **kwargs):
# initialisation to local vars
while 1:
# normal stuff using args and kwargs
yield result
def make_closure(*args, **kwargs):
return closure(*args, **kwargs).next
I still pre
In perl it is common to call methods without
parentheses - in python this does absolutely nothing! pychecker does
warn about it though.
perl -> $object->method
python -> object.method()
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Roy Smith <[EMAIL PROTECTED]> wrote:
> In article <[EMAIL PROTECTED]>,
> Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
>
> > My favourite mistake when I made the transition was calling methods
> > without parentheses. In perl it is common to call meth
; BTW. It is a much better practice to install from source into
> /usr/local, or your $HOME, etc... Anywhere which is not /usr.
easy_install can do that I think...
I find it odd that easy_install doesn't have
a) a list what you installed with easy_install
b) uninstall
in an otherwise excellent program.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
David Cournapeau wrote:
> On Thu, Dec 11, 2008 at 10:30 PM, Nick Craig-Wood
> wrote:
> > David Cournapeau wrote:
> >> On Wed, Dec 10, 2008 at 12:04 PM, Chris Rebert wrote:
> >> > On Tue, Dec 9, 2008 at 6:49 PM, wrote:
> >> >> On Ubun
== Thread 7000 working ==
== Thread 8000 working ==
== Thread 9000 working ==
== Thread 1 working ==
Total time: 834.81882
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
thing sensible in ctypes,
c_byte * 0 is what is required plus a bit of casting. This is a
non-standard GNU extension to C though.
All that said though, it looks like a great time saver.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Thomas Heller wrote:
> Nick Craig-Wood schrieb:
> > Interesting - I didn't know about h2xml and xml2py before and I've
> > done lots of ctypes wrapping! Something to help with the initial
> > drudge work of converting the structures would be very helpful.
> &g
dahl's Law too where P is approx 0, N
irrelevant...
Being IO bound explains why it takes longer with multiprocessing - it
causes more disk seeks to run an IO bound algorithm in parallel than
running it sequentially.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
are you processing at once? And how many MB of zip
files is it? As reading zip files does lots of disk IO I would guess
it is disk limited rather than anything else, which explains why doing
many at once is actually slower (the disk has to do more seeks).
--
Nick Craig-Wood -- http://www.cr
raise ValueError("Couldn't find subclass")
def __init__(self, input):
super(Field, self).__init__(input)
self.data = input
# Raise a ValueError in init if not suitable args for this subtype
class IntegerField(Field):
def __init__(self, s):
s = int(s)
super(IntegerField, self).__init__(s)
self.s = s
class ListField(Field):
def __init__(self, s):
if ',' not in s:
raise ValueError("Not a list")
super(ListField, self).__init__(s)
self.s = s.split(',')
class StringField(Field):
pass
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Thomas Heller wrote:
> Nick Craig-Wood schrieb:
> > Thomas Heller wrote:
> >> Nick Craig-Wood schrieb:
> >> > Interesting - I didn't know about h2xml and xml2py before and I've
> >> > done lots of ctypes wrapping! Something to help w
es.
Eg http://bugs.python.org/issue1515829
I'd attack this problem using beatifulsoup probably rather than
regexps!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
m mmap import mmap
>>> a = mmap(-1, 10)
>>> a[0]
'\x00'
>>> a[0] = 'z'
>>> a[9]
'\x00'
>>> a[9]='q'
>>> a[9]
'q'
>>> del a
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
a look at the code SWIG
generates and see if it puts some extern "C" in and match what it
does in your code.
We used to use SWIG in for python embedding in our C++ project, but we
found that using ctypes is a lot easier. You just write C .so/.dll
and use ctypes to access them. You can do callbacks and embedding
python like this too.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ting things into your local namespace is also the quickest, but
that isn't why I do it!
There are arguments against doing this, which I'm sure you'll hear
shortly ;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
a-b; };
>int mymul( int a, int b ) { return a*b; };
> }
>
> Traceback (most recent call last):
>File "", line 1, in
>File "test.py", line 7, in
> import _test
> ImportError: ./_test.so: undefined symbol: binary_op
Nowhere in your code is the definition of binary_op - that is why you
get a linker error.
Is it defined in another C file? If so you need to link it with the
swig wrapper before you make the .so
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
have_overlooked()
> do_something_where_I_know_a_ValueError_can_be_raised()
> catch ValueError:
> handle_the_anticipated_ValueError_from_std_lib()
> finally:
>
>
> I will not notice that it was an unanticpated condition in my own
> code, which cause
protool. Here's a silly example:
>
> >>> len(pickle.dumps([1,2,3], pickle.HIGHEST_PROTOCOL))
> 14
> >>> len(pickle.dumps([1,2,3], 0))
> 18
Or even
>>> L = range(100)
>>> a = pickle.dumps(L)
>>> len(a)
496
>>>
ot;, "rb")
>>> M = pickle.load(f)
>>> f.close()
>>> M == L
True
>>>
(Note that basic pickle protocol is likely to be more compressible
than the binary version!)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
hmod(0775, "directory")
rather than
os.chmod(775, "directory")
(leading 0 implies octal)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
greg <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> > (Note that basic pickle protocol is likely to be more compressible
> > than the binary version!)
>
> Although the binary version may be more compact to
> start with. It would be interesting to compar
thon - it all happens behind the
scenes. If you are writing a python extension in C then you do need
to worry about reference counting - a lot!
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
;, time='1:00 PM'
n='4', name='Adam', a='7', b='8', day='Monday', time='2:00 PM'
n='5', name='Bob', a='9', b='10', day='Monday', time='2:00 PM'
n='6', name='Charlie', a='11', b='12', day='Monday', time='2:00 PM'
n='7', name='Adam', a='13', b='14', day='Tuesday', time='1:00 PM'
n='8', name='Bob', a='15', b='16', day='Tuesday', time='1:00 PM'
n='9', name='Charlie', a='17', b='18', day='Tuesday', time='1:00 PM'
And leaves newfile.csv with the contents
1,2,3,Monday,1:00 PM
7,8,9,Tuesday,1:00 PM
4,5,6,Monday,2:00 PM
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
expanded
>
> My SLAG project does not care in reality WHICH or what language, it
> is simply handling menu and screen control.
So do you want to embed python into your code?
I'm still not clear what you are trying to achieve with python, though
I have a better idea what SLAG is now!
-
Ben wrote:
> On Feb 24, 11:31?am, Nick Craig-Wood wrote:
> > So do you want to embed python into your code?
> >
> > I'm still not clear what you are trying to achieve with python, though
> > I have a better idea what SLAG is now!
>
> Actually no, I want t
e
http://docs.python.org/library/linecache.html
Which may be useful...
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ng python as much of
the time as possible and C++ only when necessary.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
gt; such a job easily. I need a c parser, is there any C parser written in
> > python?
>
> GCCXML is usually used to create ctypes-structures from headers.
Look at
http://pypi.python.org/pypi/ctypeslib/
And the h2xml and xml2py scripts that are part of it.
You'll need gcc
docs.python.org/library/signal.html
Won't work on windows and there is only one sigalarm timer, so you
can't nest them :-(
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ef long_function():
duration = Duration(5)
i = 0
print "starting"
while duration:
print i
i += 1
sleep(1)
print "finished"
long_function()
Which prints
starting
0
1
2
3
4
finished
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ing cannot end in a single backslash (since
the backslash would escape the following quote character).
The usual way round this is like this
>>> r"a" "\\"
'a\\'
>>>
Which isn't terribly elegant, but it doesn't happen very often.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ute_key)
Which I think is clearer and more obvious. It gives you the
opportunity for a docstring also.
Yes it is a bit more typing, but who wants to play "code golf" all
day?
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
y to people who haven't coded in Python for one reason
> or another.
Perhaps the OP is looking for something like this
http://pleac.sourceforge.net/pleac_python/index.html
Which is a sort of Rosetta stone for perl and python ;-)
(The perl cookbook translated into python.)
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
dded ARM-Linux system ?
Works very well.
> Does cross compiling Python automatically include the standard
> Python library, or is that yet another adventure ?
If you use the debian compiled version then you get the lot.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
start = digits[0]
end = digits[-1]
f = open(minmax_path, "w")
f.write("%s %s" % (start, end))
f.close()
print "done"
if __name__ == "__main__": main()
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
tly.
You would need to make a dictionary interface to sqlite, eg
http://code.activestate.com/recipes/576638/
Or do something a bit simpler yourself.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
python as with shell because it has
almost everything you'll need built in.
Using built in functions is much quicker than fork()-ing an external
command too.
> So much to learn, so little time (but so much fun!)
;-)
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
use up all my RAM
and explode.
What I wanted to happen was for twisted to stop taking the data when
the serial port buffer was full and to only take the data at 9600
baud.
I never did solve that problem :-(
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Jean-Paul Calderone wrote:
> On Sun, 22 Mar 2009 12:30:04 -0500, Nick Craig-Wood
> wrote:
> >I wrote a serial port to TCP proxy (with logging) with twisted. The
> >problem I had was that twisted serial ports didn't seem to have any
> >back pressure. By that I
Jean-Paul Calderone wrote:
> On Mon, 23 Mar 2009 05:30:04 -0500, Nick Craig-Wood
> wrote:
> >Jean-Paul Calderone wrote:
> > [snip]
> >>
> >> In the case of a TCP to serial forwarder, you don't actually have to
> >> implement either a pro
.4 is still perhaps the safest bet, even though it is more
> awkward for writing code close to Python 3 syntax.
I tend to target whatever is in Debian stable, which starting from
this month is 2.5 (recently upgraded from 2.4).
2.6 or 3.x is nowhere to be seen in Debian stable, testing or u
address is the address of the socket sending the data.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
unmatched brackets, empty brackets, etc) and be sure it works
exactly as specified. doctest is cool for this kind of stuff.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ll once
you've jumped the flaming hoops of fire that setting it up is!
Another thing you can try is run your process untill it leaks loads,
then make it dump core. Examine the core dump with a hex editor and
see what it is full of! This technique works suprisingly often.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
quite a few years of python programing
I'm still learning new things from c.l.py
As a long time usenet user I find it easy to ignore the occasional
flame wars. Posters with the wrong sort of attitude are brought
gently into line by the majority.
If usenet groups had ratings I'd give c.l
nt only in the source code!
I think the others are just conventions and are not actually used by
anything, but I'd be interested to be proved wrong!
I tend to use
__author__ = "Nick Craig-Wood "
__version__ = "$Revision: 5034 $"
__date__ = "$Date: 2009-02-03 16:50:0
y> rc(x)
> 2 # the name x, and a temporary reference as parameter
> py> rc([])
> 1 # only the temporary reference
> py> x = y = []
> py> rc(x)
> 3
> py> x = ()
> py> rc(x)
> 954 # the empty tuple is shared
That reminds me, you can use the g
ld be easy. Try to compile python in the cross compiling
environment and see what happens!
However if you are running Nucleus with Linux and want to run python
in the Linux bit of it then I'd suggest to use the packages available
for the Linux side of it. (Eg if it is running debian then ap
rface file? Should the user defined header be placed
> > in the /usr/include directory?
> >
> > Any help on this is highly appreciated.
My advice to you is to compile the C stuff into a .so and use ctypes
instead of swig. You then write the interface code in python not C
and you'll have a lot more fun!
cython is very useful in this area too provided you don't mind an
extra dependency. If you are developing C code from scratch to
use with python, then write it in cython instead!
> Should you be putting a function body in a header file?
No
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
n to fold their work back into CPython when done too.
Sounds like a project to keep an eye on!
> Now the question is will this make Vista run faster?
Nothing could do that ;-)
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
enjoyed the encyclopedic nature of it. So if it appeals to you I'd
say go for it!
The fact that it doesn't use the latest version of python isn't a
problem - python doesn't change very quickly and emphasises backwards
compatibility, even for the jump to 3.x.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ect at 0xb7e897cc>
>>> Node(1,2,3).prev
1
>>> L = []
>>> for i in xrange(100):
... L.append(Node(1,2,3))
...
>>> import os
>>> os.getpid()
28203
>>>
(from top)
28203 ncw 20 0 43364 38m 1900 S0 1.9 0:04.41 python
So the Node class actually takes less memory 38 Mbytes vs 53 Mbytes for
the list.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ion in your program will rise.
I've noticed some programmers think in big classes and some think in
small classes. Train yourself to do the other thing and your
programming will improve greatly!
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
at C calls doubles.
When you do
>>> float( 0.222)
0.1
Python prints as many decimal places as are significant in the answer.
This is covered in the FAQ
http://www.python.org/doc/faq/general/#why-are-floating-point-calculations-so-inaccurate
If you want more precision use the built in decimal module or the
third party gmpy module.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
e here
http://packages.debian.org/sid/python-htmlgen
But I think its original website is gone.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
t;"
def search(self, r, s):
"""
Do a regular expression search and return if it matched.
"""
self.value = re.search(r, s)
return self.value
def __getitem__(self, n):
"""
Return n'th matched () item.
Note so the first matched item will be matcher[0]
"""
return self.value.group(n+1)
def groups(self):
"""
Return all the matched () items.
"""
return self.value.groups()
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ds"
This builds a set of all the files on the filesystem and prints
Found 314492 files in 1.152987957 seconds
on my laptop, using about 19 MB total memory
You could easily enough put that into an sqlite table instead of a set().
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
>>
> >> On Linux: no.
> >
> > I wonder if there is no way to emulate ptys from userspace?
>
> Didn't I just answer that question?
>
> On Linux: no.
Actually you could do it with an LD_PRELOAD library
Intercept open("/dev/ttyS0",...). You
dology above then when you re-organize (or refactor to
use the modern jargon) the code you can be 100% sure that you didn't
break anything which is a wonderful feeling.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
odule_name") you can then click in its output window to go
to the correct line of code.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
f the
other which would then speed up the two access patterns enormously.
You needn't mmap the two arrays (files) at the same time either.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
the most common class (several hundred thousand
instances!).
When doing these optimisations I ran a repeatable script and measured
the total memory usage using the OS tools (top in my case).
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Ole Streicher wrote:
> Hi Nick,
>
> Nick Craig-Wood writes:
> > mmaps come out of your applications memory space, so out of that 3 GB
> > limit. You don't need that much RAM of course but it does use up
> > address space.
>
> Hmm. So I have
27;.0')
except OSError:
pass
Which isn't racy. Or if you wanted to be more thorough
import errno
try:
os.rename(paths.xferin_dir+'/COMM.DAT',paths.xferin_dir+'/COMM.DAT'+'.0')
except OSError, e:
if e.errno != err
Steven D'Aprano wrote:
> On Tue, 28 Apr 2009 14:30:02 -0500, Nick Craig-Wood wrote:
>
> > t123 wrote:
> >> It's running on solaris 9. Here is some of the code. It's actually
> >> at the beginning of the job. The files are ftp'd over. Th
andler, item)
menuBar.Append(submenu, menuLabel)
self.SetMenuBar(menuBar)
That is the way I normally do it anyway!
You create the submenu as a seperate menu then attach it to the
menuBar with the label.
Note there is a wxpython list also which you may get more help in!
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
; Any thoughts?
Read up on introspection and learn how to look up through the stack
frames.
When you've mastered that look for an object matching self in all the
locals in those stack frames.
That will give some kind of answer.
I have no idea whether this will work - the keyboard of my phone is
too small to produce a proof ;-)
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
gt;> p.wait() # returns the error code
0
>>>
There was talk of removing the other methods from public use for 3.x.
Not sure of the conclusion.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
uot; returned something useful also!
You could do this by replacing your current __init__.py (which just
contains "from _psutil import *") with _psutil.py
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ts and the
documentation then submit the patch to the python bugtracker.
If I couldn't fix it then I'd report it as a bug.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
code byte 0xc2 in position
1: ordinal not in range(128)
>>> unicode('[\xc2\xa9au]')
Traceback (most recent call last):
File "", line 1, in
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position
1: ordinal not in range(128)
>>> L.__unicode__
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'list' object has no attribute '__unicode__'
>>> unicode(str(L),"utf-8")
u'[\xa9au]'
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
he C++ symbols into the python code at runtime
with ctypes. A bit of C++ implements the shims for the callbacks from
python -> C++ (which are exported by ctypes).
> P.S. I want to develop on Linux not Windows.
Should be just the same on both. Once you've made your setup.py (for
def __init__(self):
usage = '''Usage: %prog [options] YYMMDD
%prog -h|--help
'''
parser = OptionParser(usage=usage)
parser.add_option("-n", "--no-newline", dest="nonl",
it follows a very dumb, completely reversible
> (uninstallable) process of symlinking those files into the system
> directory structure.
Once you've got that well formed directory structure it is very easy
to make it into a package (eg deb or rpm) so that idea is useful in
general for package managers, not just stow.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
now what I mean), just to the left of the
> RETURN key. Emacs is my editor of choice, and I've never once come
> across anything like this.
You probably haven't used MAC OS X then! I vnc to a mac and use emacs
and I just can't type a #. "Ctrl-Q 43 Return" is my best effort!
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
;", line 5, in getMeasurement
NotImplementedError
>>> base.setPressure(14)
Traceback (most recent call last):
File "", line 1, in
File "", line 7, in setPressure
NotImplementedError
>>>
>>> real = RealDevice("/dev/ttyS1")
>>> real
RealDevice('/dev/ttyS1')
>>> real.getMeasurement()
0
>>> real.setPressure(14)
>>> real.getMeasurement()
14
>>>
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
callbacks or deferred objects).
To get your program to do something immediately after it is started,
use reactor.callLater() before calling reactor.run().
You can't mix and match programming styles with twisted - it is all
asynchronous callbacks or nothing in my experience! That takes a bit
of
if not out:
break
yield out
g = Grouper(5, xrange(20))
print list(g)
g = Grouper(4, xrange(19))
print list(g)
Which produces
[(0, 1, 2, 3, 4), (5, 6, 7, 8, 9), (10, 11, 12, 13, 14), (15, 16, 17, 18, 19)]
[(0, 1, 2, 3), (4, 5, 6, 7), (8, 9, 10, 11), (12, 13, 14, 15), (16, 17,
plejson as json
Is more pythonic... You aren't relying on what came with particular
python versions which may not be true in jython/ironpython/etc.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
be even a bit
> easier.
I'd use pygame for a really clean full screen display.
Probably a bit more work, but you'll get something really cool at the
end of it!
here is how to use matplotlib on a pygame surface
http://www.pygame.org/wiki/MatplotlibPygame
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
=10**6 because I got bored of waiting ;-)
map
9.85280895233
pmap
28.4256689548
So the pmap took nearly 3 times as long. I expect this is because the
task was divided into 5 sections each competing madly for the GIL.
I ran the same script under the latest jython beta which was very
interesting! pmap showing a slight improvement, and faster than
cPython!
$ jython2.5rc2/jython pmap.py
map
6.242000103
pmap
5.8881144
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
nder.py\n'
(printed with a 1 second pause between each line)
----
If you want to interact with a subprocess (eg send, receive, send,
receive) then use the pexpect module - buffering in subprocess will
cause you nothing but pain otherwise!
> (Or, is there a way to create a subprocess.Popen object from what I assume =
> is the process handle integer ?)
Errr, not as far as I know.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
uld potentially note that function types don't have enough
references to them when passed in as arguments to C functions? It
might slow it down microscopically but it would fix this problem.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
David Bolen wrote:
> Nick Craig-Wood writes:
>
> > ctypes could potentially note that function types don't have enough
> > references to them when passed in as arguments to C functions? It
> > might slow it down microscopically but it would fix this problem.
&
ointers etc. If you want to dig into virtual classes with multiple
bases or the STL then you are probably into the territory you
describe.
That said I've used C++ with ctypes loads of times, but I always wrap
the exported stuff in extern "C" { } blocks.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
radius -= 1
screen.fill(background_colour)
for dot in dots:
pygame.draw.circle(screen, foreground_colour, dot, radius, 1)
dots = [ (dot[0]+randrange(-1,2), dot[1]+randrange(-1,2)) for dot in
dots ]
pygame.display.flip()
if __name__ == "__main__"
Enabled
According to the man page smartctl also runs under windows/mac/solaris
etc
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
, press Ctrl-C Ctrl-C and have the output shown in a
different window. If you messed up, clicking on the error will put
the cursor in the right place in the code).
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Ben Finney wrote:
> Emile van Sebille writes:
>
> > On 6/4/2009 3:19 PM Lawrence D'Oliveiro said...
> > > In message , Nick Craig-
> > > Wood wrote:
> > >
> > >> You quit emacs with Ctrl-X Ctrl-C.
> > >
> > > That'
m concerned is that it is more of a port of CPython to a new
architecture than a complete re-invention of python (like PyPy /
IronPython / jython) so stands a chance of being merged back into
CPython.
--
Nick Craig-Wood -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
401 - 500 of 641 matches
Mail list logo