Re: Overriding iadd for dictionary like objects

2009-08-26 Thread RunThePun
On Aug 27, 6:58 am, Robert Kern wrote: > On 2009-08-26 20:00 PM, Jan Kaliszewski wrote: > > > > > > > 27-08-2009 o 00:48:33 Robert Kern wrote: > > >> On 2009-08-26 17:16 PM, RunThePun wrote: > >>> I'd like to build a database wrapper using DictMixin and allow items > >>> to be appended by my own

Re: Need help with Python scoping rules

2009-08-26 Thread Hendrik van Rooyen
On Wednesday 26 August 2009 17:14:27 kj wrote: > As I described at length in another reply, the function in question > is not intended to be "callable outside the class". And yes, I think this might go to nub of your problem - It might help you to think as follows: A Python class, even after

Re: codecs.open on Win32 -- converting my newlines to CR+LF

2009-08-26 Thread Chris Rebert
On Wed, Aug 26, 2009 at 11:06 PM, Chris Rebert wrote: > On Wed, Aug 26, 2009 at 8:40 PM, Ryan McGuire wrote: >> On Aug 26, 11:04 pm, Philip Semanchuk wrote: >>> Try using "rb" instead of "r" for the mode in the call to open(). >>> >>> HTH >>> Philip >> >> That does indeed fix the problem, thanks!

Re: codecs.open on Win32 -- converting my newlines to CR+LF

2009-08-26 Thread Chris Rebert
On Wed, Aug 26, 2009 at 8:40 PM, Ryan McGuire wrote: > On Aug 26, 11:04 pm, Philip Semanchuk wrote: >> Try using "rb" instead of "r" for the mode in the call to open(). >> >> HTH >> Philip > > That does indeed fix the problem, thanks! Still seems like the docs > are wrong though. Yeah, the need t

Re: break unichr instead of fix ord?

2009-08-26 Thread Martin v. Löwis
> My apologies for the red herring. I was working from > a comment in my replacement ord() function. I dug up > an old copy of Python 2.4.3 and could not reproduce it > there either so I have no explanation for the comment > (which I wrote). Python 2.3 maybe? No. The behavior you observed would

Re: break unichr instead of fix ord?

2009-08-26 Thread rurpy
On 08/26/2009 08:52 PM, Steven D'Aprano wrote: > On Wed, 26 Aug 2009 16:27:33 -0700, rurpy wrote: > >> But regardless, the significant question is, what is the reason for >> having ord() (and unichr) not work for surrogate pairs and thus not >> usable with a large number of unicode characters th

Re: Object's nesting scope

2009-08-26 Thread ryles
On Aug 26, 8:51 am, zaur wrote: > Hi folk! > > What do you think about idea of "object's nesting scope" in python? > > Let's imaging this feature, for example, in this syntax: > > obj=: >       > > or > > : >     > > That's means that result object of evaluation is used as > nested scope for eva

Re: Overriding iadd for dictionary like objects

2009-08-26 Thread Robert Kern
On 2009-08-26 20:00 PM, Jan Kaliszewski wrote: 27-08-2009 o 00:48:33 Robert Kern wrote: On 2009-08-26 17:16 PM, RunThePun wrote: I'd like to build a database wrapper using DictMixin and allow items to be appended by my own code. The problem is += is always understood as setitem and getitem pl

Re: codecs.open on Win32 -- converting my newlines to CR+LF

2009-08-26 Thread Ryan McGuire
On Aug 26, 11:04 pm, Philip Semanchuk wrote: > Try using "rb" instead of "r" for the mode in the call to open(). > > HTH > Philip That does indeed fix the problem, thanks! Still seems like the docs are wrong though. -- http://mail.python.org/mailman/listinfo/python-list

Re: Numeric literals in other than base 10 - was Annoying octal notation

2009-08-26 Thread Steven D'Aprano
On Wed, 26 Aug 2009 18:53:04 -0700, Erik Max Francis wrote: >> In any case, unary is the standard term for what I'm discussing: >> >> http://en.wikipedia.org/wiki/Unary_numeral_system >> >> although Mathworld doesn't seem to know it. > > Psst. That's a hint. > > Googling for "unary number sys

Re: Python on the Web

2009-08-26 Thread Phil
Thanks a lot for another response. I've never posted in groups like this before but the results are amazing. I will definitely consider trying mod_wsgi when I get a chance. I like the approach taken with it. It is unfortunate that I completely missed all Apache related material because I was using

Re: codecs.open on Win32 -- converting my newlines to CR+LF

