conditional running of code portion

2012-08-04 Thread JW Huang
Hi, How can I implement something like C++'s conditional compile. if VERBOSE_MODE: print debug information else: do nothing But I don't want this condition to be checked during runtime as it will slow down the code. Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list

Re: building extensions for Windows Python

2006-10-17 Thread JW
Thanks to Michael and Nick, I can now cross-compile my Pyrex extensions for bog-standard Python 2.5. As I stumbled around in the dark trying to bump into a solution, I was bolstered by the belief that at least two other people had found the light at the end of the tunnel. I had been using a cruft

building extensions for Windows Python

2006-10-13 Thread JW
I have a lousy little Python extension, generated with the generous help of Pyrex. In Linux, things are simple. I compile the extension, link it against some C stuff, and *poof*! everything works. My employer wants me to create a Windows version of my extension that works with the vanilla Python

Re: 2Qs

2006-06-26 Thread JW
> > 2nd question: > [snip] > > if x>10 and y>10 and z>10 and summ(tritup(x,y,z)): print "OK" > > Others have already suggested you use the built-in sum() function. > > I'll suggest you don't need it at all, because it is redundant. > > If the sum is zero, either all three values are zero or at leas

Re: MS VC++ Toolkit 2003, where?

2006-04-24 Thread JW
On Sun, 23 Apr 2006 21:15:23 -0700, Alex Martelli wrote: > As suggested to me by David Rushby 10 hours ago, > > ... < huge URL snipped > ... Alas, somehow this URL was split in two, and all the kings horses and all the kings men can't seem to put it back together again (at least in my browser).

Re: just one more question about the python challenge

2006-04-13 Thread JW
You said: > Sorry to post here about this again, but the hint forums are dead, and > the hints that are already there are absolutely no help (mostly it's > just people saying they are stuck, then responding to themselves saying > the figured it out! not to mention that most of the hints require > g

Re: Multiplying all the values in a dictionary

2006-03-24 Thread JW
As long as you are optimizing, addition is slightly faster than multiplication: $ python2.4 -mtimeit 'h=1;h*=2' 100 loops, best of 3: 0.286 usec per loop $ python2.4 -mtimeit 'h=1;h=h+h' 100 loops, best of 3: 0.23 usec per loop Of course, that's only a 20% decrease, so it might not be wo

Re: doctest-alike for a unix shell?

2006-03-13 Thread JW
1. Try os.popen: >>> import os >>> os.popen('echo Hello World').read() 'Hello World\n' 2. Try a test environment built for testing shell commands, such as DejaGnu: http://www.gnu.org/software/dejagnu/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Please, I Have A Question before I get started

2006-03-13 Thread JW
Skipper wrote: > I can not believe that there isn't a GUI programing tool that will > allow me to build GUI apps - just like I use Dreamweaver to build a > web page ... a WYSIWYG builder that does a few simplet things and > calls other programs ... > > Oh well no silver bullet! If you are int

Re: looking for help about python-sane

2006-03-02 Thread JW
ould be trivial modify the Python code to do the same thing. Hope this is some help, JW -- http://mail.python.org/mailman/listinfo/python-list

Re: looking for help about python-sane

2006-03-01 Thread JW
Every time, or just this run? -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 354: Enumerations in Python

2006-02-28 Thread JW
It seems the concensus is that empty enums should be allowed for consistancy, and to support the loop that doesn't. I thought I'd find some data points in other languages as a guide: * C - builtin, empty enumerations not allowed * C++ - builtin, empty enumerations allowed. C++ doesn't have itera

Re: general coding issues - coding style...

2006-02-20 Thread JW
kslash: print "\\library.zip" If you don't use the double backslash, you'll eventually have a problem, especially in Windows, which unfortunately uses the backslash as a directory seperator. You might also want to look at os.sep and the os.path.* functions, if you are interested in making your code work on different platforms. JW -- http://mail.python.org/mailman/listinfo/python-list

Re: Rethinking the Python tutorial

2006-02-14 Thread JW
Here's my two cents - I started with the official tutorial. It seemed up to date to me. Things that changed from 2.4 to 2.5 changed in the tutorial as well. I still refer to it every few days, because it had been a useful reference for the basic data types. I like that it seemlessly links into

Re: random playing soundfiles according to rating.

2006-02-09 Thread JW
I think of it this way: you randomly pick a entry out of a dictionary, then roll a 100-side die to see if the pick is "good enough". Repeat until you find one, or give up. import random def rand_weighted_pick(weighted_picks): for i in range(100): name, prob = random.choice(weighted_p

Re: New Python.org website ?

2006-01-18 Thread JW
On Wed, 18 Jan 2006 20:51:03 +, Roel Schroeven wrote: > I, Jim Wilson, schreef: >> >> I'm assured that in print ads the only "content" anyone reads is in >> picture captions, and you damn well better make sure your message is >> conveyed there. Any other "content" only wastes space. I see no

Re: New Python.org website ?

2006-01-18 Thread JW
On Wed, 18 Jan 2006 00:33:06 -0800, Tim N. van der Leeuw wrote: > What I especially dislike about the new website are the flashy pictures > on the front-page with no content and no purpose -- purely boasting but > nothing to back up your claims. > > (I wouldn't mind some sleek pictures there if t

Re: New Python.org website ?

2006-01-15 Thread JW
On Sun, 15 Jan 2006 22:19:37 +, Tim Parkin wrote: > http://pyyaml.org/downloads/masterhtml/ > > Feedback appreciated ... Many thanks Again, with FF 1.0.7 (on FC4 Linux BTW), the left column no longer violates the right. However, "View>Page Style>large text" makes the button annotation small

Re: New Python.org website ?

2006-01-13 Thread JW
On Fri, 13 Jan 2006 11:00:05 -0600, Tim Chase wrote: > http://tim.thechases.com/pythonbeta/pythonbeta.html > Very strange. With FF 1.0.7, I can just get the buttons to violate the next column if I "View>Page Style>Large Text", but I wouldn't have noticed it unless Tim had pointed it out. Tim's