how can i read a mail using uid?

2005-02-21 Thread Raghul
I want to read the content of the mail and split it words using uid.If the word is found in my database I want to delete the mail using its uid. -- http://mail.python.org/mailman/listinfo/python-list

Problem with the sort() function

2005-02-21 Thread clementine
Hi, I have an array of arrays in the form of list = [[3,'fork',0.3,1],[2,'fork,0.1,2],[3,'exec',0.2,2]] The in-built sort(),list.sort() sorts on the first element, if the first elts are equal then it sorts on the second elt and so on...But i really dont want to search on the second elt if the fi

Re: UTF-8 / German, Scandinavian letters - is it really this difficult?? Linux & Windows XP

2005-02-21 Thread Do Re Mi chel La Si Do
Hi ! For test your system, please, read this url : http://sivanataraja.free.fr/config/test.htm (french) http://www.alanwood.net/unicode/ (english) And many explains : http://en.wikipedia.org/wiki/Unicode And, to reassure you: I had no problème for use unicode chars with Tk (my tests

Re: [Fwd: Re: [Uuu-devel] languages] <-- Why Python

2005-02-21 Thread Mike Meyer
Ville Vainio <[EMAIL PROTECTED]> writes: >> "Mike" == Mike Meyer <[EMAIL PROTECTED]> writes: > > Mike> IPython's pysh seems a little clumsy for interactive use, as > Mike> it requires special characters to distinguish between > Mike> commands to be passed to the shell and commands

Re: UTF-8 / German, Scandinavian letters - is it really this difficult?? Linux & Windows XP

2005-02-21 Thread "Martin v. Löwis"
Mike Dee wrote: If I have this in the beginning of my Python script in Linux: #!/usr/bin/env python # -*- coding: UTF-8 -*- should I - or should I not - be able to use non-ASCII characters in strings and in Tk GUI button labels and GUI window titles and in raw_input data without Python returning

Re: global var

2005-02-21 Thread Jeff Shannon
Nick Coghlan wrote: Michael Hoffman wrote: raver2046 wrote: How to have a global var in python ? "global var" will give you a global variable named "var". Whether this advice is correct or not depends greatly on what the OP means by 'global' :) Module global, it's right, application global it's w

Re: Considering python - have a few questions.

2005-02-21 Thread Simon John
I'd go with a MySQL / Python / Apache route, but if it's Windows, maybe not. Also, you shouldn't store images in a database - images should be on the filesystem with their paths stored in the database. I'd definitely say going the web application route would be easier (and more portable) than the

Copy functio in imaplib

2005-02-21 Thread Raghul
What is message_set in the python documentation for copy in imaplib? Is they referring message set to the particular mail message in my inbox or something else. copy( message_set, new_mailbox) Copy message_set messages onto end of new_mailbox. -- http://mail.python.org/mailman/listinfo/py

UID python reading mail

2005-02-21 Thread Raghul
I am totally confused of using uid .Can anyone help me in giving a sample code for reading mail nad printing their uid's. I think this would be more useful for freshers like me. Thanks in advance -- http://mail.python.org/mailman/listinfo/python-list

Re: pyrex just in time compilation

2005-02-21 Thread Simon Wittber
> Before I try this myself, has anyone else already written any code to do this? Yes, someone has. http://www.prescod.net/pyximport/ I should have googled more thoroughly before posting. :-) sw. -- http://mail.python.org/mailman/listinfo/python-list

Re: copying or moving the mail message using imaplib

2005-02-21 Thread Raghul
Thanx I got some clear view about this. In the above program I used uid method to copy thje mail to "Inbox".This shows the out put of my mail messages and In the copy of messages I got the output when printing the "dat" ('OK', [None]) ('OK', ['2 (UID 16 FLAGS (\\Seen))']) 2 I cannot see the messa

Re: copying or moving the mail message using imaplib

2005-02-21 Thread Raghul
Thanx I got some clear view about this. In the above program I used uid method to copy thje mail to "Inbox".This shows the out put of my mail messages and In the copy of messages I got the output when printing the "dat" ('OK', [None]) ('OK', ['2 (UID 16 FLAGS (\\Seen))']) 2 I cannot see the messa

Re: copying or moving the mail message using imaplib

2005-02-21 Thread Grant Edwards
On 2005-02-22, Raghul <[EMAIL PROTECTED]> wrote: > Thanks for ur message .How it is possible to copy the messages betwwen > folder ?I can't understand the copy function in python documentation. Maybe you should take a look at the RFC for IMAP4: http://www.faqs.org/rfcs/rfc2060.html The UID com

Re: NOOB coding help....

2005-02-21 Thread Steven Bethard
Igorati wrote: list = [ ] a = 1 print 'Enter numbers to add to the list. (Enter 0 to quit.)' while a != 0 : a = input('Number? ') list.append(a) zero = list.index(0) del list[zero] list.sort() A simpler approach is to use the second form of the builtin iter function which takes a callab

Re: copying or moving the mail message using imaplib

2005-02-21 Thread Raghul
Thanks for ur message .How it is possible to copy the messages betwwen folder ?I can't understand the copy function in python documentation. Please Can u give me a sample example for this. And I also to copy using uid but in vain. here is my program. #!/usr/bin/env python #Normal Library import s

which parser to use

2005-02-21 Thread a_nuther
I'm building something that requires parsing a rather complex language. I'd like to do the whole application, including the lex/parse phase, in Python (for development/debug speed), and only move parts of it to a compiled language if execution speed absolutely dictates. So, what i'm looking for in

Re: NOOB coding help....

2005-02-21 Thread James Stroud
Could you phrase this in the form of a question, like Jeopardy? On Monday 21 February 2005 08:08 pm, Igorati wrote: > Ok, this is what I have so far: > > #This program will ask for a user to imput numbers. The numbers will then > be calculated > #to find the statistical mean, mode, and median. Fi

RE: copying or moving the mail message using imaplib

2005-02-21 Thread Tony Meyer
> My problem is I want to move the mail message to other folder in > the mail using imaplib (E.g) I want to move a message from > the inbox to the Draft folder in my account using python > code. Can any one help me by giving a sample code to do this? IMAP is a terrible terrible protocol. It is

NOOB coding help....

2005-02-21 Thread Igorati
Ok, this is what I have so far: #This program will ask for a user to imput numbers. The numbers will then be calculated #to find the statistical mean, mode, and median. Finallly the user will be asked #if he would like to print out the answers. list = [ ] a = 1 print 'Enter numbers to add to the

about uid in imaplib

2005-02-21 Thread Raghul
Hi guys, How to use "uid" and copy a message to the other folders using python.Please help in explainig with sample code.I think,imaplib uid object need atleast a sample to understand clearly. -- http://mail.python.org/mailman/listinfo/python-list

copying or moving the mail message using imaplib

2005-02-21 Thread Raghul
Hi Friends, I am doing project in python.I am new to this. My problem is I want to move the mail message to other folder in the mail using imaplib (E.g) I want to move a message from the inbox to the Draft folder in my account using python code. Can any one help me by giving a sample c

pyrex just in time compilation

2005-02-21 Thread Simon Wittber
It occured to me that an import hook could be written for pyrex '.pyx' files, so that compilation can occur at runtime, if the source file has changed since the last compile. Before I try this myself, has anyone else already written any code to do this? Sw. -- http://mail.python.org/mailman/lis

PyGTA next meeting: Tuesday February 22, 7-9pm at offices of Frogware (not our usual location!)

2005-02-21 Thread Peter Hansen
We're announcing here in case anyone who doesn't subscribe to our announcement mailing list was thinking of attending: NOTE the change in location from where we've been meeting for the last 12 months!! The next meeting of PyGTA, the Toronto-area Python user group, will be held at the offices of

pyGoogle is fun and easy to use, and thinks Python is the best programming language

2005-02-21 Thread rdsteph
I am having a lot of fun using the pyGoogle module ( http://pygoogle.sourceforge.net/ ) that uses the Google API. It is about as easy to use as I can imagine, and it is a lot nicer than using my old HTMl screen scraping habits. My online CGI program Ask Merlin at www.awaretek.com/askmerlin.html i

Re: How to write a ping client

2005-02-21 Thread Grant Edwards
On 2005-02-22, Harlin <[EMAIL PROTECTED]> wrote: > Is there a way to write a ping client? [...] http://www.google.com/search?q=python+icmp+ping -- Grant Edwards grante Yow! I have the power at to HALT PRODUCTION on

How to write a ping client

2005-02-21 Thread Harlin
Is there a way to write a ping client? I would like to be able to write a small ping client so that I dont have to do os.system('ping args') and thereby keep the resource overhead low. Does anyone know how this can be done or can point me in the right direction? thanks, Harlin -- http://mail.py

Re: subclassing Decimal

2005-02-21 Thread [EMAIL PROTECTED]
STeVe, Thanks for the response. Very clear. yea-though-I-walk-thru-the-valley-of-__new__-I-will-fear-no-super-ly y'rs, -Jeff -- http://mail.python.org/mailman/listinfo/python-list

Re: MatPlotLib.MatLab troubles (how to install/run matplotlib.PyLab?)

2005-02-21 Thread John Hunter
> "Colombes" == Colombes <[EMAIL PROTECTED]> writes: Colombes> matplotlib.matlab deprecated, please import Colombes> matplotlib.pylab or simply pylab instead. See Colombes> http://matplotlib.sf.net/matplotlib_to_pylab.py for a Colombes> script which explains this change and w

Re: A few q's on python files.

2005-02-21 Thread Larry Bates
On windows there's py2exe which packs a python program so that it can be distributed "like" and .exe, but Python is a bytecode language (a la Java) so it is never actually compiled into machine language. The .pyc files are the bytecode that is actually executed. For C programmers this takes some

UTF-8 / German, Scandinavian letters - is it really this difficult?? Linux & Windows XP

2005-02-21 Thread Mike Dee
A very very basic UTF-8 question that's driving me nuts: If I have this in the beginning of my Python script in Linux: #!/usr/bin/env python # -*- coding: UTF-8 -*- should I - or should I not - be able to use non-ASCII characters in strings and in Tk GUI button labels and GUI window titles

MatPlotLib.MatLab troubles (how to install/run matplotlib.PyLab?)

2005-02-21 Thread Dr. Colombes
On my home laptop computer, I'm trying to install the appropriate modules so that Python version 2.3.3 and IDLE version 1.0.2 (with an "import matplotlib.matlab" statement) can produce nice MatLab-like plots. I have a matplotlib.matlab-capable Python set-up running OK on my office desktop, which

Re: Accessing files installed with distutils

2005-02-21 Thread John Machin
Frans Englich wrote: > This is silly. How do I access data files I've installed with distutils? In a > portable, generic way, I want to find out what is the following path on most > systems: > > /usr/local/lib/python2.4/lib/site-packages/foo/bar.txt Most systems? A tad *nix-centric, yes/no? > >

Re: recommended way of generating HTML from Python

2005-02-21 Thread John J. Lee
Matt Goodall <[EMAIL PROTECTED]> writes: [...] > Agreed. Although I would go further and say that it's important to > choose a templating system that allows the Python developer to annotate > XHTML templates using **valid XML**, i.e. no "for x in y" loops, no "if > foo" conditionals, no "i = 0" var

wxPython

2005-02-21 Thread GuyBrush Treepwood
I just compiled and installed wxWidgets and wxPython. When I want to test this libraries, I get: Python 2.4 (#1, Feb 19 2005, 19:24:31) [GCC 3.3.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from wxPython.wx import * Traceback (most recent call last): F

Mixing Txinter and Pygame

2005-02-21 Thread Tim Knauf
Hi everyone, I'm glad to have found this list. I've written a small script for my own use which, amongst other things, captures mouse click information from a window containing an image. I used Pygame to manage the image window, as it was the easiest way to implement the functionality I needed.

Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-21 Thread Ilias Lazaridis
George Sakkis wrote: "Ilias Lazaridis" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Nick Vargish wrote: You can excuse yourself from this one and stop replying to comments, but you don't get to unilaterally declare a discussion over. [...] The discussion is over. At least the in-topi

A few q's on python files.

2005-02-21 Thread Joseph Quigley
hiya, i'm new to python (by a week) but am learning fast (that's what I like about python--it's simplicity). I got disgusted with C and C++ (i was learning) probably because of a bad copy of Visual C++ 6.0 that gave me errors. I noticed that IDLE doesn't have an option to allow you to convert a

Re: Tuple index

2005-02-21 Thread John Machin
Steve M wrote: > John Machin wrote: > > > > > Steve M wrote: > >> I'm actually doing this as part of an exercise from a book. What the > > program > >> is supposed to do is be a word guessing game. The program automaticly > >> randomly selects a word from a tuple. > > > > Care to tell us which boo

Re: IDLE Problem: win98\Python2.4

2005-02-21 Thread "Martin v. Löwis"
kim kubik wrote: A little knowledge is indeed a dangerous thing; forgive my stupidity - it will happen again, so I'm apologizing in advance! No need to apologize! This is a frequent mistake, and it might be sensible to change Python to be more resistent against it. For example, it might be possible

Re: unicode encoding usablilty problem

2005-02-21 Thread "Martin v. Löwis"
aurora wrote: What is the processing of getting a PEP work out? Does the work and discussion carry out in the python-dev mailing list? I would be glad to help out especially on this particular issue. See PEP 1 for the PEP process. The main point is that discussion is *not* carried out on any sp

Accessing files installed with distutils

2005-02-21 Thread Frans Englich
This is silly. How do I access data files I've installed with distutils? In a portable, generic way, I want to find out what is the following path on most systems: /usr/local/lib/python2.4/lib/site-packages/foo/bar.txt How do I figure out the rest, if I know foo/bar.txt? sys.prefix doesn't get

Re: intersection of 2 list of pairs

2005-02-21 Thread John Machin
Pierre Quentel wrote: > Another method is to build two sets of sets, one for E1 and one for E2, > then make the intersection of these sets > > - with Python 2.3 > > >>> E1=[('a','g'),('r','s')] > >>> E2=[('g','a'),('r','q'),('f','h')] > >>> from sets import Set,ImmutableSet > >>> f=Set([Immuta

Re: Tuple index

2005-02-21 Thread Steve M
Steven Bethard wrote: > Steve M wrote: >> I'm actually doing this as part of an exercise from a book. What the >> program is supposed to do is be a word guessing game. The program >> automaticly randomly selects a word from a tuple. You then have the >> oportunity to ask for a hint. I created anot

Re: Tuple index

2005-02-21 Thread Steve M
John Machin wrote: > > Steve M wrote: >> I'm actually doing this as part of an exercise from a book. What the > program >> is supposed to do is be a word guessing game. The program automaticly >> randomly selects a word from a tuple. > > Care to tell us which book is using a tuple for this, but

Re: high resolution time needed

2005-02-21 Thread Diez B. Roggisch
> I need a function returning a time value with a higher resolution that the > standard 1sec unix timestamp. I found the clock() function in the time > module, but that seems to return the same value (in the Python shell) each > time I call it (Debian Linux speaking here). Standard unix is a milli

high resolution time needed

2005-02-21 Thread Uwe Mayer
Hi, I need a function returning a time value with a higher resolution that the standard 1sec unix timestamp. I found the clock() function in the time module, but that seems to return the same value (in the Python shell) each time I call it (Debian Linux speaking here). Any ideas? Thanks, Uwe -

Re: Tuple index

2005-02-21 Thread Steven Bethard
Steve M wrote: I'm actually doing this as part of an exercise from a book. What the program is supposed to do is be a word guessing game. The program automaticly randomly selects a word from a tuple. You then have the oportunity to ask for a hint. I created another tuple of hints, where the order o

Re: Tuple index

2005-02-21 Thread John Machin
Steve M wrote: > I'm actually doing this as part of an exercise from a book. What the program > is supposed to do is be a word guessing game. The program automaticly > randomly selects a word from a tuple. Care to tell us which book is using a tuple for this, but hasn't got to lists yet? Cheers,

Re: subclassing Decimal

2005-02-21 Thread Steven Bethard
[EMAIL PROTECTED] wrote: I was interested in playing around with Decimal and subclassing it. For example, if I wanted a special class to permit floats to be automatically converted to strings. from decimal import Decimal class MyDecimal(Decimal): def __init__(self, value):

Re: python2.4 generator expression > python2.3 list expression

2005-02-21 Thread Terry Reedy
"Christos TZOTZIOY Georgiou" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On 21 Feb 2005 06:48:19 -0500, rumours say that Dan Sommers > <[EMAIL PROTECTED]> >>for c in range( 128 ): >>even_odd = 0 >>print '%3d' % c, >>while c: >>c &= c - 1 >>even_odd =

Re: Tuple index

2005-02-21 Thread Steve M
Michael Hartl wrote: > I actually find it strange that tuples don't have an index function, > since finding the index doesn't involve any mutation. Anyone know why > Python doesn't allow a statement like t.index('foo')? > > In any case, you can use the index method of list objects if you > conve

Re: Tuple index

2005-02-21 Thread Steve M
Steven Bethard wrote: > Steve M wrote: >> I guess I explained my problem incorrectly. Let me try again. >> >> tuple = ("fred", "barney", "foo") >> >> I know that foo is an element of tuple, but what I need to know is what >> the index of foo is, tuple[?]. > > Larry Bates's solution is probably

subclassing Decimal

2005-02-21 Thread [EMAIL PROTECTED]
I was interested in playing around with Decimal and subclassing it. For example, if I wanted a special class to permit floats to be automatically converted to strings. from decimal import Decimal class MyDecimal(Decimal): def __init__(self, value): if isinstance(value

Re: Tuple index

2005-02-21 Thread Steven Bethard
Michael Hartl wrote: I actually find it strange that tuples don't have an index function, since finding the index doesn't involve any mutation. Anyone know why Python doesn't allow a statement like t.index('foo')? Tuples aren't really intended for this kind of use. See: http://www.python.org/doc/

Re: Tuple index

2005-02-21 Thread Steven Bethard
Steve M wrote: I guess I explained my problem incorrectly. Let me try again. tuple = ("fred", "barney", "foo") I know that foo is an element of tuple, but what I need to know is what the index of foo is, tuple[?]. Larry Bates's solution is probably the best way to go here: py> t = ("fred", "barney"

Re: Tuple index

2005-02-21 Thread Michael Hartl
I actually find it strange that tuples don't have an index function, since finding the index doesn't involve any mutation. Anyone know why Python doesn't allow a statement like t.index('foo')? In any case, you can use the index method of list objects if you convert your tuple to a list first: >>

Re: iterative lambda construction

2005-02-21 Thread Jack Diederich
On Mon, Feb 21, 2005 at 01:14:00PM -0800, Paul Rubin wrote: > "markscottwright" <[EMAIL PROTECTED]> writes: > > But when I try to do it iteratively, it just hangs when I try to > > evaluate the results (for count > 1): > > > > def repeated2(f, count): > > newfun = f > > for i in range(coun

Re: iterative lambda construction

2005-02-21 Thread Steven Bethard
markscottwright wrote: Just for the hell of it, I've been going through the old Scheme-based textbook "Structure and Interpretation of Computer Programs" and seeing what I can and can't do with python. I'm trying to create a function that returns the function (not the results of the function, but

Re: Don't understand global variables between modules

2005-02-21 Thread Terry Reedy
"Bart" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I don't understand globals between multiple modules in a python program. Because there are not any. All names are bound to objects in a module global namespace, a function local namespace, or an object attribute namespace.

Re: iterative lambda construction

2005-02-21 Thread Andrew Koenig
"markscottwright" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Just for the hell of it, I've been going through the old Scheme-based > textbook "Structure and Interpretation of Computer Programs" and seeing > what I can and can't do with python. I'm trying to create a function >

Re: iterative lambda construction

2005-02-21 Thread Paul Rubin
"markscottwright" <[EMAIL PROTECTED]> writes: > But when I try to do it iteratively, it just hangs when I try to > evaluate the results (for count > 1): > > def repeated2(f, count): > newfun = f > for i in range(count-1): > newfun = lambda x: newfun(f(x)) > return newfun > > F

Re: Tuple index

2005-02-21 Thread Steve M
John Machin wrote: > > Steve M wrote: >> Hello, >> >> I'm trying to figure out the index position of a tuple > member. >> I know the member name, but I need to know the members index > position. > > Tuples, like lists, don't have members in the sense that they can be > "named" like t.foo

Re: Bug in email package?

2005-02-21 Thread Roman Suzi
On Sun, 20 Feb 2005, Steven Bethard wrote: Erik Max Francis wrote: Roman Suzi wrote: I think that if any object (from standard library at least) doesn't support iteration, it should clearly state so. My guess is that 'for' causes the use of 'm[0]', which is (rightfully) an error... Can this behav

iterative lambda construction

2005-02-21 Thread markscottwright
Just for the hell of it, I've been going through the old Scheme-based textbook "Structure and Interpretation of Computer Programs" and seeing what I can and can't do with python. I'm trying to create a function that returns the function (not the results of the function, but a function object) that

Re: Test for structure

2005-02-21 Thread Terry Reedy
"Steven Bethard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I don't like this idea much because it depends on str and unicode _not_ > having a particular function. I haven't seen any guarantee anywhere that > str or unicode won't ever grow an __iter__ method. So this code s

Re: PyQt Python Bindings for Qt v3.14 Released

2005-02-21 Thread Jarek Zgoda
Phil Thompson napisał(a): Riverbank Computing is pleased to announce the release of PyQt v3.14 available from http://www.riverbankcomputing.co.uk/. Classes generated by puyic 3.13 are not compatible with PyQt 3.14 (some method signature incompatibilities). I cann't provide more details, as I reg

Re: - E02 - Support for MinGW Open Source Compiler

2005-02-21 Thread Nick Vargish
Grant Edwards <[EMAIL PROTECTED]> writes: > I've never understood the problem with long URLs. Many > newsreaders let you click on them. If not, you just cut/paste > it into a browser (with a shellscript a couple lines long, you > can start firefox with the URL on the X clipboard with a single >

display VARCHAR(mysql) and special chars in html

2005-02-21 Thread Jonas Meurer
hello, my script selects a comment saved as VARCHAR in MySQL and displays it inside an html page. the problem is, that the comment contains several special characters, as mysterious utf-8 hyphens, german umlauts, etc. i could write a function to parse the comment and substitute special chars wit

Re: Test for structure

2005-02-21 Thread Steven Bethard
Martin Miller broke the order of reading again by top-posting: However, to handle the more general problem of allow *any* argument to be either a single item or a list seems to require a combination of both EAPF and LBYL. This is the best solution I've been able to come up with so far: def asList(a

Re: Real-Time Fluid Dynamics for Games...

2005-02-21 Thread Alberto Santini
You can find some screenshot in the Stam's original paper. I didn't do any serious benchmark. I compared the speed of C version with the Python one. It seems enough good. I advice you to download from Stam's site paper and C code, compile the C code and verify yourself the results. I think the so

Re: multimethod (or rather overloading) in Python

2005-02-21 Thread anton muhin
Nick Coghlan wrote: anton muhin wrote: anton muhin wrote: Correction: Of course, I can imagine some metaclasses magic that would allow to code: class MyClass(WithOverloading): @overloadMethod(A) def someMetod(self, _): ... But it would rather convoluted: the best idea I have so far is to man

Re: unicode encoding usablilty problem

2005-02-21 Thread Dieter Maurer
"Fredrik Lundh" <[EMAIL PROTECTED]> writes on Sat, 19 Feb 2005 18:44:27 +0100: > "aurora" <[EMAIL PROTECTED]> wrote: > > > I don't want to mix them. But how could I find them? How do I know this > > statement can be > > potential problem > > > > if a==b: > > > > where a and b can be instantia

Re: Test for structure

2005-02-21 Thread Martin Miller
Testing for the '__iter__' (or even '__getitem__') attribute doesn't really address the problem, nor does trying to execute the statement 'itr = iter(a)'. To use EAPF and answer the OP's original question, which was > So how can I test if a variable 'a' is either a single character > string or a

Re: python2.4 generator expression > python2.3 list expression

2005-02-21 Thread Bryan
Duncan Booth wrote: Bryan wrote: is to reset the rightmost (less significant) '1' bit of a number (ie change it to '0'). i tried c &= c - 1 but i'm not getting the least significant or rightmost bit reset to zero. am i misunderstanding something? 2 & 1 # 2 = 0x10; reset right most would be 0x10

[OT] Re: lambda closure question

2005-02-21 Thread Steven Bethard
Antoon Pardon wrote: def F(): ... l = [] ... def pop(): ... return l.pop() ... def push(e): ... l.append(e) ... return pop, push ... Just a side note to point out that another way of writing this is: py> def F(): ... l = [] ... return l.pop, l.append ... You'll get the same

Re: combining several lambda equations

2005-02-21 Thread Steven Bethard
Antoon Pardon wrote: So and if I have code like this: f = lamda x:x for g in some_iter: f = compose(g,f) Do you still think that one should use a named function in this case? Yes. If you really don't like taking two lines, Python still allows you to write this as: def f(x): return x

Re: Test for structure

2005-02-21 Thread Steven Bethard
> Steven Bethard wrote: >> >>Right. str and unicode objects support iteration through the old >>__getitem__ protocol, not the __iter__ protocol. If you want to use >>something as an iterable, just use it and catch the exception: >> >>try: >> itr = iter(a) >>except TypeError: >> # 'a' is n

ANNOUNCE: SiGeFi v0.3

2005-02-21 Thread Batista, Facundo
Title: ANNOUNCE: SiGeFi v0.3 We're proud to announce the 0.3 version of SiGeFi, which you can find at:     http://sourceforge.net/projects/sigefi     What is SiGeFi? --- SiGeFi is a Financial Management System, with focus in the needs of the administration of the mo

Re: recommended way of generating HTML from Python

2005-02-21 Thread has
Kent Johnson wrote: > Michele Simionato wrote: > > The problem is a problem of standardization, indeed. There plenty of > > recipes to > > do the same job, I just would like to use a blessed one (I am teaching > > a Python > > course and I do not know what to recommend to my students). > > Why not

RE: recommended way of generating HTML from Python

2005-02-21 Thread Robert Brewer
Michele Simionato wrote: > The problem is a problem of standardization, indeed. > There are plenty of recipes to do the same job, I just > would like to use a blessed one (I am teaching a Python > course and I do not know what to recommend to my students). Wouldn't we *all* like all of our problem

Re: Unittest - testing properties (read-only attributes)

2005-02-21 Thread Roy Smith
Paul Rubin wrote: > The example I quoted used an assignment expression inside a > lambda. The person who posted it, That was me. > and the person who followed it up > with the setattr alternative, both didn't notice that the assignment > expression wasn't valid Python

Re: IDLE Problem: win98\Python2.4

2005-02-21 Thread kim kubik
> kim kubik wrote: > > I installed Python2.4 in Win98 > > and IDLE doesn't work > Are you also running Ruby? The Ruby bundle for MS Windows has caused > problems with it's TCL package conflicting with Python's. > thanks, one of the first things I noted in the error msg (not included for brevity

Re: Unittest - testing properties (read-only attributes)

2005-02-21 Thread Paul Rubin
Duncan Booth <[EMAIL PROTECTED]> writes: > An assignment expression, if such a thing existed wouldn't help here. > > The point being that the expression must be evaluated inside the exception > handler in assertRaises, so you either need to delay the evaluation with a > lambda, or by passing the

Re: python2.4 generator expression > python2.3 list expression

2005-02-21 Thread Brian Beck
Duncan Booth wrote: The difference between the original "reset the rightmost '1' bit", and your interpretation: "reset the rightmost bit" is the "'1'". The rightmost bit that is set is reset. So 0x10 -> 0, and 0x1010 -> 0x1000. If you want to extract the least significant set bit from a number 'x

Re: Unittest - testing properties (read-only attributes)

2005-02-21 Thread Duncan Booth
Duncan Booth wrote: > An assignment expression, if such a thing existed wouldn't help here. Although of course it would help if still inside a lambda. -- http://mail.python.org/mailman/listinfo/python-list

Re: Unittest - testing properties (read-only attributes)

2005-02-21 Thread Duncan Booth
Paul Rubin wrote: > Peter Hansen <[EMAIL PROTECTED]> writes: >> > You want something like >> > self.assertRaises(AttributeError, lambda: self.combat.value = 1) >> >> Or, combining the two responses and avoiding the lambda: >> >> self.assertRaises(AttributeError, setattr, self.combat, 'value',

Re: exercise: partition a list by equivalence

2005-02-21 Thread Reinhold Birkenfeld
John Machin wrote: > Reinhold Birkenfeld wrote: >> Reinhold Birkenfeld wrote: >> >> > My solution (which may not be the fastest or most effective, but > till >> > now is the shortest and it works): > > [snip RB] >> >> A recursive solution (around twice as fast as the above, though very >> slow st

Re: Unittest - testing properties (read-only attributes)

2005-02-21 Thread Paul Moore
Peter Hansen <[EMAIL PROTECTED]> writes: > Roy Smith wrote: >> You want something like >> self.assertRaises(AttributeError, lambda: self.combat.value = 1) > > Or, combining the two responses and avoiding the lambda: > > self.assertRaises(AttributeError, setattr, self.combat, 'value', 1) > > Hmm..

Re: recommended way of generating HTML from Python

2005-02-21 Thread Michele Simionato
Kent Johnson: >I've written web pages this way (using a pretty nice Java HTML generation package) >and I don't >recommend it. In my experience, this approach has several drawbacks: >- as soon as the web page gets at all complex, the conceptual shift from HTML to >code and back is >difficult. >- It

Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-21 Thread George Sakkis
"Ilias Lazaridis" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Nick Vargish wrote: > > You can excuse yourself from this one and stop replying to comments, > > but you don't get to unilaterally declare a discussion over. > [...] > > The discussion is over. > > At least the in-topi

Re: python2.4 generator expression > python2.3 list expression

2005-02-21 Thread Duncan Booth
Bryan wrote: >> is to reset the rightmost (less significant) '1' bit of a number (ie >> change it to '0'). > > i tried c &= c - 1 but i'm not getting the least significant or > rightmost bit reset to zero. am i misunderstanding something? > > >>> 2 & 1 # 2 = 0x10; reset right most would be 0x1

Re: Unittest - testing properties (read-only attributes)

2005-02-21 Thread Paul Rubin
Peter Hansen <[EMAIL PROTECTED]> writes: > > You want something like > > self.assertRaises(AttributeError, lambda: self.combat.value = 1) > > Or, combining the two responses and avoiding the lambda: > > self.assertRaises(AttributeError, setattr, self.combat, 'value', 1) > > Hmm... this might b

Re: Unittest - testing properties (read-only attributes)

2005-02-21 Thread Peter Hansen
Roy Smith wrote: You want something like self.assertRaises(AttributeError, lambda: self.combat.value = 1) Or, combining the two responses and avoiding the lambda: self.assertRaises(AttributeError, setattr, self.combat, 'value', 1) Hmm... this might be a case where the lambda form is actually the m

Re: detecting the change in desktop resolution - how?

2005-02-21 Thread Do Re Mi chel La Si Do
Hi ! On windows, and PyWin, this script give the H/V current resolution : import win32com.client oWMI = win32com.client.Dispatch("WbemScripting.SWbemLocator") owbem = oWMI.ConnectServer(".","root\cimv2") collec = owbem.ExecQuery("Select * from Win32_PrinterConfiguration") pr

Re: Unittest - testing properties (read-only attributes)

2005-02-21 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Paul Moore <[EMAIL PROTECTED]> wrote: > I have a class with a read-only attribute, and I want to add a unit > test to ensure that it really *is* read-only. I can do this as > > def test_readonly(self): > """Value and multiplier must be readonly""" >

Re: Unittest - testing properties (read-only attributes)

2005-02-21 Thread Diez B. Roggisch
Paul Moore wrote: > I have a class with a read-only attribute, and I want to add a unit > test to ensure that it really *is* read-only. I can do this as > > def test_readonly(self): > """Value and multiplier must be readonly""" > try: > self.combat.value = 1 > self.fail("Value is not read onl

Unittest - testing properties (read-only attributes)

2005-02-21 Thread Paul Moore
I have a class with a read-only attribute, and I want to add a unit test to ensure that it really *is* read-only. I can do this as def test_readonly(self): """Value and multiplier must be readonly""" try: self.combat.value = 1 self.fail("Value is not rea

Re: IDLE Problem: win98\Python2.4

2005-02-21 Thread rmb25612
kim kubik wrote: > This sure seems like it would have been > brought up but I checked Google Groups > (the dejanews replacement) and saw > nothing: I installed Python2.4 in Win98 > and IDLE doesn't work (neither does the > online manual even tho a 3.6KB Python24.chm > is there, but that's a story

Re: python2.4 generator expression > python2.3 list expression

2005-02-21 Thread Bryan
Christos TZOTZIOY Georgiou wrote: On 21 Feb 2005 06:48:19 -0500, rumours say that Dan Sommers <[EMAIL PROTECTED]> might have written: [snip: snacktime posts code to count bits] Seems to work, is there a better way to do this? [Dan] for c in range( 128 ): even_odd = 0 print '%3d' % c, while

detecting the change in desktop resolution - how?

2005-02-21 Thread Erik Bethke
Hello All, I am trying to clean up some polish bugs with the Shanghai game I am working on and I am currently stuck on trying to get the right event for detecting when the user has changed the desktop resolution. I have tried trapping the following events: 1) SDL_ACTIVEEVENT 2) SDL_VIDEOEXPOSE

  1   2   >