Re: Factory for Struct-like classes

2008-08-20 Thread Dan Lenski
On Mon, 18 Aug 2008 08:28:53 -0700, Dan Lenski wrote: > So is there a bug in the Python docs? Does __slots__ in fact work with > subclasses of tuple? > > Dan Anybody think that this may actually be a mistake in the Python docs? Who would I contact about getting them corrected?

Re: Finding multiple of a decimal number in a floating point list

2008-08-18 Thread Dan Lenski
On Mon, 18 Aug 2008 18:04:53 +, Dan Lenski wrote: > On Mon, 18 Aug 2008 10:52:45 -0700, Alejandro wrote: > >> Hi: >> >> I need to find the multiples of a decimal number in a floating point >> list. For instance, if a have the list [0,0.01,0.02,...1], I wa

Re: Finding multiple of a decimal number in a floating point list

2008-08-18 Thread Dan Lenski
On Mon, 18 Aug 2008 10:52:45 -0700, Alejandro wrote: > Hi: > > I need to find the multiples of a decimal number in a floating point > list. For instance, if a have the list [0,0.01,0.02,...1], I want the > multiples of 0.2: [0, 0.2,0.4,0.6,0.8,1]. > > With integers this problem is easy, just tes

Re: Weird expression result

2008-08-18 Thread Dan Lenski
On Mon, 18 Aug 2008 18:27:53 +0200, Peter Otten wrote: > Dan Lenski wrote: >> How does this play with standard precedence rules? > > Simple, all comparisons have the same priority: > > http://docs.python.org/ref/comparisons.html > > Peter I see. So, since the comp

Re: Weird expression result

2008-08-18 Thread Dan Lenski
On Mon, 18 Aug 2008 18:04:32 +0200, Peter Otten wrote: > This works just like a < b < c: > 3 in [3] and [3] == True > False > > Peter Interesting. I agree with the OP that it is confusing! Does this expansion really get invoked every time there is an expression of the form?? expr1 binar

Re: Factory for Struct-like classes

2008-08-18 Thread Dan Lenski
On Aug 13, 1:30 pm, Christian Heimes <[EMAIL PROTECTED]> wrote: > Trynamedtuplehttp://code.activestate.com/recipes/500261/ > > Anamedtupleimplementation is part of Python 2.6 and 3.0. For older > versions of Python use the recipe from activestate. > > Christian This named tuple recipe is pretty co

Re: negative numbers are not equal...

