[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> > [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > > I'm using GMPY (see code).
> > [snip]
> >
> > If you are using gmpy you might as well do it like this.
> >
ly on topic, but does anyone know if there is a series 80
python? Or if the series 60 python runs on a series 80 phone (eg
communicator 9300/9500)?
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Ville Vainio <[EMAIL PROTECTED]> wrote:
> >>>>> "Nick" == Nick Craig-Wood <[EMAIL PROTECTED]> writes:
>
> Nick> Not entirely on topic, but does anyone know if there is a
> Nick> series 80 python? Or if the series 60 python runs on a
t; anything.
Are there any objects in gc.garbage?
Are you writing objects with __del__ methods? If so then that is your
problem probably.
Have you written any extension modules in C?
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
of improvement given that decent OSes have a very good cache
for stat results, and that parsing file names is very quick too,
compared to python.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
if it is I'd recommend "Dive into Python" by Mark Pilgrim as a good
first step. Its available for free in electronic form too. After
that you could read Programming Python.
Good luck!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
has <[EMAIL PROTECTED]> wrote:
> licence, practice = noun
> license, practise = verb
Tick
;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
other builtin somewhere that provides better functionality
> that I'm missing?
I suppose you could use itertools...
>>> from itertools import *
>>> L=range(10)
>>> (L1, L2, L3) = tee(L, 3)
>>> L2.next()
0
>>> L3.next()
0
>>> L3.next()
1
>
p you using ubuntu's python packages with
careful use of apt preferences and sources.list. Or you can swap to
ubuntu completely using apt-get!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
nique to cross build stuff for ARM. I found
the debian ARM python quite sufficient for my needs so I didn't have
to build that!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
"b","c"], "")
Traceback (most recent call last):
File "", line 1, in ?
TypeError: sum() can't sum strings [use ''.join(seq) instead]
>>>
I've no idea why this limitation is here... perhaps it is because pre
python2.4 cal
Alex Martelli <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> > Except if you are trying to sum arrays of strings...
> >
> > >>> sum(["a","b","c"], "")
> > Traceback (most recent
n my experience
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
up.py install
If on linux you can
python setup.py bdist_rpm
which builds an .rpm to install which you might prefer.
If you want a .deb use alien to convert the rpm
However in the case of this package
apt-get install python-pexpect
works for me on Debian and hence probably on ubuntu
ays install python packages like this - it has worked every time
so far!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
0
1.77
1.77
1.77
1.77
time.clock() is elapsed cpu time of just that process.
I think the precisions are the other way round on windows.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
"set) That took %.3f seconds: result %s" % (dt, a)
start = time.time()
a = 1.0
mine = set(range(0, 1))
for i in range(0, 3):
if 0 <= i < 1:
a += 1
dt = time.time() - start
print "comparison) That took %.3f seconds: result %s" % (dt, a)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ack(side=TOP, fill=X)
Button(self.toolbar, text='Quit', command=self.quit).pack(side=TOP,
fill=X)
def make_exception(self):
raise ValueError("Exception")
def make_callback_exception(self):
self.bang = 1
if __name__ == "__main__":
AppDemo().mainloop()
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Peter Otten <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> > How do you catch general exceptions in a Tkinter program.
> Overriding report_callback_exception() seems to work:
Thank you. That is exactly what I needed to know!
--
Nick Craig-Wood <[EMAIL PROTECTED]
ead %s running" % self.name
_do_stuff(1.0)
if __name__ == "__main__":
thread1 = KillableThread(name="thread1")
thread1.start()
_do_stuff(0.5)
thread2 = KillableThread(name="thread2")
thread2.start()
_do_stuff(2.0)
thread1.kill()
thread1.join()
_do_stuff(2.0)
thread2.kill()
thread2.join()
print "Done"
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ot;""
t = threading.Thread(target=do_child_stuff)
t.start()
# wait for child to finish
t.join()
def main():
print "Forking"
timeit.main(["-s", "from __main__ import fork_test", "fork_test()"])
print "Threading&qu
;5',
'-vframes', '1', '-s', '160x120', '-an', 'video.gif']
p = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE)
If you mix the two styles then you are probably heading for trouble
with argument quoting.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
h.
This is surely a job for twisted not threads? You'd be able to poll
all 250 devices at once with twisted...
This might be helpful (haven't tried it myself though)
http://twistedsnmp.sourceforge.net/
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
t;abcdefgh\nabc\n")
>>> p = subprocess.Popen(["cat"], stdout = subprocess.PIPE, stdin = inp)
Traceback (most recent call last):
File "", line 1, in ?
File "/usr/lib/python2.4/subprocess.py", line 534, in __init__
(p2cread, p2cwrite,
File &qu
cd build/lib.linux-i686-2.4
$ python2.4
Python 2.4.4c0 (#2, Jun 14 2006, 22:35:41)
[GCC 4.1.2 20060613 (prerelease) (Debian 4.1.1-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mi
\\n, \\t and
\\any_char into
CR, LF, TAB and any_char"""
def _translate(m):
return m.group(1).translate(_unescape_mapping)
return _unescape_re.sub(_translate, s)
(These functions have been through the optimisation mill which is why
they may not look immediately like how you might first think of
writing them!)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ensions with mingw under linux,
using -lpython2.4 which will run under windows.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
-the-box'.
Neither of those statements are true. It is fairly easy to build
python extensions using mingw hosted on linux which work with the
standard python.org install - see my other post in this thread.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://
ing to search for...
ctypes.pythonapi.PyThreadState_SetAsyncExc
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
major-mode. Syntax colouring, indentation
that sort of thing. There is also IM-Python for code navigation, and
bycycle repair man for refactoring support. You can run stuff at the
interactive python prompt from within emacs.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
7;m just learning!).
http://www.wxpython.org/maillist.php
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
appropriate maps for
the modern computing language territory.
I was born and bred on flow charts and I admit they were useful back
in the days when I wrote 1000s of lines of assembler code a week.
Now-a-days a much better map for the the territory is pseudo-code.
Python is pretty much executable pseudo-
def __str__(self):
return "%s(%s)" % (self.__class__.__name__, self.value)
a = NumX(4)
b = NumX(2)
print a,b
print a+b
print (a+b)/2
This prints
----
Nu
*
resource.getpagesize()
...
>>> print memory_used()
4575232
>>> a=1000*"x"
>>> print memory_used()
14577664
>>>
If anyone knows a (unix) portable way of doing this I'd be interested!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
>>>
You can then add to attributes in the subclasses
class MagicCharacter(Character):
attributes = Character.attributes | set(['spells', 'wand'])
>>> MagicCharacter('name', strength=10, dexterity=5, intelligence=3,
luck=0, spells=1)
QT licence, but
we decided we didn't want to have to incurr the additional expense of
renewing it.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
7;hello')
>>> random.shuffle(L)
>>> L
array('c', 'elohl')
>>> L.tostring()
'elohl'
Which is some way towards a mutable string...
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Christophe <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood a écrit :
> > There is also PyQT which we wrote off as we wanted to write commercial
> > applications too. As it happens we have a commercial QT licence, but
> > we decided we didn't want to have to
look a lot nicer
Eg debian
ii gtk2-engines-gtk-qt 0.7-1 theme engine using Qt for GTK+ 2.x
You get a control panel for GTK apps in the KDE control center also.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
pexpect has a timeout parameter exactly for this case
import os, pexpect, threading
def runyes():
print "Running yes command..."
pexpect.run('yes', timeout=5)
t = threading.Thread(target=runyes)
t.start()
t.join()
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ogram can then either poll the
global flag, or use sem_wait() and sem_trywait() on the semaphore.
Another option is to do nothing in the signal handler, and dedicate
one thread (preferably the initial thread) to wait synchronously for
signals, using sigwait(), and send messages to the other t
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
>
> > The only sensible things you can do from a signal handler is set a
> > global flag, or call sem_post on a semaphore, to record the delivery
> > of the signal. The remainder of the pr
es():
... print "Running yes command..."
... pexpect.run('yes', timeout=5)
...
>>> t = threading.Thread(target=runyes)
>>> t.start()
>>> Running yes command...
t.join()
[never returns]
I'd guess at differences between the pexpect versions. You could try
the pexpect from debian/testing easily enough I expect.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
helpful, eg
@echo off
set DEMOHOME=%CD%
set PYTHONHOME=%DEMOHOME%\Python24
set PYTHONPATH=%PYTHONHOME%;%DEMOHOME%\Demo\Python
set PYTHON=%PYTHONHOME%\python.exe
set PYTHONW=%PYTHONHOME%\pythonw.exe
set PATH=%PYTHONHOME%;%PATH%
start "Demo" "%PYTHONW%" "demo.pyw"
, []).append(process)
for process in self.by_pid.values():
try:
parent = self.by_pid[process.parent_pid]
#print "child",process
#print "parent",parent
parent.children.append(process)
ect
Create a temporary file with no directory entries.
Have a look at the functions in the tempfile module, mkstemp() in
particular (the posix way), or NamedTemporaryFile()
http://docs.python.org/lib/module-tempfile.html
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://
tell whether you have a copy or a
hardlink.
>>> import os
>>> file("z", "w").write("test")
>>> os.link("z", "z2")
>>> os.stat("z").st_ino
1685186L
>>> os.stat("z2").st_ino
1685186
our system, might copy the
> file.
The link(2) system call on linux never does that. Eg
>>> import os
>>> file("z", "w").write("test")
>>> os.link("z", "/dev/shm/z")
Traceback (most recent call last):
File "", line 1, in ?
OSError: [Errno 18] Invalid cross-device link
>>
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
closed'
bool indicating the current state of the file object. This is a
read-only attribute; the `close()' method changes the value. It
may not be available on all file-like objects.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ested #9a", True, 4, _test_time_limit,
"nested #9b", True, 5, _spin, 10)
_test_time_limit("nested #10", False, 7, _test_time_limit,
"nested #10a",False, 6, _test_time_limit,
"nested #10b",True, 5, _spin, 10)
#_test_time_limit("nested #11", False, 7, _test_time_limit,
# "nested #11a",True, 4, _test_time_limit,
# "nested #11b",False, 10, _spin, 5)
_test_time_limit("nested #12", False, 7, _test_time_limit,
"nested #12a",False, 6, _test_time_limit,
"nested #12b",False, 10, _spin, 5)
print "All tests OK"
test()
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
.o: ELF 64-bit LSB relocatable, AMD x86-64, version 1 (SYSV), not stripped
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2006-07-03, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> > Alex Martelli <[EMAIL PROTECTED]> wrote:
> >> DarkBlue <[EMAIL PROTECTED]> wrote:
> >> > try for 10 seconds
> >> >if d
for y in range(3):
... a[x][y] = i
... i = i + 1
...
>>> print a[1][1]
5
>>> a[2][1] = 'hello'
>>> print a
[[1, 2, 3], [4, 5, 6], [7, 'hello', 9], [10, 11, 12]]
Numeric/scipy/numpy/whatever-it-is-called-today supports
multidimensional arrays too I think and that may be more appropriate
if you are doing heavy numerical work.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
p://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012
That releases the controlling terminal from your job and it exits
from the process group.
You could probably close / redirect stdin/out/err too. Search for
daemonize.py and you'll find a module which does all this.
--
o.1 => /lib/tls/i686/cmov/libnsl.so.1 (0xb7aa9000)
libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7aa5000)
/lib/ld-linux.so.2 (0x8000)
If there are any missing things then you need to re-install those
packages.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-woo
this using stdin
>>> cmds="""read A
... read B
... read C
... echo $C $B $A"""
>>> out = Popen(cmds, shell=True, stdin=PIPE)
>>> out.communicate("""one
... two
... three""")
three two one
(None, None)
>>>
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
es of the language, but
otherwise it is a solid book with lots of good stuff in. The section
on programming with TK is very good too - I keep coming back to that
section.
...
I'd recommend the first and the last from your list to start with,
"Dive into Python" and "Progr
user0m1.000s
sys 0m0.036s
$ time python2.4 -c pass
real0m0.015s
user0m0.008s
sys 0m0.007s
Over all I'm very impressed - it is great to have a new implemention
of Python. I'm not sure mono is showing it off to its full extent
though!
--
Nick Crai
svc/bin/dlltool --dllname python24.dll --def python24.def
--output-lib libpython2.4.a
# Move the files into the correct place
mv -i python24.dll python24.def libpython2.4.a /usr/i586-mingw32msvc/lib/
After that lot you can build python extensions with mingw under linux,
using -lpython2.4
--
Nick Cra
27;t help you there.
You want to tell distutils that the compiler is just gcc somehow and
takes the same options. Not sure how you do that.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
d like someone to tell me that PyQT, tkinter or PyGTK does
it all for me, but from my searching on the subject I doubt it is
going to be that easy!
Thanks
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
TheSeeker <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> > Does anyone have some hints / tips / experience with making a cross
> > platform systray icon? It should work on Windows, Gnome and KDE at
> > minimum.
> You might do a search for TaskBarIcon in th
N/Cookbook/Python/Recipe/475155
Thanks anyway
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Tim Golden <[EMAIL PROTECTED]> wrote:
> if os.path.isfile (filepath):
>print filepath
You might get a more accurate result using
os.access(filepath, os.X_OK)
instead of
os.path.isfile(filepath)
Which checks the file is executable
--
Nick Craig-Wood <[
Tim Golden <[EMAIL PROTECTED]> wrote:
> [Nick Craig-Wood]
>
> | Tim Golden <[EMAIL PROTECTED]> wrote:
> | > if os.path.isfile (filepath):
> | >print filepath
> |
> | You might get a more accurate result using
> |
> | os.
s return False for X_OK under
> Win32. I'm happy to submit the patch, but is it worth it?
Wouldn't returning X_OK as true if the file exists be more sensible?
Ie the file might be executable, you'll have to try it, rather than,
no this file is definitely not executable...
-
on-dev about what you've done
Thats what I've done in the past anyway!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ds just fine.
RSI is a complicated disease - there are lots of different forms of it
all caused by different things. You'll need some professional advice
to sort it out.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
)
which is nearly as neat as qw//, but not quite since the split() bit
comes at the end so it doesn't notify you that you have an array of
strings rather than a string.
I don't expect a replacement for %w{}, qw// to ever be added to
python, it is not the python way. And the python way is why I am now
a python programmer not a perl programmer!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Duncan Booth <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
>
> > In python when making __slots__ or module.__all__ you end up typing
> > lists of objects or methods and they turn out like this which is quite
> > a lot of extra typ
Moreover match becomes a string method. No need for extra importing
> re and applying re.compile(). Both can be done in str.match() if
> necessary.
I'm happy with the re module. Having transitioned from perl to python
some time ago now, I find myself using many fewer regexps due to the
much better built in string methods of python. This is a good thing,
because regexps should be used sparingly and they do degenerate into
line noise quite quickly...
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
and .jar, and
openoffice and all of its many extensions.
If you are feeling really paranoid then encrypt it.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
n python.
http://svn.mythtv.org/trac/
A nice extra is that it is written in python.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
late to ''.
None is the traditional value to use for value not present, then you'd
get this for the function
def mainFunction(var, template=None):
if template is None:
template = 'base'
And this for the calling bit
if not_set_properly(template):
template = None
return mainFunction(var, template)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
urn var * 2
>
But yes, defining a sentinel like this is a good idea.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
-th port?
Also are you running as adminstrator? You may need admin rights to
open a serial port under windows (I'm not sure).
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
eamonisation under unix.
I'm not sure how you do open stdout to /dev/null in python though!
I suspect something like this...
import posix
posix.close(1)
posix.open("/dev/null", posix.O_WRONLY)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Tue, 28 Nov 2006 04:30:09 -0600, Nick Craig-Wood
> <[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
>
> >
> > If you run this
> >
> > import os,sys,time
> > print
Mitja Trampus <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
> > I'm not sure how you do open stdout to /dev/null in python though!
> > I suspect something like this...
> > import posix
> > posix.close(1)
> > posix.open("/dev/null",
quot;"
end_time = time() + timeout
output = ""
while time() < end_time:
try:
output += p.stdout.read(1024)
except IOError, e:
if e.errno != EAGAIN:
raise
return output
p.stdin.write("ls\n")
print read_output(p)
p.stdin.write("uname -a\n")
print read_output(p)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
mkdir() works just like its C equivalent, see
> http://docs.python.org/dev/lib/os-file-dir.html:
>
> "Where it is used, the current umask value is first masked out."
>
> Use os.chmod() after os.mkdir() to get the desired permissions.
I think you meant use os.umask(0) befor
st'
Size: 4096Blocks: 8 IO Block: 4096 directory
Device: 806h/2054d Inode: 2453906 Links: 2
Access: (0770/drwxrwx---) Uid: ( 518/ ncw) Gid: ( 518/ ncw)
Access: 2006-12-02 09:48:04.0 +0000
Modify: 2006-12-02 09:48:04.0 +
Change: 2
os.mkdir() ?
>
> No, I didn't. What is the difference/advantage of that approach?
If you use use os.umask(0) then the os.mkdir(dir, perms) will create
the directory with exactly those permissions, no chmod needed.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
Martin v. Löwis <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood schrieb:
> > So it looks like python mkdir() is applying the umask where as
> > /bin/mkdir doesn't. From man 2 mkdir
>
> Actually, mkdir(1) has no chance to not apply the umask: it also
> has to us
or x in range(0,12):
(x + 3) & ~0x3
Which prints 0,4,4,4,4,8,8,8,8,12...
You could also consider the funky
x>>2<<2
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
o read the return code of the command and
its stderr both of which you'll need if you are programming
defensively!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
p://pexpect.sourceforge.net/
>>> import pexpect
>>> p = pexpect.spawn("python")
>>> p.expect(">>>")
0
>>> p.sendline("print 10\n")
10
>>> p.readline()
' print 10\r\n'
>>> p.readline()
'10\r\n&
uages like Python when used in a web environment.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
not
> limited to use the generic *args and **kw.
If you don't want to use a register() function on each class you could
introspect like this (untested) to make the registry :-
registry = {}
for obj in sys.modules[__name__].__dict__.values():
try:
if issubclass(obj, Base):
):
"""Quote all the metacharacters in the args for the unix shell"""
return " ".join([re.sub(r"([^A-Za-z0-9_])", r"\\\1", string) for string in
args])
>>> print quotemeta(['a', "'b", 'c'])
a \'b c
> (or better, subprocess.call).
A good idea!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
ill tell you how to use it.
I've broken a lot of serial port drivers with that program ;-)
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
oes lock up it
is a driver bug.
Here you'll find a little program I wrote which, with the help of a
loopback connector, you can check your serial port out
http://www.craig-wood.com/nick/pub/cambert.exe
Run the program from a cmd prompt and it will tell you how to use it.
I've broken a lot
ent and accurate style -
this matches the next character which gets added back into the string.
>>> re.sub(r",([^\s])", r", \1", s)
'One, Two, Three, Four, File'
>>>
This shows a fundamental difference between the two methods
>>> t
not post the output.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
as overwritten.
Maybe it is a string you can identify... You'll also want to start
reading the gdb manual on breakpoints and watchpoints at this moment!
Find memory corruptions can be tricky and time consuming.
Valgrind can help also.
Good luck!
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
oto err;
}
label[i] = xstrdup(item_cstr);
Py_DECREF(item);
item = 0;
[snip]
err:;
PyErr_Print();
out:;
if (value)
Py_DECREF(value);
if (item)
Py_DECREF(item);
return rc;
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
achine
generating all possible matches at each point.
Luckily the python regexp matcher is written in python, so you have
access to the state machine directly if you want.
Take a look at sre*.py in the python library and you might be able to
work out what to do! I had a brief look myself, and it
looked
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood wrote:
>
> > A regular expression matcher uses a state machine to match strings.
>
> unless it's the kind of regular expression matcher that doesn't use a
> state machine, like the one in Pyt
conversions by hand. It is a bit
tedious but a good editor with macros will let you fly through the
job. I used emacs.
--
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list
sys 0m0.068s
> # I used python2.5 and perl 5.8.6
Playing for the other side temporarily, this is nearly twice as fast...
$ time perl -lne 'print if m/destroy/oi' bigfile >pl.out
real0m0.133s
user 0m0.120s
sys 0m0.012s
vs
$ time ./z.pl >pl.out.orig
101 - 200 of 641 matches
Mail list logo