Re: Writing an interpreter for language similar to python!!

2007-03-02 Thread Jim
On Mar 1, 1:16 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > This post begs the following questions: > > - Why make a new language, when > - It is going to be an inferior subset of Python - > - What can the motivation be to do this instead of contributing to the python > effort? Perhaps the

Re: Questions about app design - OOP with python classes

2007-03-02 Thread GHUM
> > if hmmCurrentHeight <= hinCriticalHeight: > then you should instantly recognise that there's a problem. all civilized nations but one use metric systems. Of course there is a problem if you spot inches somewhere. Harald -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Source Code Beautifier

2007-03-02 Thread Alan Franzoni
Il 28 Feb 2007 14:09:09 -0800, [EMAIL PROTECTED] ha scritto: > Seems obvious and desirable to me. Bare "=" is the way you assign a > name to an object; saying "NAME =" will rebind the name, breaking the > connection between a and b. Without it, they continue to refer to the > same object; exten

Sorting strings containing special characters (german 'Umlaute')

2007-03-02 Thread [EMAIL PROTECTED]
Hi ! I know that this topic has been discussed in the past, but I could not find a working solution for my problem: sorting (lists of) strings containing special characters like "ä", "ü",... (german umlaute). Consider the following list: l = ["Aber", "Beere", "Ärger"] For sorting the letter "Ä" i

Re: Sorting strings containing special characters (german 'Umlaute')

