creat a DOM from an html document

2006-02-07 Thread Mark Harrison
I thought I saw a package that would create a DOM from html, with allowances that it would do a "best effort" job to parse non-perfectly formed html. Now I can't seem to find this... does anybody have a recommendation as to a good package to look at? Many TIA! Mark -- http://

Re: creat a DOM from an html document

2006-02-07 Thread Mark Harrison
Mark Harrison <[EMAIL PROTECTED]> wrote: > Now I can't seem to find this... does anybody have a recommendation > as to a good package to look at? Ahh, it's BeautifulSoup... Thanks All!! -- http://mail.python.org/mailman/listinfo/python-list

Jython inherit from Java class

2006-02-07 Thread Mark Fink
Exception, e: self.exception(e) Please help, Mark Fink -- http://mail.python.org/mailman/listinfo/python-list

Re: Jython inherit from Java class

2006-02-10 Thread Mark Fink
Alan, Kent, many thanks this really helped! But there is still a problem I guess with inheritance. I use the java testsuit supplied with the original to test the server. If I use the Java FitServer the testsuite can be completed. I commented everything out from my class and it does not work?? Thats

Re: Jython inherit from Java class

2006-02-10 Thread Mark Fink
I observed something strange when I tried to compile the jython class: D:\AUT_TEST\workspace\JyFIT\fit>jythonc JyFitServer.py processing JyFitServer Required packages: fitnesse.util java.io java.net fitnesse.components* Creating adapters: Creating .java files: JyFitServer module Jy

Re: Jython inherit from Java class

2006-02-11 Thread Mark Fink
with the inheritanc construct and that this implementation path would always be so slow. On the other hand would a 100% Jython solution be faster? Mark -- http://mail.python.org/mailman/listinfo/python-list

Jython socket typecasting problems

2006-02-11 Thread Mark Fink
I try to port a server application to Jython. At the moment I use Jython21\Lib\socket.py Currently I do face problems with casting the string "localhost" to the desired value: D:\AUT_TEST\workspace\JyFIT>jython fit/JyFitServer2.py localhost 1234 23 ['fit/JyFitServer2.py', 'localhost', '1234', '23']

Re: Jython socket typecasting problems

2006-02-13 Thread Mark Fink
thanks to the help of this group I moved a tiny step forward. Obviously it is not possible to resolve name localhost: Type "copyright", "credits" or "license" for more information. >>> import socket >>> s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>> s.connect(localhost, 8080) Traceback (in

Re: Jython inherit from Java class

2006-02-13 Thread Mark Fink
the method besides rewriting the Java class or is this approach really doomed? Cheers, Mark -- http://mail.python.org/mailman/listinfo/python-list

jython socket sendall

2006-02-18 Thread Mark Fink
tput.flush() sys.stdout.write("http request sent\n") -Mark -- http://mail.python.org/mailman/listinfo/python-list

Jython Pythonpath question

2006-02-21 Thread Mark Fink
Hi there, I have a source file FailFixture.py in the folder D:\AUT_TEST\workspace\JyFIT\testutil. Now I want to import the file with "import testutil.FailFixture". Unfortunately I could not figure out how to set this up. I am convinced that "D:\AUT_TEST\workspace\JyFIT" should be included in the p

Re: jython socket sendall

2006-02-21 Thread Mark Fink
I used send instead. This should work. -Mark -- http://mail.python.org/mailman/listinfo/python-list

mimicing pg 398 of practical python

2006-02-24 Thread MARK LEEDS
  or maybe thre is an easier graphics package to use that is already inside python. i'm a beginner. thanks.                                                                 mark -- http://mail.python.org/mailman/listinfo/python-list

Re: mimicing pg 398 of practical python

2006-02-24 Thread MARK LEEDS
i should have mentioned that i am on linux and using python 2.4. my apologies.   - Original Message - From: MARK LEEDS To: [email protected] Sent: Friday, February 24, 2006 10:00 PM Subject: mimicing pg 398 of practical python I am trying to

looking for a simpe plotting module

2006-02-25 Thread MARK LEEDS
i'm pretty much a python beginner so can anyone recommend a plooting package in python ( simple foating  numbers that makes lines or dots with a yaxis and an an xaxis. i don't need fancy drawings ) that is a built in module in python ?  i am using python 2.4 in linux if that matters. thanks

