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

2005-02-21 Thread Peter Otten
snacktime wrote: > I need to convert a generator expression to a list expression so it > will work under python 2.3. > > I rewrote this: > > for c in range(128): > even_odd = (sum(bool(c & 1< > As this: > > for c in range(128): > bo = [bool(c & 1< even_odd = sum(bo) & 1 > > > Seems to

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

2005-02-21 Thread Ville Vainio
> "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 to be passed Mike> to the scripting language.

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

2005-02-21 Thread Ville Vainio
> "Mike" == Mike Meyer <[EMAIL PROTECTED]> writes: Mike> I've actually done some work on using CORBA as a COM for Mike> Unix (or, as I think of it, an ARexx for Unix). After being Mike> exposed to Plan 9, I've decided that's a better Mike> solution. CORBA has the advantage that

Re: Test for structure

2005-02-21 Thread Martin Miller
Yes, both string and lists have a __getitem__ attribute: >>> c1 = 'abc' >>> c2 = ['de', 'fgh', 'ijkl'] >>> hasattr(c1, '__getitem__') True >>> hasattr(c2, '__getitem__') True In other words you could index elements of either one using []. Likewise, both a string and list would produce a usable i

Re: Moving to Python from PHP - 3 questions

2005-02-21 Thread Fredrik Lundh
Joe Francia wrote: > You'll also want to probably look at some of the templating kits, of which > Cheetah and/or > ElementTree work best for me. (Well, ElementTree isn't exactly a templating > kit - it's a > general-purpose XML tookit - but it is easily used for templating.) if you want elem

[PyGTK] forbid focus of TreeView columns

2005-02-21 Thread Franck Pommereau
Hi all, I'm building a PyGTK interface in which I would like that no widget would be able to get the focus (and so to be activated by pressing the Return key). For this purpose, for each widget, I do: widget.set_property("can-focus", gtk.FALSE) My problem is a TreeView which has a clickable

[PyGTK] Resizing a HandleBox

2005-02-21 Thread Franck Pommereau
Hi all, I'm using PyGTK-2.0.0, when I detach a HandleBox, the resizing of the newly created window is broken: it can be resized but it's content (the HandleBox and its child) is not affected at all and is not resized. Does any one have a solytion to this problem? Thanks in advance! Franck -- htt

Re: [PyGTK] Resizing a HandleBox

2005-02-21 Thread Robert Kern
Franck Pommereau wrote: Hi all, I'm using PyGTK-2.0.0, when I detach a HandleBox, the resizing of the newly created window is broken: it can be resized but it's content (the HandleBox and its child) is not affected at all and is not resized. Does any one have a solytion to this problem? I'm afra

Re: Moving to Python from PHP - 3 questions

2005-02-21 Thread bruno modulix
Michal Migurski wrote: The python-based zope application server has session management. Togther with a built-in user and access rights management. ... This can be done in zope if you name a variable :list. That then will give you the variable as list regardless of the number of occurences. Thank

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

2005-02-21 Thread bruno modulix
Ilias Lazaridis wrote: Bruno Desthuilliers wrote: [...] closing thread http://groups-beta.google.com/group/comp.lang.python/msg/f2ae9cdbe16676d1 Nope. You are not entitled to close thread. This is irrelevant. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]

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

2005-02-21 Thread bruno modulix
Ilias Lazaridis wrote: Should a professional developer take python serious? A *professionnal developper*, yes. But this is irrelevant to you. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python

IDLE output too slow for practical use after upgrade from P2.2.2 to P2.4

2005-02-21 Thread Anthra Norell
Hi,    I upgraded from 2.2.2 to 2.4 and all is well except the output to the IDLE window is now twenty times slower than it was before, making the window utterly unusable for verbose output. The statement -- for i in range (100): print i -- now takes about forty-five seconds to complete! Used

Don't understand global variables between modules

2005-02-21 Thread Bart
Hi all I don't understand globals between multiple modules in a python program. I really don't. I've narrowed it down to the following two very simple programs a.py and b.py. When I run a.py I get the following output: inc: 2 A: 2 inc: 3 B: 3 C: 1 I don't understand the last line at all. Why

Re: Moving to Python from PHP - 3 questions

2005-02-21 Thread grahamd
Michal Migurski wrote: > 3) Structured request variables. PHP has a really handy feature where > request variables with name like "foo[]", "foo[bar]", or > "foo[bar][baz]" are automatically structured into nested associative > arrays. I can see that the python cgi module will make a list of > Min

MDaemon Warning - virus found: Returned mail: see transcript for details

2005-02-21 Thread Post Office
*** WARNING ** Este mensaje ha sido analizado por MDaemon AntiVirus y ha encontrado un fichero anexo(s) infectado(s). Por favor revise el reporte de abajo. AttachmentVirus name Action taken ---

Re: Don't understand global variables between modules

2005-02-21 Thread Fredrik Lundh
Bart wrote: > I don't understand globals between multiple modules in a python program. I > really don't. I've narrowed it down to the following two very simple > programs a.py and b.py. When I run a.py I get the following output: > > inc: 2 > A: 2 > inc: 3 > B: 3 > C: 1 > > I don't understand

Re: Moving to Python from PHP - 3 questions

2005-02-21 Thread grahamd
> If you do manage to get mod_python working, I suggest taking a look at > Vampire as well: http://www.dscpl.com.au/projects/vampire/ > I have had good experience with it. Once you start using mod_python > you'll realize you can really go anywhere you want; and that's not > necessarily a good thing

Re: unicode encoding usablilty problem

2005-02-21 Thread Fredrik Lundh
"aurora" <[EMAIL PROTECTED]> wrote: >> if you don't know what a and b comes from, how can you be sure that >> your program works at all? how can you be sure they're both strings? > > a and b are both string. how do you know that? >> if you have unit tests, why don't they include Unicode tests?

Re: lambda closure question

2005-02-21 Thread Carl Banks
Mike Meyer wrote: > "Carl Banks" <[EMAIL PROTECTED]> writes: > > > Say you have a suite of functions, all of which are called by some main > > function and each other, and all of which need to access a lot of the > > same data. The best, most straightforward way to do it is to have the > > common

Keyword Named Args

2005-02-21 Thread Fuzzyman
A colleague and I have built a Validator object for use with ConfigObj and other general schema situations. A config file is used to store a schema that specifies how to test a value that it is valid. keyword=function(param1, param2) e.g. you could specify : size = range(30, 50) This means that

Re: lambda closure question

2005-02-21 Thread Carl Banks
jfj wrote: > The costly extra feature is this: > ### > def foo(): > def f(): > print x > x=1 > f() > x=2 > f() > return f > foo()() > # > which prints '1 2 2' > > The fractal code runs a little _slower_ because of this ability. > Alth

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

2005-02-21 Thread Dan Sommers
On Sun, 20 Feb 2005 20:56:52 -0800, snacktime <[EMAIL PROTECTED]> wrote: > I need to convert a generator expression to a list expression so it > will work under python 2.3. > I rewrote this: > for c in range(128): > even_odd = (sum(bool(c & 1< As this: > for c in range(128): > bo = [bool(c

Re: combining several lambda equations

2005-02-21 Thread Antoon Pardon
Op 2005-02-18, Steven Bethard schreef <[EMAIL PROTECTED]>: > Paddy McCarthy wrote: >> x=lambda : A < B >> y=lambda : C+6 >= 7 >> > [snip] >> >> Z=lambda : (A=7) > > See "Inappropriate use of Lambda" in > http://www.python.org/moin/DubiousPython > > Perhaps your real example is different, but notice

Re: Keyword Named Args

2005-02-21 Thread Diez B. Roggisch
> What I can't easily see is any way of passing named keyword arguments > to the function. Suppose we wanted to pass keyword=param to a function > - is there any way of doing this ... obviously passing in > 'keyword=param' as text has entirely the wrong result.. Im not sure if I understand you

functions and named keyword arguments

2005-02-21 Thread Fuzzyman
Sorry if this is a duplicate - I use the google interface and sometiems it screws up (not showing stuff you've posted *or* not posting it). Before you ask it's because at work I have no NNTP and *heavily* restricted http. A colleague and I have built a Validator object for use with ConfigObj and o

Re: gui scripting

2005-02-21 Thread Simon Brunning
On 17 Feb 2005 04:48:19 -0800, Tonino <[EMAIL PROTECTED]> wrote: > thanks - am already involved in a process to modify winguiauto.py - > this is a GREAT start but we need more control and better handleing ;) Can you be more specific? > Thanks for the WATSUP site - will check on this as well ;)

Re: lambda closure question

2005-02-21 Thread Antoon Pardon
Op 2005-02-19, jfj schreef <[EMAIL PROTECTED]>: > Carl Banks wrote: >> Ted Lilley wrote: >> >> >>>Unfortunately, it doesn't work. It seems the closure keeps track of >>>the variable fed to it dynamically - if the variable changes after >> [...] >>> >>>At least, that's the explanation I'm deduci

Re: functions and named keyword arguments

2005-02-21 Thread Diez B. Roggisch
> Sorry if this is a duplicate - I use the google interface and sometiems > it screws up (not showing stuff you've posted *or* not posting it). > Before you ask it's because at work I have no NNTP and *heavily* > restricted http. It is - so I requote my answer :) Im not sure if I understand you

Re: How Do I get Know What Attributes/Functions In A Class?

2005-02-21 Thread Kent Johnson
Hans Nowak wrote: [EMAIL PROTECTED] wrote: Hi, I'm new to python. Given a class, how can I get know what attributes/functins in it without dig into the source? Use the dir function: >>> from smtplib import SMTP >>> dir(SMTP) ['__doc__', '__init__', '__module__', 'close', 'connect', 'data', 'de

Re: intersection of 2 list of pairs

2005-02-21 Thread Pierre Quentel
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([ImmutableSet(s) for s in E1])& Set([ImmutableSet(

Re: lambda closure question

2005-02-21 Thread jfj
Antoon Pardon wrote: Op 2005-02-19, jfj schreef <[EMAIL PROTECTED]>: once foo() returns there is no way to modify 'x'! It becomes a kind of constant. In this particular case yes. But not in general, what about this: def F(): ... l = [] ... def pop(): ... return l.pop() ... def push(e):

Re: recommended way of generating HTML from Python

2005-02-21 Thread Kent Johnson
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 teach your students to use a template system?

Re: lambda closure question

2005-02-21 Thread Antoon Pardon
Op 2005-02-21, jfj schreef <[EMAIL PROTECTED]>: > Antoon Pardon wrote: >> Op 2005-02-19, jfj schreef <[EMAIL PROTECTED]>: >> >>>once foo() returns there is no way to modify 'x'! >>>It becomes a kind of constant. >> >> >> In this particular case yes. But not in general, what about >> this: >> >>

Re: - E02 - Support for MinGW Open Source Compiler

2005-02-21 Thread JanC
Nick Vargish schreef: > Please consider a visit to > tinyurl.com before posting a monster like that... :^) As long as he also posts the full URL... -- JanC "Be strict when sending and tolerant when receiving." RFC 1958 - Architectural Principles of the Internet - section 3.9 -- http://mail.py

Re: lambda closure question

2005-02-21 Thread Diez B. Roggisch
> But I'll get back at what seems you actually wanted to say: > That there is no way to rebind 'x' or in my case 'l' and > with that I have to agree although I personnaly find that > a lack in python It's not only that way in python, but in java too. So it seems that there is a fundamental princip

Re: lambda closure question

2005-02-21 Thread Duncan Booth
Antoon Pardon wrote: > But I'll get back at what seems you actually wanted to say: > That there is no way to rebind 'x' or in my case 'l' and > with that I have to agree although I personnaly find that > a lack in python 'no way' is a bit strong. You can use hacks such as the one I posted a coup

Tiled Image viewer

2005-02-21 Thread Ian McConnell
Does anyone know of a widget or sample code for viewing huge (ie bigger than RAM) images in python? The usual way of doing this is to read part of the image into memory as a set of tiles and then zoom and pan the tiles. The sort of thing I'm trying to achive is at http://iipimage.sourceforge.

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

2005-02-21 Thread TZOTZIOY
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 c: >c &= c -

Re: segfault when calling Python from C thread

2005-02-21 Thread Greg Chapman
Fredrik Lundh wrote: > Greg Chapman wrote: > > > Your callback function needs to hold the Python GIL (and have a > > vaild threadstate) before it calls any Python C-API functions. > > Change the last part of it to: > > > >PyGILState_STATE state; > > > >/* ... */ > > > >/* Time to c

Yet Another BLT/TkInter Install Question

2005-02-21 Thread Noelle QUEMENER
I have just installed BLT: I effectively had some problems - the same you had. I found this: Python GUI Setup Here is the procedure I used to get "Fourier" working on Windows and Linux. I wanted to use BLT for xy-plotting, partly because we used it with tcl in the sss project, and partly becaus

Re: lambda closure question

2005-02-21 Thread Antoon Pardon
Op 2005-02-21, Diez B. Roggisch schreef <[EMAIL PROTECTED]>: >> But I'll get back at what seems you actually wanted to say: >> That there is no way to rebind 'x' or in my case 'l' and >> with that I have to agree although I personnaly find that >> a lack in python > > It's not only that way in pyth

Detecting the change of screen resolution with SDL or PyGame

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 3

Re: lambda closure question

2005-02-21 Thread Paul Rubin
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes: > It's not only that way in python, but in java too. So it seems that there is > a fundamental principle behind it: In a language that allows sideeffects, > these will actually happen. Can you even have nested functions in Java? Algol-60 did things t

Re: recommended way of generating HTML from Python

2005-02-21 Thread Matt Goodall
On Mon, 2005-02-21 at 07:36 -0500, 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 reco

Re: Platform independent adduser script?

2005-02-21 Thread Gustavo Rahal
Hi On redhat you can use a libuser module that provides some highlevel system tasks. redhat-tools use this module all the time.. look at some sources Gustavo morphex wrote: Hi there, does anyone here know of a script that enables adding of users on UNIX platforms via python? Thanks, Morten -- htt

Re: lambda closure question

2005-02-21 Thread Diez B. Roggisch
Paul Rubin wrote: > "Diez B. Roggisch" <[EMAIL PROTECTED]> writes: >> It's not only that way in python, but in java too. So it seems that there >> is a fundamental principle behind it: In a language that allows >> sideeffects, these will actually happen. > > Can you even have nested functions in

Re: lambda closure question

2005-02-21 Thread Diez B. Roggisch
> I have the impression that you misunderstood me. I'm not after a > side-effect free language. I just think python could be nicer in > allowing some side-effects. Yeah, seems as if I somehow added an inadvertent "not" somewhere in my train of thoughts while reading (and hopfully comprehending...)

Re: Article on Hi-Fi Myths

2005-02-21 Thread Grant Edwards
On 2005-02-21, Mike Meyer <[EMAIL PROTECTED]> wrote: >> "you just need to know what techniques to use to create a >> 'friendly', 'relaxing', energy pattern." > > I find that playing back Python code over multi-stranded copper > produces the best results. Only if you color the edges with

Re: - E02 - Support for MinGW Open Source Compiler

2005-02-21 Thread Grant Edwards
On 2005-02-20, Nick Vargish <[EMAIL PROTECTED]> wrote: > "BrainDead" <[EMAIL PROTECTED]> writes: > >> I believe that you are wasting your time. Looking at your email >> address, this may well be relevant. > [ 4-line URL snipped ] > > Thanks for the historical reference. Please consider a visit t

Re: [ANN] Python 2.4 Quick Reference available

2005-02-21 Thread TZOTZIOY
On Sun, 20 Feb 2005 14:57:14 +, rumours say that Michael Hoffman <[EMAIL PROTECTED]> might have written: [snip: use 'open' in preference to 'file'] >To be honest I doubt open will be extended in this manner. I can see >the Pythoneers adding, say, a keyword argument to open to allow a URL >ins

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

2005-02-21 Thread Ilias Lazaridis
Nick Vargish wrote: Ilias Lazaridis <[EMAIL PROTECTED]> writes: Now it's really time to close this thread. I suspect this will fall of deaf ears, but I have to mention that you do not get to "close threads" on Usenet. this is obvious. You can excuse yourself from this one and stop replying to comm

Re: lambda closure question

2005-02-21 Thread jfj
Carl Banks wrote: transformations gets rebound, so you'd need a reference to it. That certainly is an application. I guess it depends on one's programming background. I'd only use nested (function, class) definition to accomplish such a feature: def genclass(x,y): clas

Re: - E02 - Support for MinGW Open Source Compiler

2005-02-21 Thread Diez B. Roggisch
> 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 > command). Some break the urls - so copy an

Re: help please

2005-02-21 Thread rzed
"gargonx" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Even if i put it in exactly the way you did: > > >>> import re > >>> charmatcher = re.compile(r' [A-Z] [\d]?') > >>> > >>> ext = dict(D="V1", O="M1", G="S1") > >>> std = dict(S="H") > >>> > >>> decode_replacements ={} > >>> de

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

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

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

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: 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

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: 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 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: 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: 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: [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: 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: 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: 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 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: 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: 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 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: 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 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: 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: 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

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: 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

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

[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: 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

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: 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: 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: 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: 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

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: - 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 >

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: 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

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: 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

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: 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: 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: 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 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: 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: 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: 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"

  1   2   >