How can I wrap a binary file-like object with an IO stream?

2013-03-21 Thread Will McGugan
opriate IO stream that handles the encoding/decoding. I'm sure I could implement the logic myself by looking at the mode/ encoding and return the appropriate IO interface, but I was hoping there was something in the stdlib to do this, or some pre-existing code I can lift? Thanks in advance

Re: Worthwhile to reverse a dictionary

2005-12-14 Thread Will McGugan
gt; There may be a better solution to your original problem (if you post more details Im sure there will be plenty of suggestions), but the following should reverse a dictionary.. >>> testdict = dict(a=1, b=2) >>> reversedict = dict( (value, key) for key, value in

Re: Invoking Unix commands from a Python app

2005-12-17 Thread Will McDonald
On 16 Dec 2005 08:45:01 -0800, Rob Cowie <[EMAIL PROTECTED]> wrote: > Excellent... just the thing I was looking for. Thanks. > > Does anyone know of a unix app that could be used to monitor the > duration of processes etc.? If you have control over starting the program then &

Re: Interesting little "gotcha" with generators

2005-12-22 Thread Will McGugan
control flow > command. For example, you can't have "return" with an argument inside a > generator. > > Too bad "return" wasn't entirely forbidden within generators, and > "yield" without an argument mandated instead. Oh well, too let

Re: Simple question on Parameters...

2005-12-28 Thread Will McGugan
ath(self, path, closePath=True, outlineColor=(1.0, 1.0, 1.0, 1.0), fillColor=(0.0, 0.0, 0.0, 0.25)): It all depends on what you find the most elegant solution. Im guessing you will use color values a lot, so I would recommend writing a simple class. Its also more natural to refer to the comp

Re: Simple question on Parameters...

2005-12-28 Thread Will McGugan
or or Color(1.0, 1.0, 1.0, 1.0) fillColor = fillColor or Color(0.0, 0.0, 0.0, 0.25) Will McGugan -- http://www.willmcgugan.com "".join({'*':'@','^':'.'}.get(c,0) or chr(97+(ord(c)-84)%26) for c in "jvyy*jvyyzpthtna^pbz") -- http://mail.python.org/mailman/listinfo/python-list

Pyrex on Darwin, gcc 3.3 optimization trouble

2005-12-30 Thread Will Ware
st an approach to debugging this? I'm comfortable on Linux but I can't find my way out of a paper bag on a Mac. Also, is there a Pyrex or distutils option for limiting the compiler optimization level, ideally on a per-platform basis? Thanks much Will Ware -- http://mail.python.org/m

Re: Pyrex on Darwin, gcc 3.3 optimization trouble

2006-01-01 Thread Will Ware
In case anybody else has this problem, the solution is to add "-O" in extra_compile_args, which will override the "-O3" normally used. This is done in the setup.py file. -- http://mail.python.org/mailman/listinfo/python-list

Re: OpenGL

2006-01-22 Thread Will McGugan
functional? > Thanks > Something _like_ a PyOpenGL implementation? What about PyOpenGL itself? http://pyopengl.sourceforge.net/ Will McGugan -- http://www.willmcgugan.com "".join({'*':'@','^':'.'}.get(c,0) or chr(97+(ord(c)-84)%26) for c in "jvyy*jvyyzpthtna^pbz") -- http://mail.python.org/mailman/listinfo/python-list

Persistant dictionary with lockable elements

2006-07-12 Thread Will McGugan
ashes. The Shelve module seems ideal for this, but because the server will be multithreaded I would like to be able to lock individual elements of the shelve while they are being processed (not just the entire Shelve object). Is there some way of using Shelve like this, or should I just move to a

Re: wxPython Grid XY Coordinates question

2006-07-14 Thread Will McGugan
ent) coordinates. If you have the mouse position in screen coordinates, you will need to convert them with the ScreenToClient for your grid. Will McGugan -- work: http://www.kelpiesoft.com blog: http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple file writing techiques ...

2006-07-19 Thread Will McGugan
his... with open('somefile','w') as fout: fout.writelines( line+"\n" for line in convertedData ) > ... or maybe some hybrid of the two which writes chunks of the > convertedData list out in one shot ... The OS should buffer it for you. Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

Re: wxPython: wxStaticBitmap and large images

2006-07-20 Thread Will McGugan
map. An alternative may be to place your bitmap in html and use a wxHtmlWindow to display it. Will McGugan -- http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