2009-08-26 Thread Philip Semanchuk
On Aug 26, 2009, at 10:52 PM, Ryan McGuire wrote: I've got a UTF-8 encoded text file from Linux with standard newlines ("\n"). I'm reading this file on Win32 with Python 2.6: codecs.open("whatever.txt","r","utf-8").read() Inexplicably, all the newlines ("\n") are replaced with CR+LF ("\r \n"

Re: break unichr instead of fix ord?

2009-08-26 Thread Steven D'Aprano
On Wed, 26 Aug 2009 16:27:33 -0700, rurpy wrote: > But regardless, the significant question is, what is the reason for > having ord() (and unichr) not work for surrogate pairs and thus not > usable with a large number of unicode characters that Python otherwise > supports? I'm no expert on Unico

codecs.open on Win32 -- converting my newlines to CR+LF

2009-08-26 Thread Ryan McGuire
I've got a UTF-8 encoded text file from Linux with standard newlines ("\n"). I'm reading this file on Win32 with Python 2.6: codecs.open("whatever.txt","r","utf-8").read() Inexplicably, all the newlines ("\n") are replaced with CR+LF ("\r \n") ... Why? As a workaround I'm having to do this: op

Re : Python Processor

2009-08-26 Thread manish
Hi, Contrary to the ancient and, I believe, obsolete text in the documentation, there is no 'python bytecode'. Dis is based on CPython bytecode. Jython uses Java bytecode. IronPython uses, I believe, Microsoft clr bytecode. Object code compilers do not use bytecode. Before

Re: Python on the Web

2009-08-26 Thread Graham Dumpleton
On Aug 27, 2:54 am, Phil wrote: > Thanks to everybody. I believe I am understanding things better. > > I have looked at the links that have been provided, although I have > seen most of them in the past month or so that I've been looking into > this stuff. I do agree with most of the things Armin

Re: Numeric literals in other than base 10 - was Annoying octal notation

2009-08-26 Thread Erik Max Francis
Steven D'Aprano wrote: On Wed, 26 Aug 2009 10:58:12 -0700, Mensanator wrote: But I certainly wouldn't call it "binary", for fear of confusion with radix-2 binary. That's my point. Since the common usage of "binary" is for Standard Positional Number System of Radix 2, it follows that "unary" is

Re: Numeric literals in other than base 10 - was Annoying octal notation

2009-08-26 Thread Steven D'Aprano
On Thu, 27 Aug 2009 01:34:10 +, Steven D'Aprano wrote: > On Wed, 26 Aug 2009 10:58:12 -0700, Mensanator wrote: > >>> But I certainly wouldn't call it "binary", for fear of confusion with >>> radix-2 binary. >> >> That's my point. Since the common usage of "binary" is for Standard >> Position

Re: Numeric literals in other than base 10 - was Annoying octal notation

2009-08-26 Thread Steven D'Aprano
On Wed, 26 Aug 2009 10:58:12 -0700, Mensanator wrote: >> But I certainly wouldn't call it "binary", for fear of confusion with >> radix-2 binary. > > That's my point. Since the common usage of "binary" is for Standard > Positional Number System of Radix 2, it follows that "unary" is the > common

Re: [Tutor] Declaration order of classes... why it is important?

2009-08-26 Thread Dave Angel
(Looks like you posted privately to me; should use Reply-all. I'm copying entire message here so others can add to my comments) Mac Ryan wrote: On Wed, 2009-08-26 at 15:46 -0400, Dave Angel wrote: So define a classmethod to finish the job, and invoke it later class Employee(object):

Re: List iterator thread safety

2009-08-26 Thread Aahz
In article , Emanuele D'Arrigo wrote: > >Let's say I have a list accessed by two threads, one removing list >items via "del myList[index]" statement the other iterating through >the list and printing out the items via "for item in myList:" >statement. Am I right to say this -won't- generate except

Re: Overriding iadd for dictionary like objects

2009-08-26 Thread Jan Kaliszewski
27-08-2009 o 00:48:33 Robert Kern wrote: On 2009-08-26 17:16 PM, RunThePun wrote: I'd like to build a database wrapper using DictMixin and allow items to be appended by my own code. The problem is += is always understood as setitem and getitem plainly. d = MyDict() d['a'] = 1 # this is the p

Re: Overriding iadd for dictionary like objects

2009-08-26 Thread Jan Kaliszewski
27-08-2009 o 00:48:33 Robert Kern wrote: On 2009-08-26 17:16 PM, RunThePun wrote: I'd like to build a database wrapper using DictMixin and allow items to be appended by my own code. The problem is += is always understood as setitem and getitem plainly. d = MyDict() d['a'] = 1 # this is the p

Re: break unichr instead of fix ord?

2009-08-26 Thread Vlastimil Brom
2009/8/27 : > On Aug 26, 2:05 am, Vlastimil Brom wrote: >>[...] >>... >> However, if I need these functions for higher unicode planes, the >> following rather hackish replacements seem to work. I presume, there >> might be smarter ways of dealing with this, but anyway... >> >> hth, >>    vbr >> >

Re: Overriding iadd for dictionary like objects

2009-08-26 Thread Xavier Ho
I haven't tested it, but did you encounter a problem defining __iadd__ in the class definition? See: http://docs.python.org/reference/datamodel.html#object.__iadd__ Cheers, Ching-Yun "Xavier" Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xav

Re: Zlib: correct checksum but error decompressing

2009-08-26 Thread John Machin
Paul Rubin writes: > > Andre gmail.com> writes: > > I have been trying to solve this issue for a while now. I receive data > > from a TCP connection which is compressed. > > Are you sure it is compressed with zlib? If yes, does it include the > standard zlib header? Some applications save a

Re: Python for professsional Windows GUI apps?

2009-08-26 Thread Stef Mientki
Gilles Ganault wrote: On Tue, 25 Aug 2009 13:24:39 +0200, Wolfgang Keller wrote: The area of _desktop_ database application development indeed looks like a vast and very hostile desert in the Python landscape. The only framework that seems to be worth trying is Dabo. Unfortunately there's

Re: Python for professsional Windows GUI apps?

2009-08-26 Thread Robert Kern
On 2009-08-26 18:08 PM, sturlamolden wrote: On 26 Aug, 22:47, David C Ullrich wrote: Nothing, except lobbying for wxFormBuilder for anyone who still doesn't know of it. :) That's great. But do you know of anything I can use as a visual form design tool in wxPython? Right... I don't know if

Re: break unichr instead of fix ord?

2009-08-26 Thread rurpy
On Aug 26, 2:05 am, Vlastimil Brom wrote: >[...] > Hi, > I'm not sure about the exact reasons for this behaviour on narrow > builds either (maybe the consistency of the input/ output data to > exactly one character?). > > However, if I need these functions for higher unicode planes, the > followin

Re: break unichr instead of fix ord?

2009-08-26 Thread rurpy
On Aug 25, 9:53 pm, "Mark Tolonen" wrote: > wrote in message > > news:2ad21a79-4a6c-42a7-8923-beb304bb5...@v20g2000yqm.googlegroups.com... > > > > > In Python 2.5 on Windows I could do [*1]: > > >  # Create a unicode character outside of the BMP. > >  >>> a = u'\U00010040' > > >  # On Windows it

Re: break unichr instead of fix ord?

2009-08-26 Thread rurpy
On 08/26/2009 03:10 PM, "Martin v. Löwis" wrote: >> >> In Python 2.5 on Windows I could do [*1]: >> >> >> >>>>> a = unichr (65600) >> >>>>> a[0],a[1] >> >>(u'\ud800', u'\udc40') > > > > I can't reproduce that. My copy of Python on Windows gives > > > > Traceback (most recent call las

Re: Python for professsional Windows GUI apps?

2009-08-26 Thread Che M
On Aug 26, 4:47 pm, David C Ullrich wrote: > On Mon, 24 Aug 2009 22:22:20 -0700, sturlamolden wrote: > > On 25 Aug, 05:56, Peter Decker wrote: > > >> I use the Dabo Class Designer to visually design my forms. So what's > >> you're point?  :) > > > Nothing, except lobbying for wxFormBuilder for an

Re: Python for professsional Windows GUI apps?

2009-08-26 Thread Che M
> Combined with the comment above about issues with printing, it looks > like Python for GUI apps isn't a very good idea :-/ I don't have that feeling at all. I don't have that much of a basis of comparison, but my experience with wxPython for making GUI apps has been pretty good. Does anyone kn

Re: Python for professsional Windows GUI apps?

2009-08-26 Thread sturlamolden
On 26 Aug, 22:47, David C Ullrich wrote: > > Nothing, except lobbying for wxFormBuilder for anyone who still doesn't > > know of it. :) > > That's great. But do you know of anything I can use as a > visual form design tool in wxPython? Right... I don't know if you are trying to be funny, but as

Re: How to exclude "import"s from PyDoc

2009-08-26 Thread Diez B. Roggisch
Matt Bellis schrieb: Hi all, I tried PyDoc today for documentation for a small project on which I'm working. I have a class, foo, in foo.py. However, at the beginning of the file I "from math import *". When I use PyDoc, it's pulling in all the math functions ---snip--- . . . FUNCTION

Re: Overriding iadd for dictionary like objects

2009-08-26 Thread Robert Kern
On 2009-08-26 17:16 PM, RunThePun wrote: I'd like to build a database wrapper using DictMixin and allow items to be appended by my own code. The problem is += is always understood as setitem and getitem plainly. d = MyDict() d['a'] = 1 # this is the problem code that's I'd like to override. It'

How to exclude "import"s from PyDoc

2009-08-26 Thread Matt Bellis
Hi all, I tried PyDoc today for documentation for a small project on which I'm working. I have a class, foo, in foo.py. However, at the beginning of the file I "from math import *". When I use PyDoc, it's pulling in all the math functions ---snip--- . . . FUNCTIONS acos(...)

Re: Python for professsional Windows GUI apps?

2009-08-26 Thread Stef Mientki
David C Ullrich wrote: On Mon, 24 Aug 2009 22:22:20 -0700, sturlamolden wrote: On 25 Aug, 05:56, Peter Decker wrote: I use the Dabo Class Designer to visually design my forms. So what's you're point? :) Nothing, except lobbying for wxFormBuilder for anyone who still doesn't

