Re: How to handle two-level option processing with optparse

2006-01-25 Thread Giovanni Bajo
R. Bernstein wrote: > It seems that with all of the flexibility of optparse it should handle > this. I'm not sure right now what the best way to do so would be > though. Suggestions? If you call OptionParser.disable_interspersed_args() on your parser, it will stop parsing at the first positional

Re: Codec Search Function

2006-01-25 Thread Giovanni Bajo
James Stroud wrote: > I'm using pyinstaller 1.0 (stable) on win32xp and it is not able to > find the codec for several encodings (hex, base64, etc.). I resorted > to writing my own for hex, just to see if I could get my program > deployed. But I think a more permanent solution would be to get > py

Re: Mining strings from a HTML document.

2006-01-25 Thread Derick van Niekerk
Thanks, Jay! I'll try this out today. Trying to write my own parser is such a pain. This BeatifullSoup script is very nice! I'll give it a try. If you can help me out with an example of how to do what I explained, I would appreciate it. I actually finished doing an import last night, but there is

Re: regular expressions, unicode and XML

2006-01-25 Thread Justin Ezequiel
import codecs f = codecs.open(pth, 'r', 'utf-8') data = f.read() f.close() ## data = re.sub ... f = codecs.open(pth, 'w', 'utf-8') f.write(data) f.close() -- http://mail.python.org/mailman/listinfo/python-list

Re: Executing script with embedded python

2006-01-25 Thread Farshid Lashkari
> The problem is that PyObject_CallObject always returns NULL. Is this the > correct return value for simply executing a script, as there is no function > return value involved? The documentation for PyObject_CallObject states the following: "Returns the result of the call on success, or NULL on

Re: Using non-ascii symbols

2006-01-25 Thread Runsun Pan
I am not Chinese but I can read and write han characters (in Traditional Chinese format (Big5 encoding) that is basically popular in Taiwan ).   For the tests that I tried earlier, using han characters as the variable names doesn't seem to be possible (Syntax Error) in python. I'd love to see if

How to handle two-level option processing with optparse

2006-01-25 Thread R. Bernstein
optparse is way cool, far superior and cleaner than other options processing libraries I've used. In the next release of the Python debugger revision, I'd like to add debugger options: --help and POSIX-shell style line trace (similar to "set -x") being two of the obvious ones. So I'm wondering ho

regular expressions, unicode and XML

2006-01-25 Thread ProvoWallis
Hi, I'm hoping someone can help me. I'm hopelessly lost. I'm trying to make a change in some XML files using a regular expression (re.sub). I can capture the text I want to replace OK but when I replace it end up with nothing: i.e., just a "" character in my file. data = re.sub(r'(?i)(?u)Sample

Re: Best way to extract an item from a set of len 1

2006-01-25 Thread Alex Martelli
Rene Pijlman <[EMAIL PROTECTED]> wrote: > Peter Otten: > s = set(["one-and-only"]) > item, = s ... > >The comma may easily be missed, though. > > You could write: > > (item,) = s > > But I'm not sure if this introduces additional overhead. Naah...: helen:~ alex$ python -mtimei

Re: Help with fast tree-like structure

2006-01-25 Thread Lonnie Princehouse
> A = [, B, C] >B = [, D] >C = [] Why store node data in the same list that contains the children? It seems like the OO approach would be more extensible, e.g. class Node: def __init__(self): self.children = [] # list of nodes # store node data as attributes... # If you wa

Re: Using non-ascii symbols

2006-01-25 Thread Christoph Zwerschke
These were some interesting remarks, Terry. I just asked myself how Chinese programmers feel about this. I don't know Chinese, but probably they could write a whole program using only one-character names for variables, and it would be still readable (at least for Chinese)... Would this be used

Re: Possible memory leak?

2006-01-25 Thread Steven D'Aprano
On Wed, 25 Jan 2006 20:08:56 +0100, Giovanni Bajo wrote: > Steven D'Aprano wrote: > >> No, that's not correct. You are making a false >> assumption. > > Did you ever try to measure the code yourself? I'm still running Python 2.3, it would give misleading results. >> This is from the "What's N

Problem compiling Tkinter program with bmp images using py2