iter(callable, sentinel)

2006-07-27 Thread Will McGugan
Hi, I've been using Python for years, but I recently encountered something in the docs I wasnt familar with. That is, using two arguements for iter(). Could someone elaborate on the docs and maybe show a typical use case for it? Thanks, Will McGugan -- work: http://www.kelpiesoft.com

Python-like C++ library

2006-08-23 Thread Will McGugan
ace C++ with Python in any way, just to emulate the strings / containers / slicing etc. I did google for it but my search terms were too vague... Thanks in advance, Will McGugan -- http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

Re: wxpython problems using GLCanvas

2006-10-09 Thread Will McGugan
and i can't interact > with my machine. I hava only to press power button.. what will > cause it? the code i use is exactly the code of the demo > > If using openGL is so difficult to do together with wxpython, what > toolkit can i use do do 3d graphics? Simple graphic

Alternative constructors naming convention

2006-10-11 Thread Will McGugan
= Color.FromHtml(r, g, b) c = Color.from_html(r, g, b) Will McGugan -- http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Alternative constructors naming convention

2006-10-12 Thread Will McGugan
Steven Bethard wrote: > Are you really using staticmethod and calling __new__? It's often much > easier to use classmethod, e.g.:: > > class Color(object): > ... > @classmethod > def from_html(cls, r, g, b): > ... > # convert r, g, b to normal

Re: 3d programming without opengl

2006-11-01 Thread Will McGugan
nelson - wrote: > hi! >i want to build up a simple 3d interactive geometry application in > python. Since i want to run it without 3D acceleration (a scene will > be quite simple) I was wondering if there was a library in python that > allow me to build 3D graphic without

Python netstring module

2006-06-04 Thread Will McGugan
Hi folks, I have just posted a python 'netstring' module on my blog. Comments welcome! http://www.willmcgugan.com/2006/06/04/python-netstring-module/ Regards, Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

Freezing a static executable

2006-06-04 Thread Will Ware
libdl.so.2 => /lib/libdl.so.2 (0xb7f56000) libutil.so.1 => /lib/libutil.so.1 (0xb7f52000) libm.so.6 => /lib/tls/libm.so.6 (0xb7f2d000) libc.so.6 => /lib/tls/libc.so.6 (0xb7dff000) /lib/ld-linux.so.2 (0xb7f86000) What stupid thing am I doing wrong? TIA for any adv

Chess module blog

2006-06-18 Thread Will McGugan
://www.willmcgugan.com/2006/06/18/chesspy/ Regards, Will McGugan -- work: http://www.kelpiesoft.com blog: http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Python & chess

2006-08-24 Thread Will McGugan
brary for these things > (http://www.alcyone.com/software/chess/). Does anyone konw about more > chess related modules? I have written a chess module that may be of use to you. http://www.willmcgugan.com/2006/06/18/chesspy/ Will McGugan -- work: http://www.kelpiesoft.com blog: http://www.wil

Re: Interfacing my chess client with GNU chess using python

2006-09-18 Thread Will McGugan
r better ways of doing it. Any help would be appreciated. > The subprocess module may help you... http://docs.python.org/dev/lib/module-subprocess.html Will McGugan -- http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

SSL certificate meta data

2006-09-25 Thread Bernd Will
Hello everybody,   please help me with this topic:   Working at a big company (+100.000 employees worldwide), we have an amount of data centers and shared services where our webservers, backend server etc. are located. Now it happens from time to time, that certificates are expired and

__init__ style questions

2006-10-02 Thread Will McGugan
rors? 4) This does seem like a good candidate for __slots__, since there will could be large-ish lists of Vector3Ds. But is it a premature optimization? If it was just for myself or other experienced programmers I wouldn't be bothered about having the ability to do stupid things, because I si

Re: __init__ style questions

2006-10-02 Thread Will McGugan
Duncan Booth wrote: > No it isn't Pythonic. Why not just require 3 values and move the > responsibility onto the caller to pass them correctly? They can still use > an iterator if they want: > > Vector3D(a, b, c) > Vector3D(*some_iter) I kind of liked the ability to partially use iterato

Re: __init__ style questions

2006-10-02 Thread Will McGugan
Duncan Booth wrote: > > Yes, it would, although since the implication is that your class expected > numbers and the file iterator returns strings I'm not sure how much it > matters: you are still going to have to write more code than in your > example above. e.g. > >v1 = Vector3D(float(n) for