Overriding iadd for dictionary like objects

2009-08-26 Thread RunThePun
I'd like to build a database wrapper using DictMixin and allow items to be appended by my own code. The problem is += is always understood as setitem and getitem plainly. d = MyDict() d['a'] = 1 # this is the problem code that's I'd like to override. It's always setitem('a', getitem('a') + 3) d['

Re: How do I insert a menu item in an existing menu.

2009-08-26 Thread MRAB
BlueFlash wrote: Idea: Use of a RecentFileList, update element 0 with new file opened. Appending a menu is easy menu.Append(-1, "Menu Name") when I try to insert a new menu item menu.Insert(-1, position, "Menu Name") does not work. The following comments are the result of a brief search of

Re: Zlib: correct checksum but error decompressing

2009-08-26 Thread Paul Rubin
Andre writes: > I have been trying to solve this issue for a while now. I receive data > from a TCP connection which is compressed. Are you sure it is compressed with zlib? If yes, does it include the standard zlib header? Some applications save a few bytes by stripping the header. See the zli

Re: Need help with Python scoping rules

2009-08-26 Thread Jan Kaliszewski
26-08-2009 o 17:45:54 kj wrote: In <02a54597$0$20629$c3e8...@news.astraweb.com> Steven D'Aprano writes: On Wed, 26 Aug 2009 10:57:32 +, kj wrote: Recursion! One of the central concepts in the theory of functions! This is shown most clearly by the following elaboration of my origin

How do I insert a menu item in an existing menu.

2009-08-26 Thread BlueFlash
Idea: Use of a RecentFileList, update element 0 with new file opened. Appending a menu is easy menu.Append(-1, "Menu Name") when I try to insert a new menu item menu.Insert(-1, position, "Menu Name") does not work. full code: def addnew(self, position, path): path = path.strip()

Re: Web Services examples using "raw" xml?

2009-08-26 Thread Piet van Oostrum
> "Diez B. Roggisch" (DBR) wrote: >DBR> John Gordon schrieb: >>> I'm developing a program that will use web services, which I have never >>> used before. >>> >>> There are several tutorials out there that advise you to get the WSDL >>> and then call a method (such as wsdl2py) that inspects t

Re: Need help with Python scoping rules

2009-08-26 Thread Ethan Furman
kj wrote: I think I understand the answers well enough. What I *really* don't understand is why this particular "feature" of Python (i.e. that functions defined within a class statement are forbidden from "seeing" other identifiers defined within the class statement) is generally considered to b

Re: Python Processor

2009-08-26 Thread Martin P. Hellwig
John Nagle wrote: CPython's performance problems come from excessive dictionary lookups, not from instruction decode. John Nagle Could you please suggest some background information/links to this? I tried to Google for it but unsurprisingly any combination with 'cpython' and

Re: break unichr instead of fix ord?

2009-08-26 Thread Martin v. Löwis
> In Python 2.5 on Windows I could do [*1]: > > >>> a = unichr (65600) > >>> a[0],a[1] > (u'\ud800', u'\udc40') I can't reproduce that. My copy of Python on Windows gives Traceback (most recent call last): File "", line 1, in unichr(65600) ValueError: unichr() arg not in range(0x100

Re: ubuntu dist-packages

2009-08-26 Thread Paul Boddie
On 26 Aug, 17:48, Jorgen Grahn wrote: > > Well, if you are thinking about Debian Linux, it's not as much > "ripping out" as "splitting into a separate package with a non-obvious > name". Annoying at times, but hardly an atrocity. Indeed. Having seen two packages today which insisted on setuptools

Re: all possible matchings of elements of two lists

2009-08-26 Thread Jan Kaliszewski
26-08-2009 o 12:05:41 Sandy wrote: Hi all, I basically want all possible matchings of elements from two lists, Ex: [1,2] [a,b,c] Required: [ [(1,a),(2,b)] [(1,b),(2,c)] [(1,c),(2,b)] [(1,b),(2,a)] [(1,c),(2,a)] [(1,a),(2,c)] ] My thought is to get all possible p

Re: Confessions of a Python fanboy

2009-08-26 Thread Luis Zarrabeitia
On Friday 31 July 2009 04:08:33 am Masklinn wrote: > On 30 Jul 2009, at 23:57 , Luis Zarrabeitia wrote: > > I'd like to ask, what "container.each" is, exactly? It looks like a > > function > > call (as I've learned a few posts ago), but, what are its arguments? > > How the > > looping "works"? Does