newbie trying understand sys.path

2006-02-26 Thread MARK LEEDS
I  was trying to understand the concept of python looking for modules in sys.path.   So, as it said in "Beginning Python", I went into my .bashrc file and did   export PYTHONPATH=$PYTHONPATH:~/mytemp   then, i typed pprint.pprint(sys.path) and it worked. it was in there !

newbie : econometrics in python

2006-02-27 Thread MARK LEEDS
ample code that i could use as a template.   i've spent 2 days, going through numpy, scipy, pytrix etc and i still can't figure it out. thanks.                                                           mark -- http://mail.python.org/mailman/listinfo/python-list

Re: I want to ask you the most important question of your life. The question is: Are you saved? It is not a question of how good you are, nor if you are a church member, but are you saved? Are you sure you will go to Heaven when you die? The reason some people don't know for sure if they are going to Heaven when they die is because they just don't know. The good news is that you can know for sure you are going to Heaven. May 22, 2005 12:10:55 pm

2005-05-22 Thread Mark McIntyre
be somewhat religiously inclined. BTW, abuse reports filed with [EMAIL PROTECTED] amongst other places. -- Mark McIntyre CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html> CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt> == Posted via Newsfeeds.Com - Unlimited-Uncen

4466806 CD-R, DVD R, DVD CASES LOWEST PRICE! 44

2005-05-23 Thread mark deguire
media4sale.com offers innovative and quality media, CD/DVD packaging and other computer accessories at the best prices. We pride ourselves in service, quality and commitment and are certain that our standards will exceed expectations. http://www.media4sale.com http://w

Newbie Here

2005-05-30 Thread Mark Sargent
some basic examples out there. Cheers. Mark Sargent. -- http://mail.python.org/mailman/listinfo/python-list

Re: [ANN] IPython 0.6.14.

2005-05-31 Thread Mark Sargent
>for more details. > >* Various other fixes for obscure bugs, but all of which caused reported >IPython crashes. Details in Changelog. > > >Enjoy, and as usual please report any problems. > >Regards, > >Fernando. > > > Hi All, Fernando, if I may ask, as I'm a Fedora3 user. You mention that there are RPMs for FC3, for Python2.3, 2.4. I'm new to Python. Is IPython built into FC3s Python or is it a stand-alone program.? Sorry for troubling you with this. Cheers. Mark Sargent. -- http://mail.python.org/mailman/listinfo/python-list

Re: [ANN] IPython 0.6.14.

2005-05-31 Thread Mark Sargent
Mark Sargent wrote: >Fernando Perez wrote: > > > >>Hi all, >> >>I've just made the 0.6.14 release of IPython, mostly to fix the >>inevitable bugs reported after the .13 one (though one big improvement >>sneaked by). >> >>IPython's

Moving Places, Subtracting from slices/lists

2005-06-01 Thread Mark Sargent
oof', 'on', 'a', 'hot', 'tin'] >>> for x in hotcat[:]: ... if x == 'roof': hotcat.insert(6,x) ... hotcat[x:len(x)] = [] ... Traceback (most recent call last): File "", line 3, in ? TypeError: slice indices must be integers I feel I'm close to it. Cheers. Mark Sargent. -- http://mail.python.org/mailman/listinfo/python-list

Re: Moving Places, Subtracting from slices/lists

2005-06-02 Thread Mark Sargent
t call last): File "", line 3, in ? TypeError: list indices must be integers How do I get that x to be an integer b4 it is entered into the indice.? Cheers. Mark Sargent. -- http://mail.python.org/mailman/listinfo/python-list

Re: Moving Places, Subtracting from slices/lists

2005-06-02 Thread Mark Sargent
Dennis Lee Bieber wrote: >On Thu, 02 Jun 2005 16:12:44 +0900, Mark Sargent ><[EMAIL PROTECTED]> declaimed the following in >comp.lang.python: > > > >>How do I get that x to be an integer b4 it is entered into the indice.? >>Cheers. >> >> >

Re: Moving Places, Subtracting from slices/lists

2005-06-02 Thread Mark Sargent
>if I understand the OP correctly, he wants to *move* the "roof" to the >end of the string. > > correct... >try: >hotcat.remove("root") >hotcat.append("root") >except ValueError: >pass > >is most likely the fastest way to do that. > > > > > will give it a blast...thanx > > > Cheers. Mark Sargent. -- http://mail.python.org/mailman/listinfo/python-list