Python work in UK

2006-11-23 Thread Will McGugan
omething in web development, applications, graphics or other interesting field. Here is a copy of my CV. http://www.willmcgugan.com/cvwillmcgugan.pdf Regards, Will McGugan -- http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.5 idle and print command How do I suppress a line feed?

2006-11-23 Thread Will McGugan
notejam wrote: > Hi, > I am having a problem with print statements always cause a line feed. > I need to print a line of text, then the next print statement will > start printing where the last one stopped rather than drop down a line. > > In basic we can do this with print &quo

Re: Python 2.5 idle and print command How do I suppress a line feed?

2006-11-23 Thread Will McGugan
notejam wrote: > Hi, > I am having a problem with print statements always cause a line feed. > I need to print a line of text, then the next print statement will > start printing where the last one stopped rather than drop down a line. > > In basic we can do this with print &quo

Re: Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread Will McGugan
> #!/usr/bin/python -OO > import math > import sys > import psyco > > psyco.full() > > def primes(): > primes=[3] > for x in xrange(5,1000,2): > maxfact = int(math.sqrt(x)) > flag=True > for y in primes: > if y > maxfact: > break >

Re: Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread Will McGugan
Steve Bergman wrote: > Just wanted to report a delightful little surprise while experimenting > with psyco. > The program below performs astonoshingly well with psyco. > > It finds all the prime numbers < 10,000,000 Actualy, it doesn't. You forgot 1 and 2. Will

Re: Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread Will McGugan
Beliavsky wrote: > > The number 1 is not generally considered to be a prime number -- see > http://mathworld.wolfram.com/PrimeNumber.html . > I stand corrected. -- blog: http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

Re: extremely slow array indexing?

2006-11-30 Thread Will McGugan
e processing a lot of data? With numbers those big I would expect to have enough time to go make a coffee, then drink it. If you think it is slower than it could be, post more code for optimization advice... Will McGugan -- http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Ensure a variable is divisible by 4

2006-12-04 Thread Will McGugan
it divisable'. Do you want to check it is divisible or do you want to make it divisible? And if you want to make it divisible do you want to go to the next multiple of 4, or the previous? Will McGugan -- http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

Re: write an update manager in python/wxPython

2006-12-07 Thread Will McGugan
en there is a new version. It would require a little more effort if you want to have some kind of automatic update... Will McGugan -- blog: http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

Re: YouTube written in Python

2006-12-13 Thread Will McGugan
ers now... :-) > Nice quote re youtube on Python.org http://www.python.org/about/quotes/ Will McGugan -- blog: http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

Restrictive APIs for Python

2006-12-15 Thread Will Ware
_FRIENDS list is optional. Having defined _PUBLIC and optionally _FRIENDS, use something like the following to protect your class. Restricting the API will incur a performance overhead, so it's best to do it under the control of some sort of debug flag. if debug_flag: from restrictive imp

Re: Restrictive APIs for Python

2006-12-15 Thread Will Ware
Gabriel Genellina wrote: > In Python, the usual way of saying "don't play with me" is prepending > an underscore: _private Thanks, I am familiar with that. > BTW, have you *ever* tested your code? Yes, we have a QA process. The problem is not that the code doesn't work, it does. It was developed

Re: I'm looking for an intelligent date conversion module

2006-12-16 Thread Will McGugan
mthorley wrote: > Greetings, I'm looking for a python module that will take a datetime > obj and convert it into relative time in english. > For example: 10 minutes ago, 1 Hour ago, Yesterday, A few day ago, Last > Week, etc > I feel for you. I'm always on the lookou

Re: trouble getting google through urllib

2006-12-19 Thread Will McGugan
"&" and "%7C", so I'm > thinking thats the problem, does anyone know how I would make it keep > the url as I intended it to be? > Google doesnt like Python scripts. You will need to pretend to be a browser by setting the user-agent string in the HTTP header.

Re: trouble getting google through urllib

2006-12-19 Thread Will McGugan
Duncan Booth wrote: > > > > Google doesnt like Python scripts. You will need to pretend to be a > > browser by setting the user-agent string in the HTTP header. > > > and possibly also run the risk of having your system blocked by Google if > they figure out

sys.exit versus raise SystemExit

2007-01-08 Thread Will McGugan
Hi, Is there any difference between calling sys.exit() and raise SystemExit? Should I prefer one over the other? Regards, Will McGugan -- blog: http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

