Re: Getting a number out of a string

2005-09-27 Thread Will McGugan
Claudio Grondi wrote: > what about: > >>>>lst = [digit for digit in '06897'] >>>>lst > > ['0', '6', '8', '9', '7'] Or.. >>> list('06897') ['0', '6', &

New Python chess module

2005-09-29 Thread Will McGugan
mainly for the fun of it. I wrote a chess game in C++ a while back (http://www.chesscommander.com) and I thought it would be interesting to re-implement the chess library part in Python. Regards, Will McGugan -- http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

Re: New Python chess module

2005-09-30 Thread Will McGugan
gt; > >>>>[x for x in range(10) if 2 > [3, 4, 5, 6] > > Read about it in the reference: > http://www.python.org/doc/2.4.2/ref/comparisons.html > Thanks. I was aware of that, I've just never got in to the habbit of using it.. Will McGugan -- http://www.will

Re: New Python chess module

2005-09-30 Thread Will McGugan
There is a new version if anyone is interested... http://www.willmcgugan.com/chess.py It contains optimizations and bugfixes. Can anyone suggest a name for this module? pyChess is already taken... Will McGugan -- http://www.willmcgugan.com "".join({'*':'@',

Re: ASCII

2005-09-30 Thread Will McGugan
Tuvas wrote: > Is there a function that will take a char. and return the ascii value? > Thanks! > ord Will McGugan -- http://www.willmcgugan.com "".join({'*':'@','^':'.'}.get(c,0) or chr(97+(ord(c)-84)%26) for c in "jvyy*jvyy

Re: "no variable or argument declarations are necessary."

2005-10-02 Thread Will McGugan
ror: name 'a' is not defined >>> a = 1 >>> a + 1 2 Typos in variable names are easily discovered unless the typo happens to exist in the current context. 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: Contest snub?

2005-10-08 Thread Will McGugan
.. an irrational fear of snakes perhaps? Its not irrational if you are a gator! 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: wxPython question

2005-10-13 Thread Will McGugan
vpr wrote: > Hi > > Does anyone have some example code to create a wx dialog that apears > off screen on the bottom right hand corner and slides up into the > screen ? > Andrea Gavana does.. http://xoomer.virgilio.it/infinity77/eng/freeware.html#toasterbox Wil

Re: 1-liner to iterate over infinite sequence of integers?

2005-10-13 Thread Will McGugan
n itertools.count(): print i 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: 1-liner to iterate over infinite sequence of integers?

2005-10-13 Thread Will McGugan
Will McGugan wrote: > Neal Becker wrote: > >> I can do this with a generator: >> >> def integers(): >> x = 1 >> while (True): >> yield x >> x += 1 >> >> for i in integers(): >> Is the

Re: wxPython question

2005-10-18 Thread Will McGugan
better for the animation. HTH, 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: Converting a List into a String

2005-11-05 Thread Will McGugan
a, > > the output is > > f e d c b a > > How can i remove the spaces b/w each letter? print "".join(list) BTW list isnt a good name for a list, it hides the built in type. 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: Help With Python

2005-01-26 Thread Will McGugan
am completely new to programming! Thanks in advance! >>> print "Spam, " * 510 + "Spam" Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

Re: Help With Python

2005-01-26 Thread Will McGugan
>>> print "Spam, " * 510 + "Spam" Or if you have 2.4.. >>> print ", ".join( "Spam" for _ in xrange( 511 ) ) Although, the replys with links will ultimately be more helpful! Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

Re: stop program in komodo

2005-01-31 Thread Will McGugan
was just that the buffer had filled up with a squillion "helo"'s and was busy scrolling away.. Regards, Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

Database recommendations for Windows app

2005-06-22 Thread Will McGugan
have googled and found plenty of information on databases, its just that I dont have enough experience with databases to know which one is best for my task! Thanks in advance, Will McGugan -- http://www.willmcgugan.com "".join({'*':'@','^':'.&#x

Re: Database recommendations for Windows app

2005-06-22 Thread Will McGugan
Thanks for the replies. I think I'm going to go with sqllite for now. For the curious, Im writing an interface to a nutritional database. So you can type in a foodstuff and it will tell you whats in it.. Will McGugan -- http://www.willmcgugan.com "".join({'*':'

Re: Graphs/statistics using wxPython

2005-06-29 Thread Will McGugan
ures. Feel free to make requests or enhancements. [*] There are some size/offset bugs which I am aware of, but they are easily fixed. I just haven't got around to it yet. If you ever want to add an extra dimension, then using OpenGL with wxWindows is a breeze. See attached file for

frozenset question

2005-07-06 Thread Will McGugan
Hi, Are there any benefits in using a frozenset over a set, other than it being immutable? 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: frozenset question

2005-07-06 Thread Will McGugan
Qiangning Hong wrote: > On 7/6/05, Will McGugan <[EMAIL PROTECTED]> wrote: > >>Hi, >> >>Are there any benefits in using a frozenset over a set, other than it >>being immutable? > > > A frozenset can be used as a key of a dict: Thanks, but I meant

Re: frozenset question

2005-07-06 Thread Will McGugan
Steven D'Aprano wrote: > There is no significant speed difference between immutable and mutable > sets, at least for queries. Regardless of whether it is successful or > unsuccessful, mutable or immutable, it takes about 0.025 second to do > each test of item in set. Why would you need to opti

dictionary that discards old items

2005-07-22 Thread Will McGugan
here I read about it. Can anyone enlighten me? Regards, 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: dictionary that discards old items

2005-07-22 Thread Will McGugan
Michael Hoffman wrote: > Will McGugan wrote: > >> I need a collection class that behaves like a dictionary but when it >> reaches 'n' items it discards the oldest item so that the length never >> goes above 'n'. (Its for caching search results) >&

Re: First app, thanks people

2005-07-25 Thread Will McGugan
Jan Danielsson wrote: . > >Oh, I do have one more question though. I'm using wxPython, and when > I check for keys I use the evt.GetKeyCode() call, and compare it with > integers which I have found by printing what event.GetKeyCode() returns. > I would prefer a more portable way, since I assum

Re: Doubt C and Python

2005-08-23 Thread Will McGugan
praba kar wrote: > Dear All, >I want to know the link between c and python. >Some people with C background use Python instead > of programming in C.why? > Because I can create software many times faster. And its more fun. Will McGugan -- http://www.kelpieso

Re: aproximate a number

2005-08-28 Thread Will McGugan
>>> import math >>> math.ceil(5.7) 6.0 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: how to join two Dictionary together?

2005-08-30 Thread Will McGugan
DENG wrote: > dict1={...something...} > > dict2={...somethind else ..} > > dict1 + dict2 > > > that's does works ..:(, it's not like List... I think you want.. dict1.update(dict2) Will McGugan -- http://www.willmcgugan.com "".join({'*'

Replacing large number of substrings

2005-09-04 Thread Will McGugan
.. >>> dict_replace( "a b c", dict(a="x", b="y") ) "x y c" Regards, Will McGugan -- http://www.kelpiesoft.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Has anybody tried to make a navigation like Google?

2005-09-05 Thread Will McGugan
cular position in the results. Will McGugan -- http://www.kelpiesoft.com -- http://mail.python.org/mailman/listinfo/python-list

Re: which is more 'pythonic' / 'better' ?

2005-09-12 Thread Will McGugan
the code to _not_ throw the exception the majority of times. Otherwise the simple condition is better. Although I expect there is not much difference either way.. Will McGugan -- http://www.kelpiesoft.com -- http://mail.python.org/mailman/listinfo/python-list

Re: which is more 'pythonic' / 'better' ?

2005-09-12 Thread Will McGugan
> text = (line[n:n+1] or ['nothing'])[0] I was assuming that 'line' would be a string, not a list. Seems more likely give the name and context. Will McGugan -- http://www.kelpiesoft.com -- http://mail.python.org/mailman/listinfo/python-list

Re: which is more 'pythonic' / 'better' ?

2005-09-12 Thread Will McGugan
line' would suggest there was just one of them, so I assumed it was string. 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: Removing duplicates from a list

2005-09-14 Thread Will McGugan
'count' which must make a pass through every element of the list, which would be slower than the efficient hashing that set does. I'm also not sure about removing an element whilst iterating, I think thats a no-no. Will McGugan -- http://www.willmcgugan.com "".join

Re: Removing duplicates from a list

2005-09-14 Thread Will McGugan
;t know, and > I'll bet you don't either. Sure. But if I'm not currently optimizing I would go for the method with the best behaviour, which usualy means hashing rather than searching. Since even if it is actualy slower - its not likely to be _very_ slow. Will McGugan -- http:

Re: Python Search Engine app

2005-09-14 Thread Will McGugan
ery high speed operations on highly compressed binary > structures - which is not Python's forte. > > You might be able to put a Python interface over an engine written > in another language. Wasn't Google's first search engine actualy written in Python? Will McGugan -- h

Re: Create and display an email

2005-09-15 Thread Will McGugan
gt; There has to be something obvious that I'm missing here. Any > suggestions? > I dont think there is anything in the standard library to help you here. Windows has an api called 'MAPI' which does this sort of thing. There may be bindings to it somewhere, or you

Re: Creating Pie Chart from Python

2005-09-15 Thread Will McGugan
ached piechartwindow.py). It can also be used to pre-generate images such as this.. http://www.foodfileonline.com/static/piecharts/pie01009.jpg Code is public domain. Will McGugan -- http://www.willmcgugan.com "".join({'*':'@','^':'.'}.get(c,0) or chr(97+

Re: Britney Spears nude

2005-09-15 Thread Will McGugan
Tim Peters wrote: > [john basha] > >>send me the britney nude photos > > > Because they're a new feature, you'll have to wait for Python 2.5 to > be released. She has just spawned a child process. Give her to Python 2.6 to get back in shape. Will McGu

Re: Creating Pie Chart from Python

2005-09-16 Thread Will McGugan
version of pyOpenGL / wxPython? Its only been tested on Windows, but it just uses basic OpenGL so there is not that much to go wrong.. 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

Creating properties with decorator like syntax

2005-02-17 Thread Will McGugan
setx(self, value): self.__x = value def delx(self): del self.__x Regards, Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating properties with decorator like syntax

2005-02-17 Thread Will McGugan
Will McGugan wrote: Hi, Is there any way of making properties using a decorator? The current way of creating a property seems inelegant. Something like this imaginary snippit would be nice, IMHO. class C(object): @make_property def x(self): def getx(self): return self.__x

namespace collisions

2005-02-17 Thread Will McGugan
it in a common location in my Python path, should I call it willsutil.py? TIA, Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

Re: PIL Expand Canvas

2005-02-19 Thread Will McGugan
wide - I will want to pad it left and right by 10 pixels with white space to make it a 200x200 square. Is this possible? You could create a new canvas of the larger dimensions, then copy the smaller one to the centre of it.. Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

Googlewhacker

2005-02-27 Thread Will McGugan
Hi folks, Has anyone seen 'Googlewhack Adventure'? http://www.davegorman.com/googlewhack.htm I wrote a script to generate Googlewhacks - thought I'd share it with you. I'd better stop running it as I fear Google may ban my IP for making 20 searches a seconds.. Will McGugan

Re: Googlewhacker

2005-02-27 Thread Will McGugan
Will McGugan wrote: Hi folks, Has anyone seen 'Googlewhack Adventure'? http://www.davegorman.com/googlewhack.htm I wrote a script to generate Googlewhacks - thought I'd share it with you. I'd better stop running it as I fear Google may ban my IP for making 20 searches a s

Re: Text To Speech with pyTTS

2005-02-27 Thread Will McGugan
/2005/1/19/266813.html and immediately tried it out. All I did was download the PyTTS package for Python (2.4, not 2.3), and install it, then ran Joey's sample above. It worked as advertised. This was on Windows XP SP2. I experience the same thing as Mike P. Im running on Windows 2K. Will Mc

Re: Faster way to do this...

2005-03-01 Thread Will McGugan
Harlin Seritt wrote: I've got the following code: nums = range(0) for a in range(100): nums.append(a) Is there a better way to have num initialized to a list of 100 consecutive int values? Isn't that equivalent to simply.. nums= range(100) Will McGugan -- http://mail.python.org/mailma

Re: Faster way to do this...

2005-03-02 Thread Will McGugan
Warren Postma wrote: Will McGugan wrote: Isn't that equivalent to simply.. nums= range(100) I remember the day I first realized that 900 lines of some C++ program I was working on could be expressed in three lines of python. Ahh. Lately I've found myself commenting C++ code with the

Hash of integers for use in Random module

2005-03-06 Thread Will McGugan
kes a hashable object rather than an integer directly. Which brings another question to mind. Are hashes of builtin objects in general consistent across platforms, or are they an implementation detail that could change? TIA, Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

Re: Hash of integers for use in Random module

2005-03-06 Thread Will McGugan
Will McGugan wrote: Hi, If I retrieve the hash of an integer, will it always return the same value across platforms? This reason I ask is that I want to produce a sequence of pseudo random numbers using the random module, that I can re-create later on. So I'll need to store the seed value

Re: Creating desktop icons for Innosetup file

2005-03-13 Thread Will McGugan
.. WorkingDir: {app}; HTH, Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

Re: computing a weighted sum

2005-03-16 Thread Will McGugan
lists are large. Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

html escape sequences

2005-03-18 Thread Will McGugan
Hi, I'd like to replace html escape sequences, like   and ' with single characters. Is there a dictionary defined somewhere I can use to replace these sequences? Thanks, Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

Re: html escape sequences

2005-03-18 Thread Will McGugan
Leif K-Brooks wrote: Will McGugan wrote: I'd like to replace html escape sequences, like   and ' with single characters. Is there a dictionary defined somewhere I can use to replace these sequences? How about this? import re from htmlentitydefs import name2codepoint _entity_re = re

Re: PIL and antialiasing problem

2004-12-02 Thread Will McGugan
would be great to have it working with those colorful smudged images. It will be terribly slow to separate them by hand. There are almost 15000 of them... Try running ImageFilter.MinFilter on the image before you thumbnail it. This should make dark lines thicker. HTH, Will McGugan -- http

Re: PIL and antialiasing problem

2004-12-02 Thread Will McGugan
Laszlo Zsolt Nagy wrote: Try running ImageFilter.MinFilter on the image before you thumbnail it. This should make dark lines thicker. HTH, Will McGugan You are my man! It worked perfectly! Statement: Sometimes PIL is better than Adobe Photoshop. :-) Happy to help :) I also found these with the