2006-01-25 Thread [EMAIL PROTECTED]
Problem compiling Tkinter program with bmp images (using py2exe) I have a Tkinter gui program that uses bmp as backgrounds. The program itself works when I run from the source. I placed the .bmp files in the same folder as the script. I run my .py script (from IDLE) and all the backgrounds are lo

Re: Possible memory leak?

2006-01-25 Thread Steven D'Aprano
On Wed, 25 Jan 2006 23:20:08 +, Giovanni Bajo wrote: > Of course. I was just trying to make a point about string accumulation being > O(n) and not O(n^2). But according to Fredrik, string accumulation is still quadratic, even with the optimizations added to Python 2.4. Quoting: "it only mea

ImportError: No module name MySQLdb

2006-01-25 Thread Fred
I hope someone can help me with the below problem... Thanks, Fred My enviroment: -- Slackware Linux 10.2 Python 2.4.2 MySql version 4.1.14 MySql-Python 1.2.0 What I am trying to do: --- Using MySQL, Python, My-Sql-Python module and CGI create a sim

Re: Possible memory leak?

2006-01-25 Thread Tim Peters
[Fredrik Lundh] >> ... >> for the OP's problem, a PIL-based solution would probably be ~100 >> times faster than the array solution, but that's another story. [Tuvas] > What do you mean by a PIL based solution? The reason I need to get the > data into the string list is so I can pump it into PIL t

Re: Pulling numbers from ASCII filename not working

2006-01-25 Thread Steven D'Aprano
On Wed, 25 Jan 2006 16:57:47 -0800, IamIan wrote: >>Dude. You're trying to add a string to an int. What did you think would >>happen? > > Dude. I thought it would concatenate the value for LatInt with the rest > of the sentence; I wasn't literally trying to add them. Apparently you > can only con

Re: Pulling numbers from ASCII filename not working

2006-01-25 Thread IamIan
>Dude. You're trying to add a string to an int. What did you think would >happen? Dude. I thought it would concatenate the value for LatInt with the rest of the sentence; I wasn't literally trying to add them. Apparently you can only concatenate strings like this in Python. -- http://mail.python

Re: List of files to be opened

2006-01-25 Thread James Stroud
yawgmoth7 wrote: > Hello, I am currently writing a script that requires a few different > files to be opened, and examined. What I need to be able to do is use > something like: > > filelist = os.system("ls") > > > I cannot think of a way to do this, I could put them in a list of > something of

Sample code to handle cookie based login/password forms automatically?

2006-01-25 Thread [EMAIL PROTECTED]
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/391929 has a mechanize based script to handle login/password forms but I can't get it to work. Anyone else got sample code that does this? Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: List of files to be opened

2006-01-25 Thread Carl J. Van Arsdall
yawgmoth7 wrote: > Hello, I am currently writing a script that requires a few different > files to be opened, and examined. What I need to be able to do is use > something like: > > filelist = os.system("ls") > There are a number of ways you can do this, one method would be to do a loop for f

Re: Possible memory leak?

2006-01-25 Thread Steven D'Aprano
On Wed, 25 Jan 2006 13:17:25 -0800, Tuvas wrote: > Very interesting results with the last test. I guess I go back to my > other code then, even if it is only a hair faster, it's still faster... Can you say "premature optimization"? Have you timed your code with realistic data? Not somebody else'

List of files to be opened

2006-01-25 Thread yawgmoth7
Hello, I am currently writing a script that requires a few different files to be opened, and examined. What I need to be able to do is use something like: filelist = os.system("ls") I cannot think of a way to do this, I could put them in a list of something of the sort. But that still does not s

Re: ZODB and Zope on one Linux machine, how?

2006-01-25 Thread Terry Hancock
On Tue, 24 Jan 2006 15:24:47 +0100 Rene Pijlman <[EMAIL PROTECTED]> wrote: > Option 1: > Install ZODB in the Python installation in the usual way. > Should I expect problems when I install and run zope with > that Python installation? I think this should work, actually. ZODB is just like other d

Re: Using non-ascii symbols

2006-01-25 Thread Terry Hancock
On Tue, 24 Jan 2006 04:09:00 +0100 Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > On the page > http://wiki.python.org/moin/Python3%2e0Suggestions > I noticed an interesting suggestion: > > "These operators ≤ ≥ ≠ should be added to the > language having the following meaning: > >