Re: sys.exit versus raise SystemExit

2007-01-08 Thread Will McGugan
ption manually. In the same way that 'open' is prefered over 'file', even though they appear to do the same thing. Will -- blog: http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

Testing for the presence of input from stdin.

2006-01-23 Thread Will McDonald
e useage again. Is there a simple way to achieve this? Thanks, Will. Here's what I've got so far... #!/usr/bin/python # # hail - heads and tails import sys, os, getopt def hail(file,headlines=10,taillines=10): lines = file.readlines() sys.stdout.writelines(lines[:headlines])

Re: Testing for the presence of input from stdin.

2006-01-23 Thread Will McDonald
there waiting for input much like cat would. I think that's preferable, and simpler :), than implementing timeouts. Thanks. Will. -- http://mail.python.org/mailman/listinfo/python-list

Re: Testing for the presence of input from stdin.

2006-01-24 Thread Will McDonald
On 24/01/06, Roland Heiber <[EMAIL PROTECTED]> wrote: > Will McDonald wrote: > > Hi all. > > > > I'm writing a little script that operates on either stdin or a file > > specified on the command line when run. I'm trying to handle the > > s

Re: Question about idioms for clearing a list

2006-02-06 Thread Will McGugan
e and: > > (3) mylist = [] > > Why are (1) and (2) preferred? I think the first two are changing the > list in-place, but why is that better? Isn't the end result the same? I'm wondering why there is no 'clear' for lists. It feels like a common operation for mut

Re: Py2Exe security

2005-05-03 Thread Will McGugan
mpare with for example a program written > in a compiled language like C++? Is it easier to find the info in a > py2exe .exe than a c++ compiled c++? > Its not the exe file you need to be concerned about, its the pyc files that are created with it. I imagine the strings will be in plain

Re: wxPython custom list drawing?

2005-05-05 Thread Will McGugan
from some other toolkits) wx.VListBox allows you to render whatever you want for each item. You could also do something similar with a wx.Grid Will McGugan -- http://www.willmcgugan.com "".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-84)%

Reading image dimensions with PIL

2005-05-17 Thread Will McGugan
incomplete, but the image object is initialised with the image dimensions, which is what I need. It actualy works well enough, but I'm concerened about side-effects - since it seems an unconventional way of working with PIL. Can anyone see any problems with doing this? Or a better method?

Re: Reading image dimensions with PIL

2005-05-18 Thread Will McGugan
t only images above 640x480, although the general case will be something like 200x200 to avoid downloading thumbnails > > Checking just the first 1K probably won't save you too much time unless > you're over a modem. Are you using a byte-range HTTP request to pull > down the

Re: Reading image dimensions with PIL

2005-05-18 Thread Will McGugan
Fredrik Lundh wrote: > the "right" way to do this is to use the ImageFile.Parser class. see the > last snippet on this page for an example: > > http://effbot.org/zone/pil-image-size.htm Excellent, thanks. Will -- http://www.willmcgugan.com "".join( [

Re: PyGame and Rotozoom (Sorry if OT)

2005-05-20 Thread Will McGugan
ing up a Rect > right, but I'm not sure. Maybe this is a limitation of Rotozoom/Rotate? > > Any advice would be greatly appreciated. And yes, I'm a rank PyGame > newbie. > I'm not sure - haven't actually used rotozoom, but from the docs it returns a surfac

overhead of starting threads

2005-05-23 Thread Will McGugan
y any experience in this area that they could share? - before I start investigating myself.. I'm running on Windows, if thats relevant. Regards, Will McGugan -- http://www.willmcgugan.com "".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(

Re: overhead of starting threads

2005-05-23 Thread Will McGugan
head: profile, profile, profile. You'll have to do sample > runs and find your sweet-spot. It all depends on what you're doing in > the threads. > I haven't had much luck with the profile module in the standard library. It only shows me data from the main thread. Is there

Re: pygame 1.6 for windows (python2.4)

2005-05-24 Thread Will McGugan
bc wrote: > Hi All, > > Does anyone have any info concerning the windows pygame 1.6 for > python2.4? It doesn't seem to be available yet. Will pygame1.6 for > python23 work with python24? Have you been to the site? 1.6 is available, and there are versions for Python2.3

Re: pygame 1.6 for windows (python2.4)

2005-05-24 Thread Will McGugan
bc wrote: > Thanks for the reply, Will... I have been to the site, but I get a "URL > not found error" when I try the pygame 1.6 for python24 link; I guess > I will just keep trying until the HTML is fixed. > Does seem to be broken at the moment. I've uploaded

Re: overflowerror!!

2005-05-26 Thread Will McGugan
> for i in range(256): > data[i] = val > > print data > > How do i fill in the val 256 times into the array? 'B' creates bytes, and a byte can only store numbers in the range 0 to 255. Try using 'L' when creating your array. Will McGugan -- http://www.wi

Re: overflowerror!!

2005-05-26 Thread Will McGugan
[EMAIL PROTECTED] wrote: > I tried that. Still get an Overflowerror: unsigned long is less than > minimum. > You'll also need to reserve enough space for the 256 ints. Try this.. data = array('L', '\0' * 256*4) Will -- http://www.willmcgugan.com "&qu

Re: How to run functions in the background?

2005-05-30 Thread Will McGugan
ion but to (at the same time) > be able to send commands from it (e.g. pause, play etc...) > > How could I do this? Put your function in a thread, and add a queue to send your commands. Look up 'thread' and 'queue' in the help. Will McGugan -- http://www.willmcgugan.

Re: How to run functions in the background?

2005-05-31 Thread Will McGugan
they dont share data), then you should find it a breeze to set up. Will -- http://www.willmcgugan.com "".join({'*':'@','^':'.'}.get(c,0) or chr(97+(ord(c)-84)%26) for c in "jvyy*jvyyzpthtna^pbz") -- http://mail.python.org/mailman/listinfo/python-list

Re: maybe a bug in python

2005-06-05 Thread Will McGugan
.but when use["a"] or ("a","b"),the > tuple is longer than 1, it's no problem. > > ("a") is just a simple expression. You need to add a comma so that Python knows you want a tuple. Thusly... ("a",) Will McGugan -- http://www.willmcgugan.com "".join({'*':'@','^':'.'}.get(c,0) or chr(97+(ord(c)-84)%26) for c in "jvyy*jvyyzpthtna^pbz") -- http://mail.python.org/mailman/listinfo/python-list

Re: Dealing with marketing types...

2005-06-10 Thread Will McGugan
nd pointing out the > success stories of Python and Zope and language comparisons between > Python and Java. > > What experiences have those in the Python community had in these kinds > of situations? Marketing types need a bandwagon to jump on. Point out that Google is used by

Re: Dealing with marketing types...

2005-06-10 Thread Will McGugan
Diez B. Roggisch wrote: > Will McGugan wrote: > >> Marketing types need a bandwagon to jump on. Point out that Google is >> used by Google, ILM and NASA. > > > Certainly a true statement - but I've got the sneaky suspicion that the > first google was sup

Re: how to startup the default web browser to open a url?

2005-06-12 Thread Will McGugan
flyaflya wrote: > I want to startup the default web browser(ie...) to open a url, "execl" > can open a process, but when the process exit, the other process will > exit too, has any why to deal this problem? You want the 'webbrowser' module. http://docs.python.o

Re: Matrix Multiplication

2007-06-18 Thread Will McGugan
google.com/p/gameobjects/ Will McGugan -- http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

Re: finding an element in a string

2007-06-25 Thread Will Maier
print "Good." > > But that, obviously, will only respond "good" when one writes > "fine". I was looking for a way for the program to respond "good" > to any sentence that would contain the word "fine" in it. Since strings are

Re: Reversing a string