Re: Fun with Outlook and MAPI

2004-12-10 Thread Will McGugan
nfirmation dialogs with Outlook's MAPI dll. MS added them in a service pack as an anti-virus measure, so no work-around. Not all clients show these anoying dialogs though. Thunderbird definately doesn't. Regards, Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

Re: Fun with Outlook and MAPI

2004-12-10 Thread Will McGugan
esn't. There is actually a workaround. You're using Simple MAPI which has a I stand corrected. Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

Python Cookbook 2nd Ed

2005-03-28 Thread Will McGugan
Hi, Is the second edition of the Python Cookbook worth getting if you have the first edition? How much new material is there in the 2nd edition? Thanks, Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

BF interpreter in Python

2005-03-29 Thread Will McGugan
expert to give a one line generator expression with the same functionality.. Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

Re: Retrieve Icons Associated To An Extension?

2005-03-29 Thread Will McGugan
e Windows/Controls). That seems to do what you want.. Will McGugan -- http://mail.python.org/mailman/listinfo/python-list

Re: BF interpreter in Python

2005-03-30 Thread Will McGugan
Do Re Mi chel La Si Do wrote: Hi ! Good idea. I take this interpreter with jubilation. Can I add your URL at http://mclaveau.com/esolang ? Certainly, be my guest. Other question : do you know PATH ? (http://pathlang.sourceforge.net) Yes, a wonderfully expressive language! Will McGugan -- http