Re: Moving Places, Subtracting from slices/lists

2005-06-03 Thread Mark Sargent
>what does [hotcat[1]] do.? > > > ah, quite simple really, adds roof to the end of hotcat...thanx.. Mark Sargent. -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding a command to a Pmw.counter widget

2005-06-06 Thread Mark Light
Martin Franklin wrote: > Mark Light wrote: > > Hi, > >I have a Pmw.Counter widget and I would like to add a command > > that is called on pressing either the up or down arrows (the > > command will be the same for both). I have managed to do this

Re: Any way to not create .pyc files?

2005-06-09 Thread Mark Tolonen
c "import script" old [4] C:\ex>script old [5] C:\ex>echo print "new" > script.py [6] C:\ex>script old [7] C:\ex>python -c "import script" new [8] C:\ex>script new Even though script.py contains new (line 5), script in line 6 runs the .pyc generated by line 3. To fix this problem, put .py and .pyw extenstions ahead of .pyc and .pyo in PATHEXT. Hope this helps, Mark -- http://mail.python.org/mailman/listinfo/python-list

splitting delimited strings

2005-06-15 Thread Mark Harrison
tring into characters and use a FSM, but it seems that's not very pythonesqe. @rv@ 2 @db.locks@ @//depot/hello.txt@ @mh@ @mh@ 1 1 44 @pv@ 0 @db.changex@ 44 44 @mh@ @mh@ 1118875308 0 @ :@@: :: @ (this is from a perforce journal file, btw) Many TIA! Mark -- Mark Harrison Pixar Animation S

Re: splitting delimited strings

2005-06-15 Thread Mark Harrison
Paul McNett <[EMAIL PROTECTED]> wrote: > Mark Harrison wrote: > > What is the best way to process a text file of delimited strings? > > I've got a file where strings are quoted with at-signs, @like [EMAIL > > PROTECTED] > > At-signs in the string are represen

Python rocks

2007-06-02 Thread Mark Carter
Well, I know I'm preaching to the converted - but Python rocks. I've been enchanted by the siren calls of Scheme, Lisp and Forth, but in the end, I find Python much easier. I even tried a little bit of Tcl. To give a bit of context ... I have recently switched from Windows to OS X and Linux. I

Re: Python rocks

2007-06-02 Thread Mark Carter
Steve Howell wrote: > --- Mark Carter <[EMAIL PROTECTED]> wrote: > >> Well, I know I'm preaching to the converted - but >> Python rocks. >> [...] > > A few questions from the choir: > > As a recent newcomer to the language, did you > encount

Re: Error message if there is a space in the source directory

2007-06-02 Thread Mark Peters
> When using a source like this on line 5: > > source = [r'C:\test\test 2\\'] > > which has a space in the title, the program will not work. Try wrapping that argument in double quotes when you build the command -- http://mail.python.org/mailman/listinfo/python-list

Re: Python rocks

2007-06-02 Thread Mark Carter
Josiah Carlson wrote: > Mark Carter wrote: >> Not that I'm particularly knowledgeable about language design issues, >> but maybe closures and slightly different scoping rules would be nice. > > Python has had closures for years. I just looked up http://ww

Re: Python rocks

2007-06-03 Thread Mark Carter
Alex Martelli wrote: > Mark Carter <[EMAIL PROTECTED]> wrote: > Yes, GMP is a pain to compile (especially on Mac OS X), but I believe > Just mentioning this in case you want to give Scheme another chance Thanks. I'll take a look at it. I think I've decided to finish of

Re: Python rocks

