Re: __getattr__ Confusion

2013-02-04 Thread Saul Spatz
On Sunday, February 3, 2013 10:35:30 PM UTC-6, Steven D'Aprano wrote: On Sun, 03 Feb 2013 17:08:47 -0800, Saul Spatz wrote: I don't understand what's going on at all. Can't I dynamically define __getattr__? How should I go about it? Special dunder methods (DoubleUNDERscore

Re: __getattr__ Confusion

2013-02-04 Thread Saul Spatz
(self, name): print(name) raise AttributeError like a sensible person. Saul On Monday, February 4, 2013 8:15:47 AM UTC-6, Peter Otten wrote: Saul Spatz wrote: Now I have another question. If dunder methods are looked up only in the class, not the instance, why did defining

__getattr__ Confusion

2013-02-03 Thread Saul Spatz
To the good people on comp.lang.python: I have the following Tkinter class (python 2.7.3): from Tkinter import * class ScrolledCanvas(Frame): def __init__(self, master, width, height, bg, cursor): Frame.__init__(self, master) self.__nonzero__ = lambda: True canv = self.canvas =

[issue15772] Unresolved symbols in Windows 64-bit python

2012-08-23 Thread Saul Spatz
New submission from Saul Spatz: In trying to build a SWING module on Windows with 64-bit python, I get the linker errors listed at the bottom of this message. I have this problem with both python 2.7 and 3.2. I have built the project without problems on Windows with 32-bit python

[issue8271] str.decode('utf8', 'replace') -- conformance with Unicode 5.2.0

2012-05-17 Thread Saul Spatz
Saul Spatz saul.sp...@gmail.com added the comment: b'\xe0\x80'.decode('utf-8', 'replace') returns one U+FFFD and not two. I don't think that is right. I think that one U+FFFD is correct. The on;y error is a premature end of data. On Thu, May 17, 2012 at 12:31 PM, Serhiy Storchaka rep

pymysql only works under IDLE

2012-01-16 Thread Saul Spatz
I've been using pymysql to connect to a database, and it has suddenly stopped working on the one machine (a virtual server) where I really need it to work. I have a function with hard-coded parameters to do the connection, and now I'm getting an error that says, Can't connect to MySQL server

Re: pymysql only works under IDLE

2012-01-16 Thread Saul Spatz
Thanks a lot; I didn't know about sys.executable. For the record, IDLE is running pythonw.exe. I won't have a chance to test if this helps till tomorrow, unfortunately. -- http://mail.python.org/mailman/listinfo/python-list

Re: Validating Entry in tkinter

2011-07-25 Thread Saul Spatz
Thanks so much, this is great. I want to validate that the user is entering a string appropriate for bytes.fromhex. Here's how I modified your validate funtion: def validate(before, after): print(before, --, after) #return after.isdigit() return after[-1] in

Re: Validating Entry in tkinter

2011-07-25 Thread Saul Spatz
That doesn't work, I'm being stupid, The user might type anywhere in the string, not just at the end. I need return all([c in '1234567890abcdefABCDEF ' for c in after]) -- http://mail.python.org/mailman/listinfo/python-list

Re: Validating Entry in tkinter

2011-07-25 Thread Saul Spatz
Yes, the tuple is certainly easier to read. Thanks again. -- http://mail.python.org/mailman/listinfo/python-list

Re: Validating Entry in tkinter

2011-07-25 Thread Saul Spatz
Thanks, that a great link. -- http://mail.python.org/mailman/listinfo/python-list

Validating Entry in tkinter

2011-07-24 Thread Saul Spatz
In tcl/tk an Entry widget can be set to validate its contents with the validate option. You have to give it a validatecommand (vcmd), which is a tcl script that runs when some action triggers validation. Usually, the script would use percent substitutions so the script would be something like

Re: Validating Entry in tkinter

2011-07-24 Thread Saul Spatz
I want to interface to the native validation of tk. If you don't know what that is, you're unlikely to be able to help me. -- http://mail.python.org/mailman/listinfo/python-list

[issue8271] str.decode('utf8', 'replace') -- conformance with Unicode 5.2.0

2011-07-07 Thread Saul Spatz
Changes by Saul Spatz saul.sp...@gmail.com: -- nosy: +spatz123 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8271 ___ ___ Python-bugs-list mailing

[issue12508] Codecs Anomaly

2011-07-06 Thread Saul Spatz
New submission from Saul Spatz saul.sp...@gmail.com: The attached script produces the output 'A\ufffdBC\ufffd' 'A\ufffdBC' although it seems to me that both lines should be the same. The first line is correct, I think, since the F4 at the end is a maximal subpart of an ill-formed

Re: Unicode codepoints

2011-06-22 Thread Saul Spatz
Thanks. I agree with you about the generator. Using your first suggestion, code points above U+ get separated into two surrogate pair characters fron UTF-16. So instead of U=10 I get U+DBFF and U+DFFF. -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode codepoints

2011-06-22 Thread Saul Spatz
Thanks very much. This is the elegant kind of solution I was looking for. I had hoped there was a way to do it without even addressing the matter of surrogates, but apparently not. The reason I don't like this is that it depends on knowing that python internally stores strings in UTF-16. I

Unicode codepoints

2011-06-21 Thread Saul Spatz
Hi, I'm just starting to learn a bit about Unicode. I want to be able to read a utf-8 encoded file, and print out the codepoints it encodes. After many false starts, here's a script that seems to work, but it strikes me as awfully awkward and unpythonic. Have you a better way? def

Re: Tkinter/scrollbar/canvas question

2011-06-21 Thread Saul Spatz
It works if you change it like so: from tkinter import * class ShowList(Frame): def __init__(self, root): Frame.__init__(self, root) self.grid() self.draw_widgets() def draw_widgets(self): cframe = Frame(self)

Re: Tkinter/scrollbar/canvas question

2011-06-21 Thread Saul Spatz
This is the third time I've tried to post this reply. If you see multiple answers from me, that's why. Your script will work if you change it like so: from tkinter import * class ShowList(Frame): def __init__(self, root): Frame.__init__(self, root)

Re: Tkinter/scrollbar/canvas question

2011-06-21 Thread Saul Spatz
It works if you change it like so: from tkinter import * class ShowList(Frame): def __init__(self, root): Frame.__init__(self, root) self.grid() self.draw_widgets() def draw_widgets(self): cframe = Frame(self)

Where is the Demo Directory in Python 3.2?

2011-06-02 Thread Saul Spatz
The documentation refers to the Demo directory in the source. I've downloaded the source tarball for python 3.2 and there's no such directory. I downloaded the source for python 2.7 to check, and the Demo directory is present. Has the directory been moved, renamed or eliminated in 3.2?

Re: regexp matching end of line or comma

2010-11-25 Thread Saul Spatz
On Nov 25, 8:40 am, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Hy guys, I'm struggling matching patterns ending with a comma ',' or an end of line '$'. import re ex1 = 'sumthin,' ex2 = 'sumthin' m1 = re.match('(?Psomething\S+),', ex1) m2 = re.match('(?Psomething\S+)$', ex2) m3

PyQt Installation Problem on Windows

2010-11-24 Thread Saul Spatz
Hi, I've been trying to install PyQt on Windows XP Pro so that I can try out eric ide. I used the binary windows installer for PyQt. I can run eric as administrator, but not with my ordinary user account. By running eric.bat with the --debug flag, I found that he crux of the problem is that if

Double Clicking on .pyw File Doesn't Work in Windows 7

2010-10-05 Thread Saul Spatz
When I double-click on a file with a .pyw extension, nothing appears to happen. Control panel shows that pythonw is associated with this extension, and if I right-click on the filename, the program suggested to open it is pythonw.exe. If I make a desktop shortcut with the target pythonw.exe

Re: after_cancel?

2009-04-18 Thread Saul Spatz
W. eWatson wrote: I'm looking a program that I'm not real familiar with that uses an after_cancel method and after_id variable. Are they related to some particular widget and what is there function? Perhaps they are related to a Cancel button on a widget?

Problem with 3.0 Install on Windows

2009-01-20 Thread Saul Spatz
I'm running python 2.5.x on Windows XP, and I installed 3.0, just to get familiar with it. I have a directory with all my python projects in my PYTHONPATH variable. When I try to run python 3.0, it detects a syntax error (a print statement) in the first file in this directory, and crashes.

Re: How to write a simple shell loop in python?

2009-01-20 Thread Saul Spatz
Dietrich Bollmann wrote: Hi, I am trying to write a simple shell loop in Python. My simple approach works fine - but the first output line after entering something is always indented by one blank. Is there any logic explanation for this? How can I get rid of the blank? Is there a smarter

Re: recursion in Class-methods?

2008-06-26 Thread Saul Spatz
defn noob wrote: if start == end: return path if not self.dictionary.has_key(start): if start not in self.dictionnary: return None for node in self.dictionary[start]: if node not in path: newpath =

Re: Question: How do I format printing in python

2008-06-23 Thread Saul Spatz
format the strings: http://www.python.org/doc/2.1.3/lib/typesseq-strings.html [EMAIL PROTECTED] wrote: Hi All, How do I format printed data in python? I could not find this in the Python Reference Manual: http://docs.python.org/ref/print.html Nor could I find it in Matloff's great tutorial:

Re: Learning Python: Code critique please

2008-06-22 Thread Saul Spatz
macoovacany wrote: http://macoovacany.wordpress.com/ When I tried to run it, I got all kinds of syntax errors because of non-ASCII characters; namely, you have fancy left and right single and double quotes. Once I replaced these with the ASCII equivalents, it worked fine. I suggest you use a

Trying to Learn Packages

2008-06-22 Thread Saul Spatz
Hi, I'm making a project into my first package, mainly for organization, but also to learn how to do it. I have a number of data files, both experimental results and PNG files. My project is organized as a root directory, with two subdirectories, src and data, and directory trees below

Re: Trying to Learn Packages

2008-06-22 Thread Saul Spatz
Cédric Lucantis wrote: Le Sunday 22 June 2008 16:07:37 Saul Spatz, vous avez écrit : Hi, I'm making a project into my first package, mainly for organization, but also to learn how to do it. I have a number of data files, both experimental results and PNG files. My project is organized