Re: Counting iterations

2005-04-08 Thread Will McGugan
Derek Basch wrote: Is there a better way to count iterations that this?: pets = 0 for i in pets: pets += 1 print "pet" + "#" + pets You can use 'enumerate' to get the index, but the code above wont work - you are trying to iterate over a non-sequ

Re: World First Cancer Immune Booster

2005-04-12 Thread Will McGugan
s is really low. Scamming money out of people with potentially fatal illnesses. I hope there's a level of hell devoted to spammers like this! Will McGugan -- http://www.willmcgugan.com "".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-

Re: Codig style: " or """

2005-04-13 Thread Will McGugan
t of any length, that way I dont need to change anything if I do need to insert a quote. I dont think its a matter of coding style, its purely a practical issue. If your PHB insists on consistency, I would just use """ Will McGugan -- http://www.willmcgugan.com "".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-84)%26) for c in "jvyy*jvyyzpthtna^pbz" ] ) -- http://mail.python.org/mailman/listinfo/python-list

Re: Supercomputer and encryption and compression @ rate of 96%

2005-04-14 Thread Will McGugan
lease implement this as a Python module. I would like to compress my mp3 collection to single bits. Will McGugan -- http://www.willmcgugan.com "".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-84)%26) for c in "jvyy*jvyyzpthtna^pbz" ] ) -- http://mail.python.org/mailman/listinfo/python-list

Re: Supercomputer and encryption and compression @ rate of 96%

2005-04-14 Thread Will McGugan
Fredrik Lundh wrote: Will McGugan wrote: Please implement this as a Python module. I would like to compress my mp3 collection to single bits. here's the magic algorithm (somewhat simplified): def algorithm(data): m = 102021 # magic constant d = [int(c) for c in str(1*2*3*4*5*m+5+

Behaviour of str.split

2005-04-18 Thread Will McGugan
Hi, I'm curious about the behaviour of the str.split() when applied to empty strings. "".split() returns an empty list, however.. "".split("*") returns a list containing one empty string. I would have expected the second example to have also returned an empty

Re: random number between 0 and 20

2005-04-20 Thread Will McGugan
[EMAIL PROTECTED] wrote: How can I generate a random number between 0 - 20 and store the number in nrrandom? Assuming its inclusive.. >>> from random import randint >>> nrrandom = randint(0,20) Will McGugan -- http://www.willmcgugan.com "".join( [ {'*':'@

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: 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
onents of the color by name, rather than an index to the tuple. 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: 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

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
more typical database solution? Thanks, Will McGugan http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

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
s, i have to plot > point, lines, sphere, surfaces and their intersections... OpenGL works rather well with wxPython. If it hangs your entire machine it can only be driver issues. Try downloading the latest video drivers and I suspect this problem will magically disapear! Will McGugan -- http://www.

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
would have to be running it on an ancient PC if that is an issue. If you really want to avoid OpenGL, then writing a custom 3D engine using flat shaded polys, with painters algorithm, rendered with your favourite gui toolkit isn't a great deal of work. Will McGugan -- http://www.willmcg

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

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

__init__ style questions

2006-10-02 Thread Will McGugan
mply wouldnt do them! But I dont want to teach beginner programmers bad habbits! Any comments appreciated... Will McGugan -- http://www.willmcgugan.com -- http://mail.python.org/mailman/listinfo/python-list

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 "texst"; followed by

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 "texst"; followed by

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

  1   2   >