RE: print() and unicode strings (python 3.1)

2009-08-26 Thread Anonymous
Have you considered including an encoding line at the top of your file, as described in PEP 0263: http://www.python.org/dev/peps/pep-0263/ I just ran into a similar error, but it went away when I included # coding: utf-8 as the first line in my file. -- http://mail.python.org/mailman/listinfo

Re: Python for professsional Windows GUI apps?

2009-08-26 Thread David C Ullrich
On Mon, 24 Aug 2009 22:22:20 -0700, sturlamolden wrote: > On 25 Aug, 05:56, Peter Decker wrote: > >> I use the Dabo Class Designer to visually design my forms. So what's >> you're point?  :) > > Nothing, except lobbying for wxFormBuilder for anyone who still doesn't > know of it. :) That's gre

Re: Need help with Python scoping rules

2009-08-26 Thread Jan Kaliszewski
26-08-2009 o 09:03:27 Ulrich Eckhardt wrote: Jean-Michel Pichavant wrote: class Color: def __init__(self, r, g,b): pass BLACK = Color(0,0,0) It make sens from a design point of view to put BLACK in the Color namespace. But I don't think it's possible with python. class Col

Re: ubuntu dist-packages

2009-08-26 Thread Jorgen Grahn
On Wed, 26 Aug 2009 17:20:35 +0100, Robin Becker wrote: > Jorgen Grahn wrote: >> On Wed, 26 Aug 2009 12:46:13 +0200, Diez B. Roggisch > >> Well, if you are thinking about Debian Linux, it's not as much >> "ripping out" as "splitting into a separate package with a non-obvious >> name". Ann

Re: Need help with Python scoping rules

2009-08-26 Thread kj
In <2a7gm6-9h@satorlaser.homedns.org> Ulrich Eckhardt writes: >kj wrote: >> class Demo(object): >> def fact_iter(n): >> ret = 1 >> for i in range(1, n + 1): >> ret *= i >> return ret >> >> def fact_rec(n): >> if n < 2: >> retur

Re: Need help with Python scoping rules

2009-08-26 Thread kj
In <7figv3f2m3p0...@mid.uni-berlin.de> "Diez B. Roggisch" writes: >But if you insist on the above methodology, you can do this: >class Demo(object): >def fact(n): >def inner(n): >if n < 2: >return 1 >else: >return n * inner(n

Re: Need help with Python scoping rules

2009-08-26 Thread kj
In Ethan Furman writes: >Going back through the archives I found Arnaud's post with this decorator: >def bindfunc(f): > def boundf(*args, **kwargs): > return f(boundf, *args, **kwargs) > return boundf >If you use it on your fact function like so... >class Demo(object): >

Re: Protecting against callbacks queuing up?

2009-08-26 Thread Esben von Buchwald
Dennis Lee Bieber wrote: On Tue, 25 Aug 2009 15:21:16 +0200, Esben von Buchwald declaimed the following in gmane.comp.python.general: This is how the accelerometer is accessed http://pys60.garage.maemo.org/doc/s60/node59.html I found this called "after"... http://pys60.garage.maemo.org/doc/s6

Re: Protecting against callbacks queuing up?

2009-08-26 Thread Esben von Buchwald
Hendrik van Rooyen wrote: would that be usable? Probably If so, how? This is a guess, for your device, but I suspect something along these lines: t = Ao_timer() cb = t.after(100,thing_that_does_the_work(with_its_arguments)) Lots of assumptions here - the 100 should give you a tenth of a s

Re: pygtk - What is the best way to change the mouse pointer

2009-08-26 Thread MRAB
Ido Levy wrote: Hello All, I am writing a dialog which one of its widget is a gtk.ComboBoxEntry ( let's assume widget in the example below is its instance ) When the user select one of the values from the gtk.ComboBoxEntry I need to run some calculations that takes a few seconds. In order to r

Re: Object's nesting scope

2009-08-26 Thread MRAB
zaur wrote: On 26 авг, 21:11, "Rami Chowdhury" wrote: person = Person(): name = "john" age = 30 address = Address(): street = "Green Street" no = 12 Can you clarify what you mean? Would that define a Person class, and an Address class? I suppose that someone already define cl

Re: Need help with Python scoping rules

2009-08-26 Thread Dave Angel
Carl Banks wrote: On Aug 26, 8:13 am, Dave Angel wrote: You can probably work around this by replacing the staticmethod decorator with an equivalent function call:. class Demo9(object): def fact(n): if n < 2: return 1 else: return n * Demo.fact(n

ANN: ActivePython 3.1.1.2 is now available

2009-08-26 Thread Sridhar Ratnakumar
I'm happy to announce that ActivePython 3.1.1.2 is now available for download from: http://www.activestate.com/activepython/python3/ This is a patch release that updates ActivePython to core Python 3.1.1 We recommend that you try 2.6 version first. See the release notes for full details:

Re: quantiles of a student distribution

2009-08-26 Thread Robert Kern
On 2009-08-26 11:49 AM, Colin J. Williams wrote: Pierre wrote: Hello... Do you know how I can calculate the quantiles of a student distribution in pyhton ? Thanks You might look at: http://bonsai.ims.u-tokyo.ac.jp/~mdehoon/software/python/special.html [Please pardon the piggybacking. I have

Re: Python Processor

2009-08-26 Thread John Nagle
Terry Reedy wrote: manish wrote: Hi, I am also wondering about how to implement a soft core reconfigurable processor in a FPGA which would directly execute the compiled python bytecode. It probably wouldn't help much. CPython's performance problems come from excessive dictionary lookups,

Re: Need help with Python scoping rules

2009-08-26 Thread kj
In <02a54597$0$20629$c3e8...@news.astraweb.com> Steven D'Aprano writes: >http://docs.python.org/reference/executionmodel.html >It is also discussed in the PEP introducing nested scopes to Python: >http://www.python.org/dev/peps/pep-0227/ >It's even eluded to in the tutorial: >http://docs.pyt

Re: Context manager to temporarily change the variable of a register [aka write swap(a,b)]

2009-08-26 Thread Evan Driscoll
On Aug 26, 10:15 am, Carl Banks wrote: > Well, it wouldn't be a "can I rebind a variable using a with- > statement" thread if someone didn't post a solution that they thought > worked, but didn't test it on local variables. I'm not going to deny it was pretty stupid... though in my defense, I'm n

Re: Object's nesting scope

2009-08-26 Thread zaur
On 26 авг, 21:11, "Rami Chowdhury" wrote: > > person = Person(): > >   name = "john" > >   age = 30 > >   address = Address(): > >      street = "Green Street" > >      no = 12 > > Can you clarify what you mean? Would that define a Person class, and an   > Address class? I suppose that someone alr

Re: Need help with Python scoping rules

2009-08-26 Thread Ethan Furman
kj wrote: I have many years of programming experience, and a few languages, under my belt, but still Python scoping rules remain mysterious to me. (In fact, Python's scoping behavior is the main reason I gave up several earlier attempts to learn Python.) Here's a toy example illustrating what

Re: ubuntu dist-packages

2009-08-26 Thread Florian Diesch
Robin Becker writes: > I was surprised a couple of days ago when trying to assist a colleage > with his python setup on a ubuntu 9.04 system. > > We built our c-extensions and manually copied them into place, but > site-packages wasn't there. It seems that ubuntu now wants stuff to go > into lib/

SimpleXMLRPCServer timeout issue

2009-08-26 Thread Mahi Haile
Hi all, I have an XML-RPC server running that is using SimpleXMLRPCServer, and I am trying to send a relatively large file on a poor connection [simulated low bandwidth, high latency]. The file is simply the return value of a function call available on the server. However, sometime in to the transf

Re: Numeric literals in other than base 10 - was Annoying octal notation

2009-08-26 Thread Mensanator
On Aug 26, 9:58 am, Steven D'Aprano wrote: > On Tue, 25 Aug 2009 11:45:28 -0700, Mensanator wrote: > > On Aug 25, 9:14 am, Steven D'Aprano > cybersource.com.au> wrote: > >> On Mon, 24 Aug 2009 18:01:38 -0700, Mensanator wrote: > >> >> If you want your data file to have values entered in hex, or o

Re: Need help with Python scoping rules

2009-08-26 Thread Terry Reedy
kj wrote: In <7figv3f2m3p0...@mid.uni-berlin.de> "Diez B. Roggisch" writes: Classes are not scopes. Classes are objects. In particular, they are (by default) instances of class 'type'. Unless 'scopes' were instances of some other metaclass, the statement has to be true. I understand 'sco

Re: How does the file.seek() work ?

2009-08-26 Thread gert
On Aug 26, 12:46 am, Graham Dumpleton wrote: > On Aug 25, 5:37 am, Tim Chase wrote: > > > > I want the file pointer set to 100 and overwrite everything from there > > [snip] > > > def application(environ, response): > > >     query=os.path.join(os.path.dirname(__file__),'teemp') > > >    

Re: Need help with Python scoping rules

2009-08-26 Thread Ulrich Eckhardt
kj wrote: > class Demo(object): > def fact_iter(n): > ret = 1 > for i in range(1, n + 1): > ret *= i > return ret > > def fact_rec(n): > if n < 2: > return 1 > else: > return n * fact_rec(n - 1) > > classvar1

Re: Object's nesting scope

2009-08-26 Thread Rami Chowdhury
person = Person(): name = "john" age = 30 address = Address(): street = "Green Street" no = 12 Can you clarify what you mean? Would that define a Person class, and an Address class? If you are expecting those classes to be already defined, please bear in mind that if you w

Re: Python on the Web

2009-08-26 Thread Phil
Thanks to everybody. I believe I am understanding things better. I have looked at the links that have been provided, although I have seen most of them in the past month or so that I've been looking into this stuff. I do agree with most of the things Armin stated in that NIH post. I agree with ever

Re: Object's nesting scope

2009-08-26 Thread zaur
On 26 авг, 17:13, "Diez B. Roggisch" wrote: > Whom am we to judge? Sure if you propose this, you have some usecases in > mind - how about you present these Ok. Here is a use case: object initialization. For example, person = Person(): name = "john" age = 30 address = Address(): stree

Re: quantiles of a student distribution

2009-08-26 Thread Colin J. Williams
Pierre wrote: Hello... Do you know how I can calculate the quantiles of a student distribution in pyhton ? Thanks You might look at: http://bonsai.ims.u-tokyo.ac.jp/~mdehoon/software/python/special.html Colin W. -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help with Python scoping rules

2009-08-26 Thread Steven D'Aprano
On Wed, 26 Aug 2009 15:36:35 +, kj wrote: > In <1bf83a7e-f9eb-46ff-84fe-cf42d9608...@j21g2000yqe.googlegroups.com> > Carl Banks writes: > >>Yeah, it's a little surprising that you can't access class scope from a >>function, but that has nothing to do with encapsulation. > > It does: it thwa

Re: Python Processor

2009-08-26 Thread Terry Reedy
manish wrote: Hi, I am also wondering about how to implement a soft core reconfigurable processor in a FPGA which would directly execute the compiled python bytecode. I am trying to understand the bytecode format but apart from http://docs.python.org/library/dis.html there is hardly any doc

Re: ubuntu dist-packages

2009-08-26 Thread Robin Becker
Jorgen Grahn wrote: On Wed, 26 Aug 2009 12:46:13 +0200, Diez B. Roggisch Well, if you are thinking about Debian Linux, it's not as much "ripping out" as "splitting into a separate package with a non-obvious name". Annoying at times, but hardly an atrocity. so where is the official plac

Re: Need help with Python scoping rules

2009-08-26 Thread Carl Banks
On Aug 26, 8:36 am, kj wrote: > In <1bf83a7e-f9eb-46ff-84fe-cf42d9608...@j21g2000yqe.googlegroups.com> Carl > Banks writes: > > >Yeah, it's a little surprising that you can't access class scope from > >a function, but that has nothing to do with encapsulation. > > It does: it thwarts encapsulati

Re: Need help with Python scoping rules

2009-08-26 Thread Steven D'Aprano
On Wed, 26 Aug 2009 14:09:57 +, kj wrote: >>1. One of the key aspects of Python's design is that attributes must be >>accessed explicitly with dot notation. Accessing class scopes from >>nested functions would (seemingly) allow access to class attributes >>without the dotted notation. Theref

Re: Move dictionary from instance to class level

2009-08-26 Thread Dave Angel
Frank Millman wrote: "MRAB" wrote in message news:mailman.444.1251290454.2854.python-l...@python.org... An alternative is: class MyClass(object): ... def on_message_received(self, msg): ... try: ... getattr(self, "method_%d" % msg)() ... exc

Re: ubuntu dist-packages

2009-08-26 Thread Jorgen Grahn
On Wed, 26 Aug 2009 12:46:13 +0200, Diez B. Roggisch wrote: > Robin Becker wrote: > >> I was surprised a couple of days ago when trying to assist a colleage with >> his python setup on a ubuntu 9.04 system. >> >> We built our c-extensions and manually copied them into place, but >> site-packages

Re: Need help with Python scoping rules

2009-08-26 Thread kj
In <02a54597$0$20629$c3e8...@news.astraweb.com> Steven D'Aprano writes: >On Wed, 26 Aug 2009 10:57:32 +, kj wrote: >> Recursion! One of the central concepts in the theory of >> functions! This is shown most clearly by the following elaboration of >> my original example: >> >> class Demo(

Re: Need help with Python scoping rules

2009-08-26 Thread Nigel Rantor
kj wrote: > > Needless to say, I'm pretty beat by this point. Any help would be > appreciated. > > Thanks, Based on your statement above, and the fact that multiple people have now explained *exactly* why your attempt at recursion hasn't worked, it might be a good idea to step back, accept the a

Re: Need help with Python scoping rules

2009-08-26 Thread Steven D'Aprano
On Wed, 26 Aug 2009 13:57:23 +, kj wrote: > In "Martin P. Hellwig" > writes: > >>kj wrote: >> >>> First, one of the goals of OO is encapsulation, not only at the level >>> of instances, but also at the level of classes. >>Who says? > > Python itself: it already offers a limited form of cla

Re: Need help with Python scoping rules

2009-08-26 Thread kj
In <1bf83a7e-f9eb-46ff-84fe-cf42d9608...@j21g2000yqe.googlegroups.com> Carl Banks writes: >Yeah, it's a little surprising that you can't access class scope from >a function, but that has nothing to do with encapsulation. It does: it thwarts encapsulation. The helper function in my example is o

Re: Help with arrays

2009-08-26 Thread Dave Angel
Mart. wrote: On Aug 26, 3:02 am, Dave Angel wrote: Stephen Fairchild wrote: Philip Semanchuk wrote: On Aug 25, 2009, at 6:14 PM, Gleb Belov wrote: Hello! I'm working on an exercise wherein I have to write a Guess The Number game, but it's the computer who's guessing M

Re: Need help with Python scoping rules

2009-08-26 Thread Steven D'Aprano
On Wed, 26 Aug 2009 10:57:32 +, kj wrote: > In <7figv3f2m3p0...@mid.uni-berlin.de> "Diez B. Roggisch" > writes: > >>Classes are not scopes. > > This looks to me like a major wart, on two counts. > > First, one of the goals of OO is encapsulation, not only at the level of > instances, but a

Re: Need help with Python scoping rules

2009-08-26 Thread Carl Banks
On Aug 26, 8:13 am, Dave Angel wrote: > You can probably work around this by replacing the staticmethod > decorator with an equivalent function call:. > > class Demo9(object): >     def fact(n): >         if n < 2: >             return 1 >         else: >             return n * Demo.fact(n - 1) >

Re: Need help with Python scoping rules

2009-08-26 Thread kj
In <1bf83a7e-f9eb-46ff-84fe-cf42d9608...@j21g2000yqe.googlegroups.com> Carl Banks writes: >On Aug 26, 7:09=A0am, kj wrote: >> In <16b72319-8023-471c-ba40-8025aa6d4...@a26g2000yqn.googlegroups.com> Ca= >rl Banks writes: >> >> >> First, one of the goals of OO is encapsulation, not only at the >>

Raw data extraction question

2009-08-26 Thread Maggie
i have event timing stretch of code i need to alter. here is code below: -- # we start each run with one full silent trial # creating a "stub" with the duration of a full block # less the discarded acquisitions stub = block_dur - (distax * tr) feed = sys.stdin.readlines() sess = -1 for

Re: Context manager to temporarily change the variable of a register [aka write swap(a,b)]

2009-08-26 Thread Carl Banks
On Aug 25, 1:07 pm, Evan Driscoll wrote: > On Aug 25, 2:33 pm, Evan Driscoll wrote: > > > I want to make a context manager that will temporarily change the > > value of a variable within the scope of a 'with' that uses it. This is > > inspired by a C++ RAII object I've used in a few projects. Ide

Re: Need help with Python scoping rules

2009-08-26 Thread kj
In Dave Angel writes: >Thanks for diluting my point. The OP is chasing the wrong problem. Who >cares whether a class initializer can call a method, if the method >doesn't meet its original requirements, to be callable outside the class? >And the arguments about how recursion is restricted

Re: Need help with Python scoping rules

2009-08-26 Thread Dave Angel
kj wrote: In <7figv3f2m3p0...@mid.uni-berlin.de> "Diez B. Roggisch" writes: Classes are not scopes. This looks to me like a major wart, on two counts. First, one of the goals of OO is encapsulation, not only at the level of instances, but also at the level of classes. Your comment

Re: Zlib: correct checksum but error decompressing

2009-08-26 Thread InvisibleRoads Patrol
On Wed, 26 Aug 2009 07:19:42 -0700 (PDT), Andre wrote: > I have been trying to solve this issue for a while now. I receive data > from a TCP connection which is compressed. I know the correct checksum > for the data and both the client and server generate the same > checksum. However, in Python wh

Re: Numeric literals in other than base 10 - was Annoying octal notation

2009-08-26 Thread Steven D'Aprano
On Tue, 25 Aug 2009 11:45:28 -0700, Mensanator wrote: > On Aug 25, 9:14 am, Steven D'Aprano cybersource.com.au> wrote: >> On Mon, 24 Aug 2009 18:01:38 -0700, Mensanator wrote: >> >> If you want your data file to have values entered in hex, or oct, or >> >> even unary (1=one, 11=two, 111=three, 11

  1   2   >