2007-06-03 Thread Mark Carter
Alex Martelli wrote: > Josiah Carlson <[EMAIL PROTECTED]> wrote: > >>> pitfall of Python is knowing whether an operation is destructive or not. >> If it returns None, it probably changes the content of an object. > > A reasonable heuristic, but with lots of exceptions, alas: > somedict.get(so

Re: Who uses Python?

2007-06-04 Thread Mark Carter
walterbyrd wrote: > Anything else? Finance? Web-analytics? SEO? Digital art? I played with NodeBox a little while ago: http://nodebox.net/code/index.php/Home "NodeBox is a Mac OS X application that lets you create 2D visuals (static, animated or interactive) using Python programming code and ex

Re: Who uses Python?

2007-06-04 Thread Mark Carter
Thomas Jollans wrote: > Broadly speaking, everyone who uses python programs in it and may thus be > considered a "programmer". A woman from a job agency 'phoned me up the other day, and asked me if I was any good with "algortihms". I told her that all programs are algorithms, so the question

Re: Determinant of Large Matrix

2007-06-07 Thread Mark Westwood
with Numpy. Regards Mark Westwood PS 13x13 isn't a large matrix ! On Jun 6, 12:10 pm, James Stroud <[EMAIL PROTECTED]> wrote: > Hello All, > > I'm using numpy to calculate determinants of matrices that look like > this (13x13): > > [[ 0. 1. 1. 1. 1. 1.

Re: Why can not catch the inner exception

2007-06-07 Thread Mark T
"人言落日是天涯,望极天涯不见家" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Please see the follow code, I can not catch the exception " IOError" raised from shutil.copyfile() , why? try: if (DEST_TYPE & TYPE_FTP): fn = oname

Re: Running a process every N days

2007-06-08 Thread Mark Westwood
Hi Dan FWIW I'd use logrotate for this. Regards Mark Westwood On Jun 7, 11:27 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > What's the best way to run either an entire python process or a python > thread every N days. I'm running Python 2.4.3 on Fedor

Re: Working with fixed format text db's

2007-06-08 Thread Mark Carter
Neil Cerutti wrote: > The underlying problem, of course, is the archaic flat-file > format with fixed-width data fields. Even the Department of > Education has moved on to XML for most of it's data files, :( I'm writing a small app, and was wondering the best way to store data. Currently the fi

Re: passing arguments to tcpserver classes

2007-06-13 Thread Mark T
elf.arg2 = arg2 class MyHandler(SocketServer.StreamRequestHandler): def handle(self): print self.server.arg1 print self.server.arg2 if __name__ == '__main__': srv = MyServer(('',5000),MyHandler,123,456) srv.serve_forever() --Mark -- http://mail.python.org/mailman/listinfo/python-list

sqlite3 bug??

2007-06-17 Thread mark carter
I hesitate to ask, but ... I'm using Ubuntu Feisty: * Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 * SQLite version 3.3.13 Suppose I run the following program: import sqlite3 conn = sqlite3.connect('example') c = conn.cursor() # Create

Re: sqlite3 bug??

2007-06-17 Thread mark carter
David Wahler wrote: > On 6/17/07, mark carter <[EMAIL PROTECTED]> wrote: >> Anyone else getting these problems? > > See http://www.python.org/dev/peps/pep-0249/ (emphasis mine): > >.commit() OK, I tried that, and I appear to be cooking. The funny thing is, I co

Re: sqlite3 bug??

2007-06-17 Thread mark carter
7stud wrote: > On Jun 17, 7:16 am, mark carter <[EMAIL PROTECTED]> wrote: >> David Wahler wrote: >>> On 6/17/07, mark carter <[EMAIL PROTECTED]> wrote: >>>> Anyone else getting these problems? >>> Seehttp://www.python.org/dev/peps/pep-0249/(em

Re: sqlite3 bug??

2007-06-17 Thread mark carter
Carsten Haese wrote: > On Sun, 2007-06-17 at 07:43 -0700, 7stud wrote: >> Please report the whole docs as a bug. > > I imagine the author appreciates constructive criticism. This is not > constructive criticism. > > In other words: Pointing out specific shortcomings and ways to correct > them, su

wxPython - embed separate script in panel?

2007-06-19 Thread mark . martinez2
This is a wxPython question.. the wxPython group is pretty much inactive. I have an MDI parent frame and child frame set up. In the child frame, I want to use part of the frame to display the output from a .py that is mainly matplotlib (a graph) in a section of the frame. How can I get it to autom

Transfer file name input from one .py to another

2007-06-19 Thread mark . martinez2
How do I transfer the file name which is input in one .py (an MDI parent frame in wxPython) to another .py (an MDI child frame)? The parent gets the file name from the user via a file select dialog, but the child frame is the one that needs to know what file it is working with. Thanks -- http://

Re: simplifying algebraic expressions

2007-06-26 Thread Mark Westwood
for 'program transformation' and follow some of the links. Good luck ! Mark Westwood On 26 Jun, 12:06, DavidM <[EMAIL PROTECTED]> wrote: > On Tue, 26 Jun 2007 11:11:39 +0100, Robin Becker wrote: > > I have seen this sort of evolution strategy in the past and it's ve

Re: Shed Skin Python-to-C++ Compiler 0.0.21, Help needed

2007-06-29 Thread Mark Dufour
syco on my computer), please visit the homepage at: http://mark.dufour.googlepages.com I could really use some help in pushing Shed Skin forward. Please try the latest release and send in bug reports, or join the project via the homepage. Thanks, Mark Dufour. On 3/31/07, Mark Dufour <[EM

Re: Shed Skin Python-to-C++ Compiler 0.0.21, Help needed

2007-07-01 Thread Mark Dufour
e, and compile this into an extension module or separate program. Look at Shed Skin as something that allows you to write fast extension modules in pure Python, not as something that can convert arbitrary Python programs. Thanks, Mark Dufour. -- "One of my most productive days was thr

Re: Probably simple syntax error

2007-07-01 Thread Mark Peters
> **weights_array(randomizing_counter) = small_randomized_int > > The starred line is the one getting the error message: "SyntaxError: > can't assign to function call" > > Now, I do understand what this means. I'm trying to assign to a > function instead of the value that the function shoul

Re: The best platform and editor for Python

2007-07-05 Thread Mark Morss
On Jul 1, 3:30 pm, "Sönmez Kartal" <[EMAIL PROTECTED]> wrote: "Emacs is the best for anything for me." Me too. Also, as pointed out by some others, a debugger is not really all that necessary for an interpreted language like Python. > > Hi, > > For experienced with Pyhton users, which developing

Re: Shed Skin Python-to-C++ Compiler 0.0.21, Help needed

2007-07-10 Thread mark . dufour
practically no help at all). >But there is such a large gap betwixt the >twain that such dreaming is but an excercise in fantasy (there's >always pypy). yes, pypy will solve all problems, including world hunger ^^ thanks, mark dufour - shed skin author -- http://mail.python.org/mailman/listinfo/python-list

Re: Fast powerset function

2007-07-13 Thread Mark Dickinson
ey appear and don't need to store them all at once, then it's significantly faster (on my machine) if you replace the line subset = subset ^ d[i & -i] with an in-place update: subset ^= d[i & -i]. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Exiting from python shell

2007-07-18 Thread Mark Elston
k would spontaneously spoil, among other anomalies. > > For these reasons, you might propose a "quit" keyword. > > James > You know, some answers simply *must* be saved for posterity Mark -- http://mail.python.org/mailman/listinfo/python-list

Python training in Colorado, June 2007

2007-04-19 Thread Mark Lutz
Python author and trainer Mark Lutz will be teaching another 3-day Python class at a conference center in Longmont, Colorado, on June 11-13, 2007. This is a public training session open to individual enrollments, and covers the same topics as the 3-day onsite sessions that Mark teaches, with

Re: Vector classes

2007-04-22 Thread Mark Dickinson
5, 6]) [4, 5, 6] >>> c = a + b >>> print b.vals [5, 7, 9] Something like def __add__(self, other): return Vector(x + y for x, y in zip(self.vals, other.vals)) might work better. Similarly for the __sub__ method. Have you considered using numpy? Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: str() and repr() question