Re: Pulling numbers from ASCII filename not working

2006-01-25 Thread Steven D'Aprano
On Wed, 25 Jan 2006 12:42:20 -0800, IamIan wrote: > Thank you for the replies, I'm new to Python and appreciate your > patience. I'm using Python 2.1. > > To reiterate, the ASCII files in the workspace are being read correctly > and their latitude values (coming from the filenames) are successful

Re: Apache with Python 2.4 Need Help !!!

2006-01-25 Thread Sybren Stuvel
rbt enlightened us with: > This was my first real go at using mod_python. It was a bit > different, but once I got the hang of it, I like it very much. > Existing py scripts need little modification to work, and if you've > done any PHP or Perl web projects in the past, you'll understand 50% > of i

Re: Using non-ascii symbols

2006-01-25 Thread Steven D'Aprano
On Wed, 25 Jan 2006 11:14:06 -0500, Peter Hansen wrote: > I think "not equal", at least the way our brains handle it in general, > is not equivalent to "less than or greater than". > > That is, I think the concept "not equal" is less than or greater than > the concept "less than or greater than

Re: Possible memory leak?

2006-01-25 Thread Giovanni Bajo
Fredrik Lundh wrote: > since you know the length, you can preallocate the list > > def iters3(n): > L = [None]*n > for i in xrange(n): > L[i] = chr(i%64) > return "".join(L) > > or use a preallocated array > > def iters4(n): > L = array.array("B"

Re: win32com early binding problem

2006-01-25 Thread Roger Upole
"Roland" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, > > I'm trying to use Sparx Systems Enterprise Architect OLE automation > interface. There is no problem to get early binding interface using > Microsoft Visual Basic. But using win32com makepy utility there problem > is.

Executing script with embedded python

2006-01-25 Thread Andrew Ayre
Hi, I have a script that I want to execute from C. I don't want to call any functions, just execute the script. Below is a code snippet. The problem is that PyObject_CallObject always returns NULL. Is this the correct return value for simply executing a script, as there is no function return value

Re: float formatting

2006-01-25 Thread Peter Hansen
Brian wrote: > Thanks guys, that really helped. Am I to assume that the * references > the args in the parens? Better than assuming, you can read all about it: http://docs.python.org/lib/typesseq-strings.html -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: while/break - The pure-python FSM implementation to Rule Them All.

2006-01-25 Thread Carl Cerecke
Paul Rubin wrote: > Carl Cerecke <[EMAIL PROTECTED]> writes: > >>3. Not as fast as byte code hacks, or using pyrex/psyco. Peter Hansen >>is right. One of those is likely a better solution if you don't need >>pure python. > > > If you don't need pure python than your approach still beats > everyt

Re: while/break - The pure-python FSM implementation to Rule Them All.

2006-01-25 Thread Paul Rubin
Carl Cerecke <[EMAIL PROTECTED]> writes: > 3. Not as fast as byte code hacks, or using pyrex/psyco. Peter Hansen > is right. One of those is likely a better solution if you don't need > pure python. If you don't need pure python than your approach still beats everything else. Just generate C code

while/break - The pure-python FSM implementation to Rule Them All.

2006-01-25 Thread Carl Cerecke
Well, it doesn't quite rule them all, but it is fast: About three times faster than using one function per state. Faster than using generators. Faster than using code objects. Some, possibly minor, problems: 1. The generated code is ugly. 2. The generated code can be quite large, depending on th

Re: Python code written in 1998, how to improve/change it?

2006-01-25 Thread skip
>> If they need to resume their calculations from where they left off >> after the last yield. Wolfgang> Well, no, independently from that. Wolfgang> Just to avoid to inital overhead of the function call. How do you pass in parameters? Consider: def square(x): ret

Re: Possible memory leak?

2006-01-25 Thread Tuvas
Fredrik Lundh wrote: > Giovanni Bajo wrote: > > > --- foo.py - > > def iters(n): > > s = '' > > for i in xrange(n): > > s += chr(i%64) > > return s > > > > def iters2(n): > > L = [] > > for i in xrange(n): > > L.append(chr(i%64)) > > return "".join(L

Re: Python code written in 1998, how to improve/change it?

2006-01-25 Thread skip
Wolfgang> So basically if I want to write a long-running program in Wolfgang> Python, it would make sense to code all functions that are Wolfgang> likely to be called more than once as generators... Skip> If they need to resume their calculations from where they left off Skip>

Re: Possible memory leak?

2006-01-25 Thread Fredrik Lundh
Giovanni Bajo wrote: > --- foo.py - > def iters(n): > s = '' > for i in xrange(n): > s += chr(i%64) > return s > > def iters2(n): > L = [] > for i in xrange(n): > L.append(chr(i%64)) > return "".join(L) > --- foo.py - > > So, look, it's even

Re: Fast generation of permutations

2006-01-25 Thread Paul Rubin
Paul Rubin writes: > Well, maybe not 24x. The exact number is more complicated. I'm still > too sleepy to figure this out right now but may think about it later. Turns out to be 7x, for reasons that are a bit mysterious. Ignoring suits, think of the 5-card hand as a 5-

Re: Possible memory leak?

2006-01-25 Thread Tuvas
Very interesting results with the last test. I guess I go back to my other code then, even if it is only a hair faster, it's still faster... It's odd, I just ran another test. There's 2 ways I can call my load_pic function, first of all, through taking a picture, secondly by loading a picture. Fo

Re: float formatting

2006-01-25 Thread Brian
Thanks guys, that really helped. Am I to assume that the * references the args in the parens? Thanks, Brian -- http://mail.python.org/mailman/listinfo/python-list

Re: Python code written in 1998, how to improve/change it?

2006-01-25 Thread Peter Hansen
Wolfgang Keller wrote: >>what makes you think that resuming a generator won't involve function >>calls ? > > That was not what I wrote. > > I referred to what Peter Hansen <[EMAIL PROTECTED]> wrote in > [EMAIL PROTECTED]: > >>I believe the more modern approach to this is to use generators in so

Re: Convert a long XML string into indented format

2006-01-25 Thread mwilliams
I would recommend using Amara (http://uche.ogbuji.net/tech/4suite/amara/). It works wonders with XML. Regards, Michael -- Original Message -- From: [EMAIL PROTECTED] Reply-To: python-list@python.org Date: Wed, 25 Jan 2006 20:55:03 +0100 >Send Python-li

Re: Pulling numbers from ASCII filename not working

2006-01-25 Thread IamIan
Thank you for the replies, I'm new to Python and appreciate your patience. I'm using Python 2.1. To reiterate, the ASCII files in the workspace are being read correctly and their latitude values (coming from the filenames) are successfully being converted to string. Even doing LatInt = int(LatStri

Re: Loop exception catching

2006-01-25 Thread Ivan Shevanski
On 1/25/06, Ivan Shevanski <[EMAIL PROTECTED]> wrote: On 1/25/06, Fredrik Lundh < [EMAIL PROTECTED]> wrote: Aldo Cortesi wrote:> > What do you mean?>> Well, the problem with "input" is that it allows the user to supply an> arbitrary Python _expression_, which will then be executed. Among other thin

Re: Is there a way to profile underlying C++ code?

2006-01-25 Thread Bo Peng
Travis E. Oliphant wrote: > On Linux you can use oprofile (which is pretty nice and easy to use --- > no recompiling. Just start the profiler, run your code, and stop the > profiler). Thank you very much for the tip. This is a great tool. The source of the problem has been found: cache misses

Re: Codec Search Function

2006-01-25 Thread James Stroud
James Stroud wrote: > Hello All, > > I'm using pyinstaller 1.0 (stable) on win32xp and it is not able to find > the codec for several encodings (hex, base64, etc.). I resorted to > writing my own for hex, just to see if I could get my program deployed. > But I think a more permanent solution wo

Re: float formatting

2006-01-25 Thread Peter Otten
Brian wrote: > I am a bit stuck with a float formatting issue. What I want to do is > print a float to the screen with each line showing one more decimal > place. Here is a code snip that may explain it better: > > #!/usr/bin/env python > > num1 = 32 > num2 = 42.98765 > > for i in range(2,7):

Re: float formatting

2006-01-25 Thread Tim Chase
> for i in range(2,7): > print "|" + "%10.if" % num2 + "|" #where i would be the iteration > and the num of decimal places >>> for places in range(2,7): ... print "|%10.*f|" % (places, num2) ... | 42.99| |42.988| | 42.9877|

Re: Convert a long XML string into indented format

2006-01-25 Thread Laguna
Excellent! This is exactly what I was looking for. Thank you Jim! My example code: import xml.dom.ext import xml.dom.minidom doc = xml.dom.minidom.parse('myfile.xml') xml.dom.ext.PrettyPrint(doc) -- http://mail.python.org/mailman/listinfo/python-list

Re: float formatting

2006-01-25 Thread Dave Hansen
On 25 Jan 2006 11:32:27 -0800 in comp.lang.python, "Brian" <[EMAIL PROTECTED]> wrote: >Hello all, > >I am a bit stuck with a float formatting issue. What I want to do is >print a float to the screen with each line showing one more decimal >place. Here is a code snip that may explain it better: >

Re: float formatting

2006-01-25 Thread Diez B. Roggisch
> However, if I do that I get errors saying that all args were not > converted during string formatting. An escaped 'i' does not work > either. You need to format the string twice - first, to generate the float formatting string, and then to format the string. Like this: num = 7.1234567890123

[ANN] pycdio 0.10 - Python to CD reading and control (via libcdio)

2006-01-25 Thread R. Bernstein
pycdio is a Python interface to the CD Input and Control library (libcdio). You can get the source at the same place as libcdio: ftp://ftp.gnu.org:/pub/gnu/libcdio/pycdio-0.10.tar.gz The pycdio and libcdio libraries encapsulate CD-ROM reading and control. Python programs wishing to be oblivious

Re: Convert a long XML string into indented format

2006-01-25 Thread Jim
Laguna wrote: > Hi, > > I have an XML file in a single long string. How can I convert it into > the nicely indented format as displayed by Internet Explorer using > Python? You want to pretty print. Have a look at http://www.boddie.org.uk/python/XML_intro.html for example. Thank you to Paul,

Re: Creating a more random int?

2006-01-25 Thread Grant Edwards
On 2006-01-25, Fredrik Lundh <[EMAIL PROTECTED]> wrote: >> FWIW, "nominal brith dates" is a phrase with exactly one hit in >> google. :) > > try "nominal birth date", and you'll find lots of references to Saddam, > Jesus, and fish, and a few pages that actually explain the concept... I know. I w

float formatting

2006-01-25 Thread Brian
Hello all, I am a bit stuck with a float formatting issue. What I want to do is print a float to the screen with each line showing one more decimal place. Here is a code snip that may explain it better: #!/usr/bin/env python num1 = 32 num2 = 42.98765 for i in range(2,7): print "|" + "

Help with fast tree-like structure

2006-01-25 Thread David Hirschfield
I've written a tree-like data structure that stores arbitrary python objects. The objective was for the tree structure to allow any number of children per node, and any number of root nodes...and for it to be speedy for trees with thousands of nodes. At its core, the structure is just a list of

Re: Python and XML Schema

2006-01-25 Thread Dennis Benzinger
Trond wrote: > I have a need to, given a XML document with XML Schema defined, to get the > type of each element in the XML file based on the XML Schema URI given. IE, > the element is of simple datatype string. Is there any existing > Python libraries were I can parse the XML file, and for a g

"pre-"*10 + "PEP": extension to the list comprehensions & genexps syntax

2006-01-25 Thread Gregory Petrosyan
This is revised version of "Arithmetic sequences in Python" proposal. I don't want this topic to become as bloated with offtopic as "ASiP". Please post here corresponding info only. Your (revised) comments (possibly already posted to "ASiP") are welcome. The first thing I want to mention is that,

Re: Possible memory leak?

2006-01-25 Thread Giovanni Bajo
Steven D'Aprano wrote: > No, that's not correct. You are making a false > assumption. Did you ever try to measure the code yourself? > This is from the "What's New" for Python 2.4: > > [quote] > String concatenations in statements of the form s = s + > "abc" and s += "abc" are now performed more

Convert a long XML string into indented format

2006-01-25 Thread Laguna
Hi, I have an XML file in a single long string. How can I convert it into the nicely indented format as displayed by Internet Explorer using Python? Thanks, Laguna Input XML file (one continuous string without newline): */2 * * * * Output XML file: */2

Re: Some thougts on cartesian products

2006-01-25 Thread Fredrik Lundh
Terry Reedy wrote: > You might so define, but Bryan and others might not. The > philosophical/methodological idea that 'everything is a set' has been very > fruitful but it is not a fact. Alternative ideas are 'everything is a > function' and 'everything is defined by axioms'. according to goog

Re: remote file

2006-01-25 Thread Fredrik Lundh
"yqyq22" wrote: > How to open remote file ? example: \\server\share\file.txt like you'd open any other file: f = open(filename) e.g. f = open(r"\\server\share\file.txt") -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating a more random int?

2006-01-25 Thread Fredrik Lundh
Grant Edwards wrote: > > Grant Edwards wrote: > > > >> [1] Assuming birth dates are uniformly distributed. Which the > >> probably aren't in countries where a significant portion of > >> the population schedules births to fit the hospital/doctors > >> schedule. > > > > or in countries

Re: Some thougts on cartesian products

2006-01-25 Thread Terry Reedy
"Christoph Zwerschke" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Bryan Olson wrote: >> The claim "everything is a set" falls into the category of >> 'not even wrong'. > > No, it falls into the category of the most fundamental Mathematical > concepts. You actually *define* tuple

remote file

2006-01-25 Thread yqyq22
How to open remote file ? example: \\server\share\file.txt thanks a lot -- http://mail.python.org/mailman/listinfo/python-list

Re: Fast generation of permutations

2006-01-25 Thread Paul Rubin
Paul Rubin writes: > Note that you're looking at 24x more hands than you really need to, Well, maybe not 24x. The exact number is more complicated. I'm still too sleepy to figure this out right now but may think about it later. -- http://mail.python.org/mailman/listin

Re: Creating a more random int?

2006-01-25 Thread Grant Edwards
On 2006-01-25, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Grant Edwards wrote: > >> [1] Assuming birth dates are uniformly distributed. Which the >> probably aren't in countries where a significant portion of >> the population schedules births to fit the hospital/doctors >> schedule. >

Re: Fast generation of permutations

2006-01-25 Thread Paul Rubin
Frode Øijord <[EMAIL PROTECTED]> writes: > > cards = range(52) > > for (hand) in probstat.Combination(card, 5): > > pass > > Takes 1.3 seconds on my laptop instead of 17 seconds for the pure > > python version which is only one order of magnitude faster. > > This is *exactly* what i wanted! I ju

Re: Creating a more random int?

2006-01-25 Thread davbrow
Steven, Have you considered you might want a less random distribution? If you just want to remove repeats so it 'seems' more random you could do that (replace any repeat with another random value not equal to the last value). It likely will not be as uniformly random as the original sequence but

Re: customized instance dictionaries, anyone?

2006-01-25 Thread [EMAIL PROTECTED]
thx! indeed, it worked -- took me some time to figure out how to implement the setting of attributes, too. i finally managed to get that done using super: custom dictionary, unchanged:: class CustomDict( dict ): defaultValue = 'THIS ITEM NOT AVAILABLE' def __getitem__( self,

Re: Possible memory leak?

2006-01-25 Thread Tuvas
FYI, to all who asked, I was indeed just simply monitering the system memory. I changed my approach to one that uses arrays and simply joins the statements together at the end, it seems to have improved the speed. However, for some reason it still takes a small eternity to process on one computer,

Re: Fast generation of permutations

2006-01-25 Thread Terry Reedy
"Frode Øijord" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > However, this is way too slow for my needs. I try to use this to > generate all possible 5 card poker hands, but this takes around 17 > seconds on an Athlon 2200. That's a 2 orders of magnitude too slow for > my needs.

Re: Fast generation of permutations

2006-01-25 Thread Frode Øijord
Jack Diederich wrote: > You might want to look at a specific purpose library for poker hands: > http://pokersource.sourceforge.net/ Nah, evaluating the poker hands is the FUN part! I want to do that myself :) > If you really want to do combinations a C extension has already > been written (by m

Python and XML Schema

2006-01-25 Thread Trond
I have a need to, given a XML document with XML Schema defined, to get the type of each element in the XML file based on the XML Schema URI given. IE, the element is of simple datatype string. Is there any existing Python libraries were I can parse the XML file, and for a given node ask for th

Re: Creating a more random int?

2006-01-25 Thread davbrow
Well it IS unusual actually (~1/365.25). Please tell them for me. -- Dave -- http://mail.python.org/mailman/listinfo/python-list

Re: ActivePython & SSL

2006-01-25 Thread Trent Mick
[Fuzzyman wrote] > Hello all, > > In the past I've used the ActivePython distribution for windows. > Particularly their chm help manual is excellent. > > I have heard that the ActivePython distribution *doesn't* include SSL > support compiled in for windows. > > Can anyone confirm or deny this r

Re: Fast generation of permutations

2006-01-25 Thread Michael Amrhein
Michael Amrhein schrieb: > Frode Øijord schrieb: >> Hi all, >> given a sequence of n elements i need to generate all possible >> permutations of length k <= n. >> >> I found an elegant way to do this recursively: >> >> def comb(items, n): >> if n==0: yield [] >> else: >> for i in x

Re: Creating a more random int?

2006-01-25 Thread Tim Chase
> Exactly. And I've never heard anyone say to my sons that it's > so unusual that they are born on Jan 30th or June 27th! Now those born on Feb 29th...they're about a quarter as frequent :) -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating a more random int?

2006-01-25 Thread Magnus Lycka
Grant Edwards wrote: > Well, it happens to slightly less than 1/365th of the > population[1], so it is rather unusual. Of course it's no more > unusal that being born on June 19th or November 3rd or any > other date you choose... Exactly. And I've never heard anyone say to my sons that it's so un

Re: Fast generation of permutations

2006-01-25 Thread Michael Amrhein
Frode Øijord schrieb: > Hi all, > given a sequence of n elements i need to generate all possible > permutations of length k <= n. > > I found an elegant way to do this recursively: > > def comb(items, n): > if n==0: yield [] > else: > for i in xrange(len(items)): > fo

Re: Using non-ascii symbols

2006-01-25 Thread Peter Hansen
Dave Hansen wrote: > C uses ! as a unary logical "not" operator, so != for "not equal" just > seems to follow, um, logically. > > Pascal used <>, which intuitively (to me, anyway ;-) read "less than > or greater than," i.e., "not equal." For quantitative data, anyway, or things which can be ord

Re: Fast generation of permutations

2006-01-25 Thread Jack Diederich
On Wed, Jan 25, 2006 at 03:33:48PM +0100, Frode ?ijord wrote: > Hi all, > given a sequence of n elements i need to generate all possible > permutations of length k <= n. > > I found an elegant way to do this recursively: > > def comb(items, n): > if n==0: yield [] > else: > for i

RE: win32com early binding problem

2006-01-25 Thread Stefan Schukat
win32com does only support late bound interfaces in python scripts. To support early bound interfaces a pyd has to be created. If you want to script early bound interfaces try ctypes.com aka. comtypes from Thomas Heller. Stefan > -Original Message- > From: [EMAIL PROTECTED] > [

Re: Python code written in 1998, how to improve/change it?

2006-01-25 Thread Magnus Lycka
Wolfgang Keller wrote: > The way I understand this, resuming a generator causes less overhead than the > inital overhead of a function call. I don't have Python 2.4 handy, but it doesn't seem to be true in 2.3. I'm not very proficient with generators though, so maybe I'm doing something stupid he

Re: Creating a more random int?

2006-01-25 Thread Fredrik Lundh
Grant Edwards wrote: > [1] Assuming birth dates are uniformly distributed. Which the > probably aren't in countries where a significant portion of > the population schedules births to fit the hospital/doctors > schedule. or in countries that use "nominal birth dates" for people born

Re: Creating a more random int?

2006-01-25 Thread Dave Hansen
On Wed, 25 Jan 2006 15:21:43 - in comp.lang.python, Grant Edwards <[EMAIL PROTECTED]> wrote: >On 2006-01-25, Magnus Lycka <[EMAIL PROTECTED]> wrote: > >> P.S. Since I was a kid, I've heard people say: So you're born >> on new years day--how unusual. > >Well, it happens to slightly less than 1/

exception given by minidom.parse

2006-01-25 Thread ankit
I want to catch the exception given by minidom.parse. Please let me know what are the exceptions raised by minidom.parse() esp if some given file is not xml -- http://mail.python.org/mailman/listinfo/python-list

win32com early binding problem

2006-01-25 Thread Roland
Hello, I'm trying to use Sparx Systems Enterprise Architect OLE automation interface. There is no problem to get early binding interface using Microsoft Visual Basic. But using win32com makepy utility there problem is. Does anybody have an idea, what may disqualify python win32com from creating e

Re: Best way to extract an item from a set of len 1

2006-01-25 Thread Alex Martelli
Fredrik Lundh <[EMAIL PROTECTED]> wrote: ... > the obvious solution is > > item = list(s)[0] > > but that seems to be nearly twice as slow as [x for x in s][0] > under 2.4. hmm. Funny, and true on my laptop too: helen:~ alex$ python -mtimeit -s's=set([23])' 'x=list(s)[0]' 10 loops,

Re: Best way to extract an item from a set of len 1

2006-01-25 Thread Fredrik Lundh
Peter Otten wrote: > > When you have a set, known to be of length one, is there a "best" > > ("most pythonic") way to retrieve that one item? > > >>> s = set(["one-and-only"]) > >>> item, = s > >>> item > 'one-and-only' > > This works for any iterable and guarantees that it contains exactly one >

Re: Mining strings from a HTML document.

2006-01-25 Thread Chris Lasher
I think Jay's advice is solid: you shouldn't rule out HTML parsing. It's not too scary and it's probably not overboard. Using a common HTML parsing library saves you from having to write and debug your own parser. Try looking at Dive Into Python's chapter on it, first. http://www.diveintopython.org

Re: Best way to extract an item from a set of len 1

2006-01-25 Thread Rene Pijlman
Peter Otten: s = set(["one-and-only"]) item, = s item >'one-and-only' > >This works for any iterable and guarantees that it contains exactly one >item. Nice! >The comma may easily be missed, though. You could write: (item,) = s But I'm not sure if this introduces additional

Re: Apache with Python 2.4 Need Help !!!

2006-01-25 Thread rbt
Sybren Stuvel wrote: > pycraze enlightened us with: > >>I am currently using Fedora Core - 3 with apache 2.0 Web Server and >>Python 2.4 . >> >>[...] i would like to know have apache released any version that can >>be successfully use Python 2.4 ( with mod-python module ) using >>Fedora Core -3 .

Re: Creating a more random int?

2006-01-25 Thread Grant Edwards
On 2006-01-25, Magnus Lycka <[EMAIL PROTECTED]> wrote: > P.S. Since I was a kid, I've heard people say: So you're born > on new years day--how unusual. Well, it happens to slightly less than 1/365th of the population[1], so it is rather unusual. Of course it's no more unusal that being born on J

Re: Best way to extract an item from a set of len 1

2006-01-25 Thread Alex Martelli
Tim Chase <[EMAIL PROTECTED]> wrote: ... > To get the item, i had to resort to methods that feel less than > the elegance I've come to expect from python: > > >>> item = [x for x in s][0] A shorter, clearer expression of the same idea: item = list(s)[0] or item = list(s).pop() > or

Re: logging module question

2006-01-25 Thread Vinay Sajip
> but now I'd like to understand the design rational behind having each > logger in the object hierarchy log the same output by default. Anyone? Loggers are different to handlers. Loggers map to areas of the application, handlers map to output destinations. Loggers form a hierarchy based on names

Re: Best way to extract an item from a set of len 1

2006-01-25 Thread Rene Pijlman
Tim Chase: >When you have a set, known to be of length one, is there a "best" >("most pythonic") way to retrieve that one item? e = s.copy().pop() #:-) -- René Pijlman Wat wil jij worden? http://www.carrieretijger.nl -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to extract an item from a set of len 1

2006-01-25 Thread Fuzzyman
That's cute. :-) Fuzzyman -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >