Odd behaviour on importing variable from module

2008-08-23 Thread rs387
Hi, I've found the following behaviour on importing a variable from a module somewhat odd. The behaviour is identical in Python 2.5 and 3.0b2. In summary, here's what happens. I have a module, oddmodule.py (below), that defines a variable, OddVariable, by assigning a value A to it. The file I exe

Re: Odd behaviour on importing variable from module

2008-08-23 Thread rs387
> the construct > > from oddmodule import OddVariable, OddFunction > > assigns the *values* of the given module names to new variables in the > importing module's namespace. that is, you're binding new names to the > values the variables happen to have when the from-import statement is > exec

Stuck connection in Python 3.0b2 http.server

2008-09-13 Thread rs387
Hi All I've encountered a weird issue when migrating a web server to Python 3 - the browser would wait forever without showing a page, displaying "Transferring data" in the status bar. I tracked it down to a reference cycle in my BaseHTTPRequestHandler descendant - one of the attributes stored a d

Re: How to emit Cyrillic and Chinese via unicode from console mode?

2008-09-14 Thread rs387
On Sep 14, 2:03 am, "Siegfried Heintze" <[EMAIL PROTECTED]> wrote: > Can someone point me to an example of a little program that emits non-ascii > Unicode characters (Russian or Chinese perhaps)? The following doesn't quite work, but I'll post it anyway since it actually ends up printing the chara

Re: recursion gotcha?

2008-09-14 Thread rs387
On Sep 14, 9:01 am, cnb <[EMAIL PROTECTED]> wrote: > def suma(xs, acc=0): >         if len(xs) == 0: >                 acc >         else: >                 suma(xs[1:], acc+xs[0]) > > it returns none. Yep, that's because there is no "return" statement anywhere. Python doesn't return expressions "

Re: How to emit Cyrillic and Chinese via unicode from console mode?

2008-09-14 Thread rs387
On Sep 14, 11:51 am, Gertjan Klein <[EMAIL PROTECTED]> wrote: > Interesting. On my system (Windows XP) the console codepage does not > change, and hence the characters don't print properly (I get some of the > CP437 line drawing characters, for example). I have never been able to > convince windows

Add vs in-place add of str to list

2008-10-02 Thread rs387
Hi I'm trying to understand why it is that I can do >>> a = [] >>> a += 'stuff' >>> a ['s', 't', 'u', 'f', 'f'] but not >>> a = [] >>> a = a + 'stuff' Traceback (most recent call last): File "", line 1, in TypeError: can only concatenate list (not "str") to list Can someone explain the logi

Re: Add vs in-place add of str to list

2008-10-02 Thread rs387
On Oct 2, 8:11 am, Erik Max Francis <[EMAIL PROTECTED]> wrote: > It's because the `+=` operator is doing the equivalent of calling the > `extend` method, which treats its argument as a generic sequence, and > doesn't enforce type. I see. Do you know whether this is seen as a problem with the langu

Re: Add vs in-place add of str to list

2008-10-02 Thread rs387
On Oct 2, 3:50 pm, Mel <[EMAIL PROTECTED]> wrote: > rs387 wrote: > > I see. Do you know whether this is seen as a problem with the language > > design? > > No. OK, I get it now. I was assuming that the "+" could be implemented in terms of "+=&quo