2007-04-26 Thread Mark T
rmally. > > Where is the problem here? > Thanks in advance. > You might want to check out pychecker.py. Its output: Processing Script1... Warnings... Script1.py:1: Imported module (glob) not used Script1.py:1: Imported module (string) not used Script1.py:9: Local variable (alllines) not used Script1.py:20: (str) shadows builtin You've replaced the built-in function str with the return value of DoTestTime(). -Mark -- http://mail.python.org/mailman/listinfo/python-list

Lisp for the C21

2007-05-04 Thread Mark Tarver
htm for our take on this one. Mark -- http://mail.python.org/mailman/listinfo/python-list

Help creating Tiger hash function in Python

2007-05-06 Thread Mark Livingstone
Hello! I am a Uni student and for a project in Information Systems Security due in just under two weeks, I have tried to make a Python version of the Biham / Anderson Tiger Hash function. I have put the original C source and my two files Tiger.py and doHash.py on my website: http://www.users.on.n

Re: Python compared to other language

2007-05-21 Thread Mark Morss
On May 20, 5:02 pm, Bruno Desthuilliers >Ruby is probably far better than Python at sys-admin tasks. Why, pray tell? I don't know much about Ruby, but I know that Python is the language that Gentoo uses for package management, which certainly qualifies as a sys-admin task. -- http://mail.pytho