2008-08-15 Thread Dan Lenski
On Fri, 15 Aug 2008 08:03:23 -0700, Carl Banks wrote: > On Aug 14, 4:42 pm, Christian Heimes <[EMAIL PROTECTED]> wrote: >> Integers >> between -5 and +256 are singletons as are some other objects like >> strings with one element or empty tuples. > > Not quite. > > Python 2.5.2 (r252:60911, May 2

Re: negative numbers are not equal...

2008-08-15 Thread Dan Lenski
gets created when they are assigned to variables, so a=500 followed by m=500 will create new objects. The "is" operator just shows the effect of this caching. It's unimportant for real code since you never care whether two numeric variables refer to the same object (only impo

HTTP proxy server for Motorola E815 phone in Python

2007-02-22 Thread Dan Lenski
a connection when it says it's going to? Any advice on improving the code is appreciated! Thanks, Dan Lenski -- http://mail.python.org/mailman/listinfo/python-list

Re: Python code to do the *server* side of digest authentication?

2007-02-15 Thread Dan Lenski
On Feb 15, 3:19 pm, Larry Bates <[EMAIL PROTECTED]> wrote: > I think that is because normally the web server does the authentication on the > server side. Why not use Apache to do the digest authentication? > > http://httpd.apache.org/docs/2.0/mod/mod_auth_digest.html > > -Larry Hi Larry, I'm so

Python code to do the *server* side of digest authentication?

2007-02-15 Thread Dan Lenski
Hi all, I've got a very simple HTML proxy server to access the web from my cell phone (based on this code: http://www.okisoft.co.jp/esc/python/proxy/). It's a very retarded phone that freezes if there's no Content-Length header and some other circumstances, so I have to tweak and modify the headers

Re: beginner question about range with list and list

2006-11-23 Thread Dan Lenski
erik gartz wrote: > Doesn't {} allocate new memory for the > dictionary each time? It almost appears as if the 2nd dictionary > created overwrites the first one. Thanks for your help, > Erik > > >>> > >>> a = [[{}] * 3] * 2 > >>> a > [[{}, {}, {}], [{}, {}, {}]] > >>> for i in range(2): > a[

Re: What python modules are available?

2006-11-17 Thread Dan Lenski
Why Tea wrote: > How do I find out what python modules are installed on a Solaris > platform? > > I tried to import numarray, but python couldn't find it. > > /Why Tea They're usually stored in something like /usr/lib/python2.4 And you can find most of the available modules at http://python.org/py

Re: Will GPL Java eat into Python marketshare?

2006-11-15 Thread Dan Lenski
walterbyrd wrote: > Some think it will. > > Up untill now, Java has never been standard across different versions > of Linux and Unix. Some think that is one reason that some developers > have avoided Java in favor of Python. Now that Java has been GPL'd that > might change. > > IMO: it won't make

Re: Py3K idea: why not drop the colon?

2006-11-14 Thread Dan Lenski
Hendrik van Rooyen wrote: > This is true - and it is actually also an intractable problem - if you look at > what your daughter wrote, you get the feeling that you should be able to write > an interpreter that can implement what she meant, because it is quite clear to > you - until you try to write

Re: Py3K idea: why not drop the colon?

2006-11-13 Thread Dan Lenski
Ben Finney wrote: > Readability doesn't vary directly or inversely with the number of > characters, even though it is affected when they change. Good point! Perl has more characters than Python, and I find they make it harder to read because they are distracting. Brainf*** (http://en.wikipedia.o

Re: Is python for me?

2006-11-13 Thread Dan Lenski
Carsten Haese wrote: > On Mon, 2006-11-13 at 10:14 -0800, Dan Lenski wrote: > > lennart wrote: > > > So i ask myself is python the language I'm looking for? > > > > Yep! Python is very much a jack-of-all-trades language. > > I'll run the risk of b

Re: Is python for me?

2006-11-13 Thread Dan Lenski
lennart wrote: > But I'm not a full-time programmer. I know, that I've only time & > possibility to learn one (= 1) language good. So i ask myself is python > the language I'm looking for? Yep! Python is very much a jack-of-all-trades language. I've used it for similar tasks, including as a fron

Re: Singleton Class Exception

2006-11-13 Thread Dan Lenski
dischdennis wrote: > the line "raise Singleton.__single" invokes in my class the following > error: > > exceptions must be classes, instances, or strings (deprecated), not > PurchaseRequisitionController Denis, Jason's explanation is correct! You are trying to use the Singleton instance as the ex

Re: Py3K idea: why not drop the colon?

2006-11-11 Thread Dan Lenski
Hendrik van Rooyen wrote: > "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > > 8<--- > > >>> color = "blue" > > >>> if color == "red" or "green" or "yellow": > > ... print color, "is red or green or yellow" > > ... > > blue is red or green or yellow

Re: How to choose the right GUI toolkit ?

2006-11-10 Thread Dan Lenski
Eric Brunel wrote: > On Thu, 09 Nov 2006 22:01:51 +0100, Dan Lenski <[EMAIL PROTECTED]> wrote: > > Tk 8.4 appears to use native Win32 widgets under Cygwin and native > > WinXP. > > It seems to depend on the widget type, and on what you call native... For > exampl

Re: Py3K idea: why not drop the colon?

2006-11-09 Thread Dan Lenski
Ben Finney wrote: > > I think the colon could be omitted from every type of compound > > statement: 'if', 'for', 'def', 'class', whatever. Am I missing > > anything? > > A use case. What problem is being solved by introducing this > inconsistency? I agree completely. And as a recent convert to Py

Re: Simple question to split

2006-11-09 Thread Dan Lenski
Yep, use regular expressions! For example, use the regular expression r',|\s+' to split on either (a) any amount of whitespace or (b) a single comma. Try this: import re a='1,2,3,4,5 6 7,3,4' print re.split(r',|\s+*', a) Matthias Winterland wrote: > Hi, > > I have a simple question. When I read

Re: How to choose the right GUI toolkit ?

2006-11-09 Thread Dan Lenski
One other thing I'm wondering: how exactly does Tkinter work? Is the whole Tk toolkit bound up as library of low-level C code, or does Tkinter sit on top of a Tcl interpreter? If the latter, that might explain why it is frustratingly slow on Cygwin... since Cygwin is not very good at starting up

Re: How to choose the right GUI toolkit ?

2006-11-09 Thread Dan Lenski
Wojciech Mula wrote: > Nick Craig-Wood wrote: > >> It's very mature, full-featured, and portable, and fairly easy to > >> learn as well. > > > > ...with native look and feel on each platform unlike GTK / TK > > AFAIK Tk 8 uses platform's native widgets. > > w. Tk 8.4 appears to use native Win32

Re: How to choose the right GUI toolkit ?

2006-11-09 Thread Dan Lenski
John Henry wrote: > I assume you meant that the example programs looks LabView-like GUIs? > PythonCard itself has nothing in common with LabView. It's more like > HyperCard. That's right, I'm saying the GUIs *produced* by PythonCard look like those produced by LabView. Believe me, if the Python

Re: How to choose the right GUI toolkit ?

2006-11-09 Thread Dan Lenski
Christophe wrote: > Dan Lenski a écrit : > > Nick and John S., thank you for the tip on wxPython! I'll look into it > > for my next project. I too would avoid Qt, not because of the GPL but > > simply because I don't use KDE under Linux and because Qt is not well &

Re: How to choose the right GUI toolkit ?

2006-11-09 Thread Dan Lenski
Nick Craig-Wood wrote: > John Salerno <[EMAIL PROTECTED]> wrote: > > Dan Lenski wrote: > > > > > So, is there another toolkit I should be looking at? > > > > I highly recommend wxPython. > > I'd second that! > > There is a book also >

How to choose the right GUI toolkit ?

2006-11-08 Thread Dan Lenski
n quickly move programs to new measurement computers. I like GTK a lot and Tk is growing on me too.. are there any higher-level "wrapper" toolkits for GTK and Tk? Thanks for any advice! Dan Lenski University of Maryland -- http://mail.python.org/mailman/listinfo/python-list