2007-06-27 Thread Will Maier
backward.reverse() ... return ''.join(backward) >>> rev("spam") 'maps' list.reverse() changes the list in-place. Instead of iterating over the items in the string sequence, you can just convert the input string outright. -- [Will [EMAIL P

Re: process stdin grab

2007-06-28 Thread Will Maier
hon? i need only to write to its > stdin, not read any information from it, and i don't really need > to know if my command worked for now, so error handling isn't > really an issue. I don't know of any magic to write to a running program's stdin. -- [Will [EMAIL PROTE

error return without exception set

2007-07-03 Thread Will McGugan
Hi, Can anyone suggest a likely cause for the following exception... Exception exceptions.SystemError: 'error return without exception set' in ignored Thanks Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

Re: error return without exception set

2007-07-03 Thread Will McGugan
ns when I'm debugging a wxWidgets application with Komodo, but I can't trap it. I'm guessing it must be a Komodo issue, because I dont get it if I run it without the debugger. Will -- http://mail.python.org/mailman/listinfo/python-list

Per thread data

2007-07-09 Thread Will McGugan
Hi, Is there a canonical way of storing per-thread data in Python? Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

Re: condor_compiled python interpreter

2007-07-11 Thread Will Maier
e you building for the standard universe? It shouldn't be too hard. See this thread[0] for some more bits, including a step-by-step. [0] https://lists.cs.wisc.edu/archive/condor-users/2007-March/msg00216.shtml https://lists.cs.wisc.edu/archive/condor-users/2007-March/msg00217.shtml

Re: getting text inside the HTML tag

2007-07-14 Thread Will Maier
n reading through SGMLParser documentation, but just can't > figure that out... You need to define handle_data. You may also want to look at HTMLParser in addition to the alternatives previously mentioned. http://docs.python.org/lib/module-sgmllib.html -- [Will [EMAIL PROTECTED]|http

Re: Newbie: freebsd admin scripting

2007-07-18 Thread Will Maier
ugh. > > I think you're referring to ConfigParser. This is the standard way > to do config files in Python, and it is very simple to use and > work with, so I would recommend using it. rc.conf is a shell script on BSD systems. The OP will need to write his own parser to read it. Ta

Re: Interpreting os.lstat()

2007-07-18 Thread Will Maier
os.lstat()." http://www.python.org/doc/current/lib/module-stat.html -- [Will [EMAIL PROTECTED]|http://www.lfod.us/] -- http://mail.python.org/mailman/listinfo/python-list

Re: Log Memory Usage

2007-07-19 Thread Will Maier
of anything in the standard library that does this sort of thing. Instead, you'll probably need to rely on your system's tools. sysstat is available on Linux and provides the sar(1) command for examining logs of various system attributes. The tool to use depends on the system you'r

Re: Log Memory Usage

2007-07-19 Thread Will Maier
On Thu, Jul 19, 2007 at 04:35:56AM -0500, Will Maier wrote: > On Thu, Jul 19, 2007 at 09:52:36AM +0100, Robert Rawlins - Think Blue wrote: > > I have a scheduled event which occurs every minute, i just need a > > code solution to give me the systems current memory consumptions

Re: Pure Python equivalent of unix "file" command?

2007-07-19 Thread Will Maier
On Thu, Jul 19, 2007 at 03:29:35PM -0400, W3 wrote: > Just a quick one... Is there such a thing? Debian et al ship Python bindings[0] for file(1)[1]. file works by using a file (/etc/magic) with 'magic' numbers in it to figure out the type of a file. Googling 'python magic&#

Re: How to check if an item exist in a nested list

2007-07-19 Thread Will Maier
gt;>> 'spam' in dinner True 'in' uses the __contains__() method implemented by lists. -- [Will [EMAIL PROTECTED]|http://www.lfod.us/] -- http://mail.python.org/mailman/listinfo/python-list

Re: Sorting dict keys

2007-07-20 Thread Will Maier
, 1 That means that doesn't return a sorted version of the list you're working with. Instead, it sorts the list itself. If you want to return a sorted list, use (duh) sorted: >>> sorted(l) ['eggs', 'spam', 'spam'] -- [Will [EMAIL PROTECTED]|http://www.lfod.us/] -- http://mail.python.org/mailman/listinfo/python-list

Re: Vector classes

2007-04-22 Thread Will McGugan
Mizipzor wrote: > During my coding Ive found two vector classes on the internet. Ive > modified them both a little but the do both have advantages and > disadvantages. > I'm working on a vector class at the moment, in my 'gameobjects' library. It's not really ready for public consumption, but fee

Cross platform Python app deployment

2007-07-30 Thread Will McGugan
Hi, Is there some reference regarding how to package a Python application for the various platforms? I'm familiar with Windows deployment - I use Py2Exe & InnoSetup - but I would like more information on deploying on Mac and Linux. TIA, Will McGugan -- http://www.willmcgugan.com

Re: passing vars to py scipts in cron jobs

2007-08-07 Thread Will Maier
at need arguments. This is commonly done with either sys.argv (a list of arguments passed when invoking the script) or os.environ (a dictionary of environment variables and values). Use either to instantiate your classes or run functions. -- [Will [EMAIL PROTECTED]|http://www.lfod.us/] -- http:

Re: Simple python iteration question

2007-08-14 Thread Will Maier
e the enumerate() builtin. >>> l = ['a', 'b', 'c'] >>> for i, v in enumerate(l): ... print i, v ... 0 a 1 b 2 c -- [Will [EMAIL PROTECTED]|http://www.lfod.us/] -- http://mail.python.org/mailman/listinfo/python-list

Re: My 'time' module is broken, unsure of cause

2007-08-23 Thread Will Maier
le that's shadowing the stdlib's time. To check: Python 2.4.4 (#1, Jul 26 2007, 14:42:10) [GCC 3.3.5 (propolice)] on openbsd4 Type "help", "copyright", "credits" or "license" for more information. >>> import time >>> print time.__file__ /usr/local/lib/python2.4/lib-dynload/time.so -- [Will [EMAIL PROTECTED]|http://www.lfod.us/] -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating a unique identifier

2007-09-07 Thread Will Maier
. 2.5 includes the uuid module for RFC 4122 universally-unique IDs: http://docs.python.org/lib/module-uuid.html -- [Will [EMAIL PROTECTED]|http://www.lfod.us/] -- http://mail.python.org/mailman/listinfo/python-list

Announcing BBCode parsing module

2007-03-10 Thread Will McGugan
Hi, I have written a BBCode parsing module that may be of use to some people. It turns BBCode in to XHTML snippets. See the following page if you are interested... http://www.willmcgugan.com/2007/03/10/bbcode-python-module/ Will McGugan -- blog: http://www.willmcgugan.com -- http

Re: execution speed increase after compile py code into exe?

2007-03-24 Thread Will McGugan
om running normally (not that I've actually tested it, > mind you). Actualy startup is faster for the apps that I have py2exe'd. I think this may be because all the modules are in one place and Python doesn't have to go searching for them. Will -- http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

Re: 16bit RGB with Image module

2007-03-27 Thread Will McGugan
m = Image.fromstring("RGB", (326, 325), pixel_data, "raw", "BGR;16") > im.show() > > Although I have no idea *why* it works, other than the fact that I'm now > using the correct number of bits per pixel. :) > > Anyone have thoughts on this? Well

Order of tuples in dict.items()

2007-10-14 Thread Will McGugan
Hi, If I have two dictionaries containing identical values, can I be sure that the items() method will return tuples in the same order? I tried an experiment with CPython and it does appear to be the case. >>> a=dict(a=1, b=1, c=2) >>> b=dict(c=2, a=1, b=1) >>>

Re: Simple HTML template engine?

2007-10-15 Thread Will McGugan
allen.fowler wrote: > Hello, > > Can anyone recommend a simple python template engine for generating > HTML that relies only on the Pyhon Core modules? > Mako (http://www.makotemplates.org/) sounds like what you want.. Will McGugan http://www.willmcgugan.com -- http://mail.pyt

Re: Simple HTML template engine?

2007-10-15 Thread Will McGugan
allen.fowler wrote: > Hello, > > Can anyone recommend a simple python template engine for generating > HTML that relies only on the Pyhon Core modules? > Mako (http://www.makotemplates.org/) sounds like what you want.. Will McGugan http://www.willmcgugan.com -- http://mail.pyt

generate tuples from sequence

2007-01-17 Thread Will McGugan
while True: yield tuple([i.next() for _ in xrange(count)]) Is this the most efficient solution? Regards, Will McGugan -- http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

Re: generate tuples from sequence

2007-01-17 Thread Will McGugan
Will McGugan wrote: > Hi, > > I'd like a generator that takes a sequence and yields tuples containing > n items of the sqeuence, but ignoring the 'odd' items. For example Forgot to add, for my purposes I will always have a sequence with a multiple of n items. Will

midipy.py on linux

2006-04-27 Thread Will Hurt
same thing available for linux[ie i can get raw midi data in as a list] and thats why no-ones bothered to compile midipy under linux? Thanks Will -- http://mail.python.org/mailman/listinfo/python-list

midi input

2006-04-29 Thread Will Hurt
on how to do this. thanks in advance will -- http://mail.python.org/mailman/listinfo/python-list

Re: What would YOU like to see in a txt to html converter?

2009-05-07 Thread Will Wang
> "Florian" == Florian Wollenschein > writes: Florian> As you might have mentioned I'm just working on a txt to html converter called Florian> "thc". This project is intended for me to learn Python and now pyQT4 to which I Florian> changed a few days ago (started with Tkint

<    1   2   3   >