Re: Threaded Design Question

2007-08-09 Thread Mark T
y. Any suggestions would be greatly appreciated. > > ~Sean > Just rename the file. We've used that technique in a similar application at my work for years where a service looks for files of a particular extension to appear in a directory. When the service sees a file, in renames it to a different extension and spins off a thread to process the contents. -Mark T. -- http://mail.python.org/mailman/listinfo/python-list

Shed Skin Python-to-C++ compiler 0.0.23

2007-08-20 Thread Mark Dufour
l RSI) -add more tests to unit.py Thanks, Mark Dufour. -- "One of my most productive days was throwing away 1000 lines of code" - Ken Thompson -- http://mail.python.org/mailman/listinfo/python-list

Re: Python equivalent of Perl's $/

2007-08-20 Thread Mark T
Without wishing to start a flame war, is there a way to do this in Python? > > Regards, John > -- > War is God's way of teaching Americans geography > Ambrose Bierce (1842 - 1914) >>> 'test\ntest2.\ntest3\ntest4.\ntest5'.split('.\n') ['test\ntest2', 'test3\ntest4', 'test5'] -Mark T. -- http://mail.python.org/mailman/listinfo/python-list

Re: Does shuffle() produce uniform result ?

2007-08-24 Thread Mark Dickinson
thers. But since there are now so many values, you'd again have problems detecting any bias. Steven Holden wrote: > Frankly I don't think you need to worry. What he said. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Does shuffle() produce uniform result ?

2007-08-24 Thread Mark Dickinson
On Aug 24, 9:30 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > x = floor((n/2**53)*7) > > will produce 0, 1, 3 and 5 with probability (2**53//7+1)/2**53, and 2, > 4 and 6 with probability (2**53//7)/2*53. Oops---I lied; I forgot to take into account the rounding implicit

Re: convert non-delimited to delimited

2007-08-27 Thread Mark Elston
> a="01397256359210100534+42050-102800FM-15+1198KAIA" >>> print "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s" % (a[0:4],a[4:10],a[10:15],a[15:19],a[19:21],a[21:23],a[23:25], a[25:27],a[27],a[28:34],a[34:41],a[41:46],a[46:51],a[51:]) which result

Re: int/long bug in locale?

2007-08-28 Thread Mark Dickinson
On Aug 28, 10:03 am, [EMAIL PROTECTED] wrote: > Is there an int/long related bug lurking in locale? Looks like this has already been reported: See http://bugs.python.org/issue1742669 Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Biased random?

2007-08-30 Thread Mark Dickinson
2 both end up being 2), but there's only one integer n for which abs(n) == 0. One possible fix: do x = randint(0, 10) - randint(0, 10) x = abs(x) - (x<0) This collapses -1 and 0 to 0, -2 and 1 to 1, etc. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Biased random?

2007-08-30 Thread Mark Dickinson
> One possible fix: do > > x = randint(0, 10) - randint(0, 10) > x = abs(x) - (x<0) > > This collapses -1 and 0 to 0, -2 and 1 to 1, etc. Or a slightly simpler formula that ends up producing the same distribution: x = min(randint(0, 10), randint(0, 10)) Mark -- h

Re: Why is this loop heavy code so slow in Python? Possible Project Euler spoilers

2007-09-02 Thread Mark Dickinson
turning off gcc's optimiser with the -O0 flag, the C version is still > > > 100 times quicker. Well, for one thing, you're creating half a million xrange objects in the course of the search. All the C code has to do is increment a few integers. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is this loop heavy code so slow in Python? Possible Project Euler spoilers

2007-09-02 Thread Mark Dickinson
On Sep 2, 12:55 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: > Mark Dickinson <[EMAIL PROTECTED]> wrote: > > Well, for one thing, you're creating half a million xrange objects in > > the course of the search. All the C code has > > to do is increment a few integers