2007-03-02 Thread Robin Becker
[EMAIL PROTECTED] wrote: > Hi ! > > I know that this topic has been discussed in the past, but I could not > find a working solution for my problem: sorting (lists of) strings > containing special characters like "ä", "ü",... (german umlaute). > Consider the following list: > l = ["Aber", "Beere",

Re: Sorting strings containing special characters (german 'Umlaute')

2007-03-02 Thread Peter Otten
[EMAIL PROTECTED] wrote: > I know that this topic has been discussed in the past, but I could not > find a working solution for my problem: sorting (lists of) strings > containing special characters like "ä", "ü",... (german umlaute). > Consider the following list: > l = ["Aber", "Beere", "Ärger"]

Re: Converting a c array to python list

2007-03-02 Thread zefciu
I have just read about buffer and array objects and I think one of them could be fit for my need. However there are two questions. If i make a buffer from a part of dynamically allocated memory, what would free it? Should it be allocated with malloc or some python-specific function? How on eart

Re: How to update DNS record

2007-03-02 Thread Martin P. Hellwig
Andi Clemens wrote: > > It's working!!! > Yeah! > I don't know why I didn't get this the first time I tried dnspython, but now > its working! And it's so easy, 3 lines of code: > > def make_dns_entry(pix): > update = dns.update.Update(_DOMAIN) > update.replace(pix.name, 3600, 'a', pix.

Re: class declaration shortcut

2007-03-02 Thread Bjoern Schliessmann
Steven D'Aprano wrote: > Overkill? Storage of a single attribute holding a (usually short) > string is overkill? No, but storing the first name a class is bound to in it is a bit of, IMHO. > When you do that, you wouldn't expect the __name__ of > some.module.function to change to f, and it does

Re: Matplotlib axes label

2007-03-02 Thread John Henry
On Mar 1, 10:07 pm, "John Henry" <[EMAIL PROTECTED]> wrote: > On Mar 1, 9:53 pm, [EMAIL PROTECTED] wrote: > > > > > On Mar 1, 3:10 pm, "John Henry" <[EMAIL PROTECTED]> wrote: > > > > I've been asking this question at the matplotlib user list and never > > > gotten an answer. I am hoping that there

Python GUI + OpenGL

2007-03-02 Thread Achim Domma
Hi, I'm developing a GUI app in Python/C++ to visualize numerical results. Currently I'm using Python 2.4 with wx and PyOpenGLContext, but there are no windows binaries for Python 2.5 for quite some time now. I need a OpenGL context without restrictions and some settings dialogs. Is wx + PyOpe

tkinter what do you use?

2007-03-02 Thread Gigs_
list = Listbox() list.insert('end', x) list.insert(END, x) what do you use 'end' or END? -- http://mail.python.org/mailman/listinfo/python-list

Re: Matplotlib axes label

2007-03-02 Thread attn . steven . kuo
On Mar 2, 7:02 am, "John Henry" <[EMAIL PROTECTED]> wrote: > On Mar 1, 10:07 pm, "John Henry" <[EMAIL PROTECTED]> wrote: > > > > > On Mar 1, 9:53 pm, [EMAIL PROTECTED] wrote: > (snipped) > > > You can try adjusting the labels and ticks > > > using matplotlib.ticker. > > > > To the example you cit

Re: Sorting strings containing special characters (german 'Umlaute')

2007-03-02 Thread Hallvard B Furuseth
[EMAIL PROTECTED] writes: > For sorting the letter "Ä" is supposed to be treated like "Ae", > therefore sorting this list should yield > l = ["Aber, "Ärger", "Beere"] Are you sure? Maybe I'm thinking of another language, I thought Ä shold be sorted together with A, but after A if the words are ot

Re: float64 print digits

2007-03-02 Thread Grant Edwards
On 2007-03-02, Ulrich Dorda <[EMAIL PROTECTED]> wrote: > I need a pytho nscript to read numbers(with loads of digits) from a > file, do some basic math on it and write the result out to another file. > > My problem: I don't get python to use more digits: > > In order to try this I type: > > The no

A more navigable Python Library Reference page

2007-03-02 Thread m . n . summerfield
Although a fan of Python, I find the Python Library Reference page (lib.html) very inconvenient because of its book contents-like layout. Also, some things that seem to me to belong together, such as string methods and string services are dispersed. Another annoyance is that it is so verbose: this

Python installation problem

2007-03-02 Thread Ray Buck
I've been trying to install Mailman, which requires a newer version of the Python language compiler (p-code generator?) than the one I currently have on my linux webserver/gateway box. It's running a ClarkConnect 2.01 package based on Red Hat 7.2 linux. I downloaded the zipped tarball (Python-

Re: Tkinter menus

2007-03-02 Thread Eric Brunel
On Fri, 02 Mar 2007 13:41:12 +0100, Gigs_ <[EMAIL PROTECTED]> wrote: > is it alright to use Menu instead Toplevel or Tk > like this? > > from Tkinter import * > from tkMessageBox import * > > class MenuDemo(Menu): > def __init__(self, master=None): > Menu.__init__(self, master) >

Re: tkinter what do you use?

2007-03-02 Thread Eric Brunel
On Fri, 02 Mar 2007 16:17:32 +0100, Gigs_ <[EMAIL PROTECTED]> wrote: > list = Listbox() > list.insert('end', x) > list.insert(END, x) > > > what do you use 'end' or END? >>> from Tkinter import END >>> END == 'end' True So this isn't really important... My personal usage varies: for your use c

Re: Sorting strings containing special characters (german 'Umlaute')

2007-03-02 Thread Bjoern Schliessmann
Hallvard B Furuseth wrote: > [EMAIL PROTECTED] writes: >> For sorting the letter "Ä" is supposed to be treated like "Ae", >> therefore sorting this list should yield >> l = ["Aber, "Ärger", "Beere"] > > Are you sure? Maybe I'm thinking of another language, I thought Ä > shold be sorted together

AJAX Calander like Google Calender

2007-03-02 Thread lalit
Hi all, I would like to make the the calender cery similar to google event calander in python. can any one help me where i will get library that uses AJAX is this feasible reg, Lalit -- http://mail.python.org/mailman/listinfo/python-list

Re: Sorting strings containing special characters (german 'Umlaute')

2007-03-02 Thread [EMAIL PROTECTED]
On 2 Mrz., 15:25, Peter Otten <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > For sorting the letter "Ä" is supposed to be treated like "Ae", There are several way of defining the sorting order. The variant "ä equals ae" follows DINDIN 5007 (according to wikipedia); defining (a equals ä)

Re: Dialog with a process via subprocess.Popen blocks forever

2007-03-02 Thread bayer . justin
> If you are both waiting for input, you have a Mexican standoff... That is not the problem. The problem is, that the buffers are not flushed correctly. It's a dialogue, so nothing complicated. But python does not get what the subprocess sends onto the subprocess' standard out - not every time, an

Re: class declaration shortcut

2007-03-02 Thread Arnaud Delobelle
On Mar 2, 3:01 pm, Bjoern Schliessmann wrote: > Steven D'Aprano wrote: > > Overkill? Storage of a single attribute holding a (usually short) > > string is overkill? > > No, but storing the first name a class is bound to in it is a bit > of, IMHO. Don't see it as the first name a class is bound to

Re: ANN: PyDSTool now compatible with numpy 1.0.1, scipy 0.5.2 and 64-bit CPUs.

2007-03-02 Thread Rob Clewley
Mike, Yes, that is a pretty fair description of our support for symbolics using Python's own inheritance. Our ModelSpec classes provide only an elementary form of inheritance, polymorphism and type checking. We hope to expand our existing support for hybrid/DAE systems at the level of our ModelSpe

Re: Python GUI + OpenGL

2007-03-02 Thread Diez B. Roggisch
Achim Domma wrote: > Hi, > > I'm developing a GUI app in Python/C++ to visualize numerical results. > Currently I'm using Python 2.4 with wx and PyOpenGLContext, but there > are no windows binaries for Python 2.5 for quite some time now. > > I need a OpenGL context without restrictions and some

Re: Dialog with a process via subprocess.Popen blocks forever

2007-03-02 Thread Bernhard Herzog
[EMAIL PROTECTED] writes: > So, once I start the C Program from the shell, I immediately get its > output in my terminal. If I start it from a subprocess in python and > use python's sys.stdin/sys.stdout as the subprocess' stdout/stdin I > also get it immediately. If stdout is connected to a term

is it bug or feature in xml.dom.minidom?

2007-03-02 Thread Maksim Kasimov
Hi, i'm faced with such a problem when i use xml.dom.minidom: to append all child nodes from "doc" in "_requ" to "doc" in "_resp", i do the following: _requ = minidom.parseString("OneTwo") _resp = minidom.parseString("") iSourseTag = _requ.getElementsByTagName('doc')[0] iTargetTag = _resp.ge

Re: Dialog with a process via subprocess.Popen blocks forever

2007-03-02 Thread Donn Cave
In article <[EMAIL PROTECTED]>, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Thu, 01 Mar 2007 14:42:00 -0300, <[EMAIL PROTECTED]> escribió: > > > BUT If I use PIPE for both (so I can .write() on the stdin and .read() > > from the subprocess' stdout stream (better: file descriptor)) readin

HL7 servers in Python?

2007-03-02 Thread Richard Low, MD
Richard, I was most impressed by your answer below (in '03) Do you know whether there is a third party application/library that can interface our software to the HL7 sockets systems so we do not have to develop them? If you do, which one would you recommend? Thank you, [] Richard M. Low M

Re: Python GUI + OpenGL

2007-03-02 Thread Mike C. Fletcher
Achim Domma wrote: > Hi, > > I'm developing a GUI app in Python/C++ to visualize numerical results. > Currently I'm using Python 2.4 with wx and PyOpenGLContext, but there > are no windows binaries for Python 2.5 for quite some time now. > > I need a OpenGL context without restrictions and some s

Re: Python GUI + OpenGL

2007-03-02 Thread MonkeeSage
On Mar 2, 9:17 am, Achim Domma <[EMAIL PROTECTED]> wrote: > I need a OpenGL context without restrictions and some settings dialogs. > Is wx + PyOpenGL the way to go? Or could somebody recommend a better set > of tools/libs? You could use pygtk + pygtkglext. http://pygtk.org/ http://gtkglext.sourc

Re: Sorting strings containing special characters (german 'Umlaute')

2007-03-02 Thread Robin Becker
Bjoern Schliessmann wrote: > Hallvard B Furuseth wrote: >> [EMAIL PROTECTED] writes: ... > > In German, there are some different forms: > > - the classic sorting for e.g. word lists: umlauts and plain vowels > are of same value (like you mentioned): ä = a > > - name list sorting for e.g. pho

Re: pyHook or SetWindowsHookEx

2007-03-02 Thread abcd
:( -- http://mail.python.org/mailman/listinfo/python-list

Python 2.5, problems reading large ( > 4Gbyes) files on win2k

2007-03-02 Thread paduffy
Folks, I've a Python 2.5 app running on 32 bit Win 2k SP4 (NTFS volume). Reading a file of 13 GBytes, one line at a time. It appears that, once the read line passes the 4 GByte boundary, I am getting occasional random line concatenations. Input file is confirmed good via UltraEdit. Groovy versi

Re: Will Python Run On Microsoft Vista?

2007-03-02 Thread vegaseat
On Feb 5, 9:24 am, Jonathan Curran <[EMAIL PROTECTED]> wrote: > On Monday 05 February 2007 11:08, slogging_away wrote: > > > I know, I know - flame away but its not clear to me if Python will run > > on a system running MicrosoftVista. Is anyone successfully running > > Python onVista? If so, is

Re: Python 2.5, problems reading large ( > 4Gbyes) files on win2k

2007-03-02 Thread Peter Otten
[EMAIL PROTECTED] wrote: > I've a Python 2.5 app running on 32 bit Win 2k SP4 (NTFS volume). > Reading a file of 13 GBytes, one line at a time. It appears that, > once the read line passes the 4 GByte boundary, I am getting > occasional random line concatenations. Input file is confirmed good >

Re: tkinter what do you use?

2007-03-02 Thread vegaseat
On Mar 2, 8:32 am, "Eric Brunel" <[EMAIL PROTECTED]> wrote: > On Fri, 02 Mar 2007 16:17:32 +0100, Gigs_ <[EMAIL PROTECTED]> wrote: > > list = Listbox() > > list.insert('end', x) > > list.insert(END, x) > > > what do you use 'end' or END? > >>> from Tkinter import END > >>> END == 'end' > > True > >

Re: HL7 servers in Python?

2007-03-02 Thread Tim Churches
Richard Low, MD wrote: > Richard, > > I was most impressed by your answer below (in '03) > > Do you know whether there is a third party application/library that can > interface our software to the HL7 sockets systems so we do not have to > develop them? > > If you do, which one would you recomme

Re: Python 2.5, problems reading large ( > 4Gbyes) files on win2k

2007-03-02 Thread Paul Duffy
I am not using the universal newline. File reading loop is essentially... ifile = open("fileName", "r") for line in ifile ... Thanks Peter Otten wrote: > [EMAIL PROTECTED] wrote: > > >> I've a Python 2.5 app running on 32 bit Win 2k SP4 (NTFS volume). >> Reading a file of 13 GBytes, one li

mercurial is not known from apache2

2007-03-02 Thread soloturn
as i'm not sure if apache2 or python is responsible for this, excuse if i try to ask here too. our problem is that mercurial does not work from apache, but from python command-line it does. what could be a reason for this behaviour? --- from the command

Sort with extra variables

2007-03-02 Thread Thomas Dybdahl Ahle
I have a sort function in a python chess program. Currently it looks like this: def sortMoves (board, table, ply, moves): f = lambda move: getMoveValue (board, table, ply, move) moves.sort(key=f, reverse=True) return moves However I'd really like not to use the lambda, as it slows dow

Re: Sort with extra variables

2007-03-02 Thread Diez B. Roggisch
Thomas Dybdahl Ahle schrieb: > I have a sort function in a python chess program. > Currently it looks like this: > > def sortMoves (board, table, ply, moves): > f = lambda move: getMoveValue (board, table, ply, move) > moves.sort(key=f, reverse=True) > return moves > > However I'd rea

Re: Strange method signature via COM

2007-03-02 Thread Bruno Desthuilliers
Richard Jebb a écrit : > We are trying to use the API of a Win32 app which presents the API as a COM > interface. The sample VB code for getting and setting the values of custom > data fields on an object shows a method named Value(): > > getterobj.Value("myfield") > setterobj.Valu

Re: Sort with extra variables

2007-03-02 Thread Paul Rubin
Thomas Dybdahl Ahle <[EMAIL PROTECTED]> writes: > Do you have any ideas how I can sort these moves the fastest? One idea: if you're using alpha-beta pruning, maybe you can use something like heapq instead of sorting, since a lot of the time you only have to look at the first few moves (ordered bes

Re: Sort with extra variables

2007-03-02 Thread Bjoern Schliessmann
Thomas Dybdahl Ahle wrote: > However I'd really like not to use the lambda, as it slows down > the code. Did you check how much the slowdown is? Regards, Björn -- BOFH excuse #65: system needs to be rebooted -- http://mail.python.org/mailman/listinfo/python-list

Re: Sorting strings containing special characters (german 'Umlaute')

2007-03-02 Thread Bjoern Schliessmann
Robin Becker wrote: > Björn, in one of our projects we are sorting in javascript in > several languages English, German, Scandinavian languages, > Japanese; from somewhere (I cannot actually remember) we got this > sort spelling function for scandic languages > > a > .replace(/\u00C4/g,'A~') //A

Re: class declaration shortcut

2007-03-02 Thread Bjoern Schliessmann
Arnaud Delobelle wrote: > Don't see it as the first name a class is bound to, but rather as > the name a class is defined as. > If class_object.__name__ == 'Foo' it means that somewhere in your > code there is a class definition: > > class Foo: > # stuff > > Same for function: if function_ob

Re: is it bug or feature in xml.dom.minidom?

2007-03-02 Thread Paul Boddie
Maksim Kasimov wrote: > Hi, i'm faced with such a problem when i use xml.dom.minidom: > > to append all child nodes from "doc" in "_requ" to "doc" in "_resp", i do the > following: > > _requ = > minidom.parseString("OneTwo") > _resp = minidom.parseString("") Note that these are different documen

Re: Strange method signature via COM

2007-03-02 Thread Richard Jebb
After digging around in the group archives I've figured it out. It's not been helped by my inability to identify the API's COM server/type library in the list produced by the MakePy utility, so I've largely been flying blind. Some posts on this same subject back in 1999 revealed the answer, namely

Re: How do I Color a QTableView row in PyQt4

2007-03-02 Thread Mel
Now that I can change the row colors of QTableView when loading data I now need to be able to set the color of the row at anytime. I've been trying by using an item delegate but I'm not sure if I'm using it correctly. Would I try and set an item delegate for the row and change the background colo

Re: Converting a c array to python list

2007-03-02 Thread Russell E. Owen
In article <[EMAIL PROTECTED]>, zefciu <[EMAIL PROTECTED]> wrote: > Hi! > > I want to embed a function in my python application, that creates a > two-dimensional array of integers and passes it as a list (preferably a > list of lists, but that is not necessary, as the python function knows > the

Re: Matplotlib axes label

2007-03-02 Thread John Henry
On Mar 2, 7:22 am, [EMAIL PROTECTED] wrote: > On Mar 2, 7:02 am, "John Henry" <[EMAIL PROTECTED]> wrote: > > > On Mar 1, 10:07 pm, "John Henry" <[EMAIL PROTECTED]> wrote: > > > > On Mar 1, 9:53 pm, [EMAIL PROTECTED] wrote: > > (snipped) > > > > > > > You can try adjusting the labels and ticks > > >

Re: class attrdict

2007-03-02 Thread James Stroud
Hallvard B Furuseth wrote: > Does this class need anything more? > Is there any risk of a lookup loop? > Seems to work... > > class attrdict(dict): > """Dict where d['foo'] also can be accessed as d.foo""" > def __init__(self, *args, **kwargs): > self.__dict__ = self > dict

classes and functions

2007-03-02 Thread Silver Rock
Friends, I don´t see why using classes.. functions does everything already. I read the Rossum tutotial and two other already. Maybe this is because I am only writing small scripts, or some more serious misunderstandings of the language. Please give me a light. thanks guys, Claire -- http://mai

Re: New to Tkinter GUI building

2007-03-02 Thread Adam
Thanks for the reply, will work with this tomorrow. Adam -- http://mail.python.org/mailman/listinfo/python-list

Perl and Python, a practical side-by-side example.

2007-03-02 Thread Shawn Milo
I'm new to Python and fairly experienced in Perl, although that experience is limited to the things I use daily. I wrote the same script in both Perl and Python, and the output is identical. The run speed is similar (very fast) and the line count is similar. Now that they're both working, I was l

Re: Sort with extra variables

2007-03-02 Thread Thomas Dybdahl Ahle
Den Fri, 02 Mar 2007 21:13:02 +0100 skrev Bjoern Schliessmann: > Thomas Dybdahl Ahle wrote: > >> However I'd really like not to use the lambda, as it slows down the >> code. > > Did you check how much the slowdown is? Yes, the lambda adds 50% -- http://mail.python.org/mailman/listinfo/python-l

Re: classes and functions

2007-03-02 Thread Bruno Desthuilliers
Silver Rock a écrit : > Friends, > > I don´t see why using classes.. functions does everything already. I > read the Rossum tutotial and two other already. > > Maybe this is because I am only writing small scripts, or some more > serious misunderstandings of the language. or both ?-) If you onl

Re: classes and functions

2007-03-02 Thread Nicholas Parsons
Hi Claire, That is the beauty of using Python. You have a choice of using classes and traditional OOP techniques or sticking to top level functions. For short, small scripts it would probably be overkill to use classes. Yet the programmer still has classes in his tool chest if he/she is

Re: Sort with extra variables

2007-03-02 Thread Thomas Dybdahl Ahle
Den Fri, 02 Mar 2007 11:44:27 -0800 skrev Paul Rubin: > Thomas Dybdahl Ahle <[EMAIL PROTECTED]> writes: >> Do you have any ideas how I can sort these moves the fastest? > > One idea: if you're using alpha-beta pruning, maybe you can use > something like heapq instead of sorting, since a lot of th

Re: Sort with extra variables

2007-03-02 Thread Thomas Dybdahl Ahle
Den Fri, 02 Mar 2007 20:33:45 +0100 skrev Diez B. Roggisch: > Thomas Dybdahl Ahle schrieb: >> I have a sort function in a python chess program. Currently it looks >> like this: >> >> def sortMoves (board, table, ply, moves): >> f = lambda move: getMoveValue (board, table, ply, move) >> mo

Re: class declaration shortcut

2007-03-02 Thread Arnaud Delobelle
On Mar 2, 8:28 pm, Bjoern Schliessmann wrote: > This is somehow contrary to my understanding of the Python names > concept. > > What if I use a loop to define several classes based on data -- > they'll all have the same __name__ unless I change it manually. Well that's not a typical way of defini

Re: Sort with extra variables

2007-03-02 Thread MonkeeSage
On Mar 2, 5:11 pm, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote: > Wouldn't that be just as slow? Well, I'm not sure about speed, but with the lambda you're creating a new callable for f every time you call sortMoves. Intuitively, that seems like it would be more of a hit than just doing a lookup

Re: class declaration shortcut

2007-03-02 Thread MonkeeSage
On Feb 28, 1:26 pm, "Luis M. González" <[EMAIL PROTECTED]> wrote: > I've come across a code snippet in www.rubyclr.com where they show how > easy it is to declare a class compared to equivalent code in c#. > I wonder if there is any way to emulate this in Python. I posted like 10 minutes ago, but

How *extract* data from XHTML Transitional web pages? got xml.dom.minidom troubles..

2007-03-02 Thread [EMAIL PROTECTED]
I'm trying to extract some data from an XHTML Transitional web page. What is best way to do this? xml.dom.minidom.parseString("text of web page") gives errors about it not being well formed XML. Do I just need to add something like or what? Chris -- http://mail.python.org/mailman/listinfo/py

thread safe SMTP module

2007-03-02 Thread Gordon Messmer
I believe that I've seen this discussed previously, so maybe there's some interest in it. I wrote a threaded mail filtering framework a while ago, and one of the modules does address verification via SMTP. Since smtplib.SMTP uses blocking IO, it can block the whole interpreter. Sometimes the

Re: class declaration shortcut

2007-03-02 Thread Luis M. González
On Mar 2, 8:29 pm, "MonkeeSage" <[EMAIL PROTECTED]> wrote: > On Feb 28, 1:26 pm, "Luis M. González" <[EMAIL PROTECTED]> wrote: > > > I've come across a code snippet inwww.rubyclr.comwhere they show how > > easy it is to declare a class compared to equivalent code in c#. > > I wonder if there is any

Re: How *extract* data from XHTML Transitional web pages? got xml.dom.minidom troubles..

2007-03-02 Thread Paul Boddie
[EMAIL PROTECTED] wrote: > I'm trying to extract some data from an XHTML Transitional web page. > > What is best way to do this? An XML parser should be sufficient. However... > xml.dom.minidom.parseString("text of web page") gives errors about it > not being well formed XML. > > Do I just need t

Re: Sort with extra variables

2007-03-02 Thread Thomas Dybdahl Ahle
Den Fri, 02 Mar 2007 15:20:33 -0800 skrev MonkeeSage: > On Mar 2, 5:11 pm, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote: >> Wouldn't that be just as slow? > > Well, I'm not sure about speed, but with the lambda you're creating a > new callable for f every time you call sortMoves. Intuitively, th

Re: classes and functions

2007-03-02 Thread Thomas Dybdahl Ahle
Den Fri, 02 Mar 2007 19:26:08 -0300 skrev Silver Rock: > Friends, > > I don´t see why using classes.. functions does everything already. I > read the Rossum tutotial and two other already. > > Maybe this is because I am only writing small scripts, or some more > serious misunderstandings of the

Re: How *extract* data from XHTML Transitional web pages? got xml.dom.minidom troubles..

2007-03-02 Thread Thomas Dybdahl Ahle
Den Fri, 02 Mar 2007 15:32:58 -0800 skrev [EMAIL PROTECTED]: > I'm trying to extract some data from an XHTML Transitional web page. > xml.dom.minidom.parseString("text of web page") gives errors about it > not being well formed XML. > Do I just need to add something like or what? As many HTML Tr

Re: Perl and Python, a practical side-by-side example.

2007-03-02 Thread bearophileHUGS
Few suggestions, some important, some less important. All my suggestions are untested. Use 4 spaces to indent. If you want to speed up this code you can move it inside a function. After that, if you want to make it even faster you can use Psyco too. Ho are the dates represented? How do you te

Re: class declaration shortcut

2007-03-02 Thread MonkeeSage
On Mar 2, 5:48 pm, "Luis M. González" <[EMAIL PROTECTED]> wrote: > Thanks for your detailed reply! > So after all, the www.rubyclr.com code is not a fair comparison. > Because the c# code shows a class definition, and the ruby code shows > a struct definition, which is not equivalent to a class. >

Re: How *extract* data from XHTML Transitional web pages? got xml.dom.minidom troubles..

2007-03-02 Thread James Graham
[EMAIL PROTECTED] wrote: > I'm trying to extract some data from an XHTML Transitional web page. > > What is best way to do this? May I suggest html5lib [1]? It's based on the parsing section of the WHATWG "HTML5" spec [2] which is in turn based on the behavior of major web browsers so it should

Re: Sort with extra variables

2007-03-02 Thread MonkeeSage
On Mar 2, 5:51 pm, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote: > I guess the thing is that I'd have to create a new callable no matter > how, as it is the only way to bring the extra variables into the getValue > function when called by sort. Yes, but you don't have to create it every time you

Re: Perl and Python, a practical side-by-side example.

2007-03-02 Thread John Machin
On Mar 3, 9:44 am, "Shawn Milo" <[EMAIL PROTECTED]> wrote: > I'm new to Python and fairly experienced in Perl, although that > experience is limited to the things I use daily. > > I wrote the same script in both Perl and Python, and the output is > identical. The run speed is similar (very fast) an

Newbie Test

2007-03-02 Thread Nicholas Parsons
Greetings, This is just a test to see if I can post to this mailing list. Can someone from the list please respond to this email so I know it worked? Thanks in advance! --Nick -- http://mail.python.org/mailman/listinfo/python-list

Re: Sort with extra variables

2007-03-02 Thread Paul Rubin
Thomas Dybdahl Ahle <[EMAIL PROTECTED]> writes: > Do you mean that I add my moves something like this? > > from heapq import heappush, heappop > heap = [] > for move in genAll(): > heappush(heap, (-getMoveValue (board, table, ply, move), move)) > > And then use heappop(heap) in the alphabeta

Re: Perl and Python, a practical side-by-side example.

2007-03-02 Thread Bruno Desthuilliers
Shawn Milo a écrit : > I'm new to Python and fairly experienced in Perl, although that > experience is limited to the things I use daily. > > I wrote the same script in both Perl and Python, and the output is > identical. The run speed is similar (very fast) and the line count is > similar. > > N

Re: Perl and Python, a practical side-by-side example.

2007-03-02 Thread Bruno Desthuilliers
John Machin a écrit : > On Mar 3, 9:44 am, "Shawn Milo" <[EMAIL PROTECTED]> wrote: > (snip) > > [big snip] > Here is my rewrite in what I regard as idiomatic reasonably-modern > Python (OMMV of course). (snip) John, I *swear* I didn't read your code before posting my own version ! -- http://m

cyclic iterators ?

2007-03-02 Thread Tool69
Hi, Let say I've got a simple list like my_list = [ 'a', ',b', 'c' ]. We can have an iterator from it by k = iter( my_list), then we can access each of her (his ?) element by k.next(), etc. Now, I just wanted k to have the following cyclic behaviour (without rising the ) : >> k.next() 'a' >> k.

Re: Newbie Test

2007-03-02 Thread Tool69
On 3 mar, 01:44, Nicholas Parsons <[EMAIL PROTECTED]> wrote: > Greetings, > > This is just a test to see if I can post to this mailing list. Can > someone from the list please respond to this email so I know it worked? > > Thanks in advance! > --Nick Hi Nicholas, Does it work for you ? -- http

Re: How *extract* data from XHTML Transitional web pages? got xml.dom.minidom troubles..

2007-03-02 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > I'm trying to extract some data from an XHTML Transitional web page. > > What is best way to do this? > > xml.dom.minidom. As a side note, cElementTree is probably a better choice. Or even a simple SAX parser. >parseString("text of web page") gives errors about it

Re: cyclic iterators ?

2007-03-02 Thread Bruno Desthuilliers
Tool69 a écrit : > Hi, > > Let say I've got a simple list like my_list = [ 'a', ',b', 'c' ]. > We can have an iterator from it by k = iter( my_list), then we can > access each of her (his ?) element by k.next(), etc. > > Now, I just wanted k to have the following cyclic behaviour (without > risi

Re: cyclic iterators ?

2007-03-02 Thread Paul Rubin
"Tool69" <[EMAIL PROTECTED]> writes: > I've tried something like this to have a cyclic iterator without > sucess: > > def iterate_mylist(my_list): > k = len((my_list) > i=0 > while i <= k : > yield my_list[i] > i += 1 > i = 0 > yield my_list[0] > > I missed som

Re: Sort with extra variables

2007-03-02 Thread Thomas Dybdahl Ahle
Den Fri, 02 Mar 2007 16:27:47 -0800 skrev MonkeeSage: > On Mar 2, 5:51 pm, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote: >> I guess the thing is that I'd have to create a new callable no matter >> how, as it is the only way to bring the extra variables into the >> getValue function when called by

Re: Sort with extra variables

2007-03-02 Thread Thomas Dybdahl Ahle
Den Fri, 02 Mar 2007 16:46:05 -0800 skrev Paul Rubin: > Thomas Dybdahl Ahle <[EMAIL PROTECTED]> writes: >> Do you mean that I add my moves something like this? >> >> from heapq import heappush, heappop >> heap = [] >> for move in genAll(): >> heappush(heap, (-getMoveValue (board, table, ply,

"unknown encoding: string-escape" in frozen Python

2007-03-02 Thread Jeff Groves
I'm using FreezePython on a Python program that uses wxPython and subprocess. The result almost works, but it always hits this bug: File "velauncher.py", line 847, in Launch File "python/velLaunchCode.py", line 61, in __init__ File "python/velLaunchCode.py", line 143, in Unix File "python/

Re: Perl and Python, a practical side-by-side example.

2007-03-02 Thread Paul Rubin
Here's my version (not tested much). Main differences from yours: 1. It defines a Python class to hold row data, and defines the __cmp__ operation on the class, so given two Row objects r1,r2, you can say simply if r1 > r2: ... to see which is "better". 2. Instead of reading all the rows in

Re: Sort with extra variables

2007-03-02 Thread MonkeeSage
On Mar 2, 7:34 pm, Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote: > Well, you'd have to define the function inside the sortMoves function, as > it is where the variables exists. Oh, sorry, I wasn't thinking there! Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie Test

2007-03-02 Thread James Stroud
Nicholas Parsons wrote: > Greetings, > > This is just a test to see if I can post to this mailing list. Can > someone from the list please respond to this email so I know it worked? > > Thanks in advance! > --Nick Congratulations, you passed the newbie test! James -- http://mail.python.org/

Re: Sort with extra variables

2007-03-02 Thread Alex Martelli
Thomas Dybdahl Ahle <[EMAIL PROTECTED]> wrote: > I have a sort function in a python chess program. > Currently it looks like this: > > def sortMoves (board, table, ply, moves): > f = lambda move: getMoveValue (board, table, ply, move) > moves.sort(key=f, reverse=True) > return moves >

Re: class attrdict

2007-03-02 Thread Alex Martelli
Hallvard B Furuseth <[EMAIL PROTECTED]> wrote: > Does this class need anything more? > Is there any risk of a lookup loop? > Seems to work... > > class attrdict(dict): > """Dict where d['foo'] also can be accessed as d.foo""" > def __init__(self, *args, **kwargs): > self.__dict__

Re: Questions about app design - OOP with python classes

2007-03-02 Thread MRAB
On Mar 2, 4:47 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Thu, 01 Mar 2007 20:24:33 -0800, Paul Rubin wrote: > > Steven D'Aprano <[EMAIL PROTECTED]> writes: > >> But if you used Apps Hungarian, and saw this line of code: > > >> if hmmCurrentHeight <= hinCriticalHeight: > > >> then you shou

Re: Perl and Python, a practical side-by-side example.

2007-03-02 Thread John Machin
On Mar 3, 12:36 pm, Bruno Desthuilliers > [snip] > DATE = 5 > TARGET = 6 [snip] > Now for the bad news: I'm afraid your algorithm is broken : here are my > test data and results: > > input = [ > #ID STATE ... ... ... TARG DATE > "aaa\tAAA\t...\t...\t...\tBBB\t20071212\n", [sn

Re: class attrdict

2007-03-02 Thread MonkeeSage
On Mar 2, 9:25 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: > The problem is mostly that, given an instance a of attrdict, whether you > can call (e.g.) a.update(foo) depends on whether you ever set > a['update'], making the whole program extremely fragile -- a very high > price to pay for some mod

Re: Python Source Code Beautifier

2007-03-02 Thread greg
Alan Franzoni wrote: > I would assume then, that if the '+=' operator > is assumed to modify objects in-place, it would just fail on immutable > objects, wouldn't I? Then you wouldn't be able to do things like x = 3 x += 1 which would result in howls of outrage from the *other* half of t

implementing SFTP using Python

2007-03-02 Thread kadarla kiran kumar
Hi Everybody, I have to implement SFTP conection from client to the server using Python script. Iam very new new to python , and i dont't have much time to complete this. So I need some pointers from you. If anybody has already done this kind of stuff, please let me know. Please do

Re: class attrdict

2007-03-02 Thread Alex Martelli
MonkeeSage <[EMAIL PROTECTED]> wrote: > On Mar 2, 9:25 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: > > The problem is mostly that, given an instance a of attrdict, whether you > > can call (e.g.) a.update(foo) depends on whether you ever set > > a['update'], making the whole program extremely fra

  1   2   >