Re: Why is this loop heavy code so slow in Python? Possible Project Euler spoilers

2007-09-02 Thread Mark Dickinson
single machine instruction. Mark Code and timings: (Python 2.5.1/G4.) def test(): solutions = [0] * 1000 for a in xrange(1, 1000): for b in xrange(1, 1000 - a): for c in xrange(1, 1000 - a - b): if a*a + b*b == c*c: solutions[a+b+c

Colorado Python training in October

2007-09-03 Thread Mark Lutz
Python author and trainer Mark Lutz will be teaching another 3-day Python class at a conference center in Longmont, Colorado, on October 23-25, 2007. This is a public training session open to individual enrollments, and covers the same topics as the 3-day onsite sessions that Mark teaches, with

An ordered dictionary for the Python library?

2007-09-12 Thread Mark Summerfield
I feel that Python lacks one useful data structure: an ordered dictionary. I find such data structures v. useful in C++. I know that in Python the sort function is v. fast, but often I prefer never to sort but simply to use an ordered data structure in the first place. (I'm aware that for ordered

Re: An ordered dictionary for the Python library?

2007-09-12 Thread Mark Summerfield
On 12 Sep, 13:46, Michele Simionato <[EMAIL PROTECTED]> wrote: > On Sep 12, 2:42 pm, Steven D'Aprano <[EMAIL PROTECTED] > > cybersource.com.au> wrote: > > On Wed, 12 Sep 2007 07:33:45 +, Mark Summerfield wrote: > > In fact, I'm not sure what people me

Re: An ordered dictionary for the Python library?

2007-09-12 Thread Mark Summerfield
On 12 Sep, 15:04, Michele Simionato <[EMAIL PROTECTED]> wrote: > On Sep 12, 3:54 pm, Mark Summerfield <[EMAIL PROTECTED]> > wrote: > > > > > On 12 Sep, 13:46, Michele Simionato <[EMAIL PROTECTED]> > > > Actually I meant by key order, so insertio

Re: An ordered dictionary for the Python library?

2007-09-12 Thread Mark Summerfield
On 13 Sep, 00:03, Paul Rubin <http://[EMAIL PROTECTED]> wrote: > Mark Summerfield <[EMAIL PROTECTED]> writes: > > I feel that Python lacks one useful data structure: an ordered > > dictionary. > > Do other Python programmers feel this lack? Is this worth a PEP? >

Re: Randomizing in Python

2007-03-03 Thread Mark Nenadov
a random > experience database for a game. What would be necessary to do so? Look into the random module (http://docs.python.org/lib/module-random.html) random.choice selects a random item out of a sequence random.shuffle shuffles a sequence randomly random.random gives a random floating point

Signed zeros: is this a bug?

2007-03-11 Thread Mark Dickinson
Should the above be considered a bug, or is Python not expected to honour signs of zeros? I'm working in a situation involving complex arithmetic where branch cuts, and hence signed zeros, are important, and it would be handy if the above code could be relied upon to do the right thing. Mar

Re: Signed zeros: is this a bug?

2007-03-11 Thread Mark Dickinson
On Mar 11, 12:13 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > "Dan Bishop" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | On Mar 11, 9:31 am, "Mark Dickinson" <[EMAIL PROTECTED]> wrote: > | > I get the follow

Re: Signed zeros: is this a bug?

2007-03-11 Thread Mark Dickinson
SVC (every platform C compiler has its own set > > of gimmicks for "dealing with" these things). Understood. Platform dependent is fine. But does this really excuse results like the following? >>> from math import atan2 >>> x = -0.; print atan2(0., -1.) -3.14159

Re: Signed zeros: is this a bug?

2007-03-11 Thread Mark Dickinson
build the > bytecode you need. Yup: the workaround seems to be as simple as replacing all occurrences of -0.0 with -(0.0). I'm embarrassed that I didn't figure this out sooner. >>> x, y = -(0.0), 0.0 >>> x, y (-0.0, 0.0) Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Signed zeros: is this a bug?

2007-03-11 Thread Mark Dickinson
r "license" for more information.>>> > 0.0,-0.0 > (0.0, -0.0) > >>> -0.0,0.0 > > (-0.0, 0.0) > > so it seems to be very specifically a 2.5 problem. I've filed a bug report (bug #1678380) and got an impressively quick response from MvL. It l

Re: Signed zeros: is this a bug?

2007-03-11 Thread Mark Dickinson
problems above surfaced. By the way, I don't suppose that anybody would be interested in a rewritten cmath for Python 2.6? It wouldn't be hard for me to rewrite what I already have in C, and add suitable documentation and tests. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Signed zeros: is this a bug?

2007-03-11 Thread Mark Dickinson
hon's svn). It does, and all tests pass. (Still on OS X 10.4.8/PowerPC; I'll test it tomorrow on my Linux machine at work.) Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: To count number of quadruplets with sum = 0

2007-03-17 Thread mark . dufour
else: h[x+y] = 1 for x in e: for y in r: sch += h.get(-(x+y),0) print sch print time.clock() - t Thanks, Mark Dufour (Shed Skin author - send me bug reports!) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-21 Thread Mark T
e.next and placed in node, also losing the original value of node. -Mark T. > > as > node = node.next = nextnode > > only to discover that Python performs chained assignments > backwards compared to other languages, i.e. left-to-right > instead of right-to-left. From the user&#

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-21 Thread Mark T
of y there. > > > Alex This is interesting: >>> class Test(object): ... def __getattribute__(self,n): ... print 'reading',n ... return object.__getattribute__(self,n) ... def __setattr__(self,n,v): ... print 'writing',n,v ... return object

Re: Python object overhead?

2007-03-23 Thread Mark Nenadov
I don't think you can get around some overhead with the objects. However, in terms of generally efficiency not specifically related to object instantiation, you should look into xreadlines(). I'd suggest doing the following instead of that while loop: for line in open(sys.argv[1]).

Re: Python object overhead?

2007-03-23 Thread Mark Nenadov
time units" open() iterator -> 0.41 "time units" -- Mark Nenadov -> skype: marknenadov, web: http://www.marknenadov.com -> "They need not trust me right away simply because the British say that I am O.K.; but they are so ridiculous. Microphones everywhere and planted

Re: How to find to HTML strings and 'save' them?

2007-03-25 Thread Mark Crowther
Yep, I agree! once I've got this done I'll be back to trawling the tutorials. Life never gives you the convenience of learning something fully before having to apply what you have learnt ;] Thanks for the feedback and links, I'll be sure to check those out. Mark. On Mar 26, 12:

Re: To count number of quadruplets with sum = 0

2007-03-26 Thread mark . dufour
with > Shed Skin CVS at least: after optimizing dicts a bit for Shedskin 0.0.21 (http:// mark.dufour.googlepages.com), the speedup for this program is now about 16.5 times for the same test. Thanks, Mark Dufour (Shed Skin author - send me bug reports!) -- http://mail.python.org/mailman/listinfo/python-list

Re: Fortran vs Python - Newbie Question

2007-03-27 Thread Mark Morss
On Mar 26, 12:59 pm, "Erik Johnson" <[EMAIL PROTECTED]> wrote: > <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > OK... > > I've been told that Both Fortran and Python are easy to read, and are > > quite useful in creating scientific apps for the number crunching, but > > then

Re: Fortran vs Python - Newbie Question

2007-03-27 Thread Mark Morss
On Mar 27, 12:55 pm, Jaap Spies <[EMAIL PROTECTED]> wrote: > Mark Morss wrote: > > > Maybe somebody reading this will be able to convince me to look again > > at Numpy/Scipy, but for the time being I will continue to do my > > serious numerical computation in Fortran.

Re: Python automatic testing: mocking an imported module?

2007-03-28 Thread Mark T
port foo" will import the foo.py in foo_fake directory before the one in the local directory. # unverified code import sys sys.path.append(0,'foo_fake') # add foo_fake to front of path import foo foo.bar() execfile('testee.py') sys.path.pop(0) # remove foo_fake reload(foo) foo.bar() execfile('testee.py') -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Indentation for code readability

2007-03-30 Thread Mark Jackson
x(); > } > popMatrix(); > > The curly brackets have no functional meaning but increase the > readability significantly. You are e. e. cummings, and I claim my £5. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson Every 10 years we say t

<    36   37   38   39   40   41   42   43   44   45   >