pysqlite throwing exception?

2009-09-05 Thread william tanksley
I'm trying to modify an app I wrote a few months ago, but now it dies on startup (it worked before). The app loads the SQLite Media Monkey database, and crashes on its first query (when I try to get the number of podcasts). At the end of this post is a reduced version of the problem (which

Re: pysqlite throwing exception?

2009-09-05 Thread william tanksley
william tanksley wtanksle...@gmail.com wrote: Oh, this is Python 2.5 on Windows. New result: this works on Python 2.6. Obviously the SQLite format changed between the two runs. I'll call this problem solved; my app appears to run now. -Wm -- http://mail.python.org/mailman/listinfo/python-list

Re: pysqlite throwing exception?

2009-09-05 Thread william tanksley
MRAB pyt...@mrabarnett.plus.com wrote: I wonder whether it's complaining about the as count part because count is the name of a function, although you do say that the same query works elsewhere. Hey, good catch. Thanks; I'll change that. (It wasn't the problem, but no doubt someday it could

Re: Guido's new method definition idea

2008-12-08 Thread william tanksley
On Dec 5, 6:21 pm, Daniel Fetchinson [EMAIL PROTECTED] wrote: I'd like this new way of defining methods, what do you guys think? Anyone ready for writing a PEP? I think it's an awesome proposal. It's about time! With this change, defining methods uses the same special syntax hack that calling

Re: RegExp: wontmatch-function

2008-10-13 Thread william tanksley
On Oct 13, 9:40 am, [EMAIL PROTECTED] wrote: I'm looking for a function which, given a regexp re and  and a string str, returns whether re won't match any string starting with str. (so it would always return False if str is or if str itself matches re -- but that are only the easy cases).

Re: Bidirectional Generators

2008-08-04 Thread william tanksley
Paddy [EMAIL PROTECTED] wrote: What's one of them then? I'm sorry, I don't know what you mean. Meanwhile, more pertinently: I did get my generator working, and then I replaced it with a class that did the same thing in less than a quarter of the number of lines. So... I'm not going to worry

Re: Bidirectional Generators

2008-08-04 Thread william tanksley
Jeff [EMAIL PROTECTED] wrote: william tanksley [EMAIL PROTECTED] wrote: I'm still curious, though, whether anyone's written any code that actually uses yield _and_ send() to do anything that isn't in the original PEP. I have.  An iterator that could backtrack itself without the user

Re: Python parsing iTunes XML/COM

2008-08-01 Thread william tanksley
John Machin [EMAIL PROTECTED] wrote: william tanksley [EMAIL PROTECTED] wrote: Cool. Sorry for the misunderstanding. Thank you for helping again! Postscript: your request to print the actual data did the trick. I'd back inspecting actual data against armchair philosophy any time :-) Heh

Re: Python parsing iTunes XML/COM

2008-07-31 Thread william tanksley
Stefan Behnel [EMAIL PROTECTED] wrote: william tanksley wrote: Okay, my answer is that ElementTree (in Python 2.5) is simply deranged when it comes to Unicode. It assumes everything's ASCII. It does not assume that. It *requires* byte strings to be ASCII. You can't encode Unicode

Re: Python parsing iTunes XML/COM

2008-07-31 Thread william tanksley
John Machin [EMAIL PROTECTED] wrote: william tanksley [EMAIL PROTECTED] wrote: Buffett Time - Annual Shareholders\xc2\xa0L.mp3 1. This isn't Unicode; it's missing the u (I printed using repr). 2. It's got the UTF-8 bytes there in the middle. In addition to the above results, *WHAT

Re: Python parsing iTunes XML/COM

2008-07-31 Thread william tanksley
John Machin [EMAIL PROTECTED] wrote: william tanksley [EMAIL PROTECTED] wrote: Let's try again: Cool. Sorry for the misunderstanding. Thank you for helping again! Postscript: your request to print the actual data did the trick. I'm including the rest of my reply just to provide context

Re: Python parsing iTunes XML/COM

2008-07-30 Thread william tanksley
Thank you for the response. Here's some more info, including a little that you didn't ask me for but which might be useful. John Machin [EMAIL PROTECTED] wrote: william tanksley [EMAIL PROTECTED] wrote: To ask another way: how do I convert from a file:// URL to a local path in a standard way

Re: Python parsing iTunes XML/COM

2008-07-30 Thread william tanksley
Jerry Hill [EMAIL PROTECTED] wrote: william tanksley [EMAIL PROTECTED] wrote: Here's one example. The others are similar -- they have the same things that look like problems to me. Buffett Time - Annual Shareholders\xc2\xa0L.mp3 I tried doing track_id.encode(utf-8), but it doesn't seem

Re: Python parsing iTunes XML/COM

2008-07-30 Thread william tanksley
Jerry Hill [EMAIL PROTECTED] wrote: On Wed, Jul 30, 2008 at 2:27 PM, william tanksley [EMAIL PROTECTED] wrote: Awesome... Thank you! I had my mental model of Python turned around backwards. That's an odd feeling. Okay, so you decode to go from raw byes into a given encoding, and you encode

Re: Python parsing iTunes XML/COM

2008-07-30 Thread william tanksley
william tanksley [EMAIL PROTECTED] wrote: I'm still puzzled why I'm getting some non-Unicode out of an ElementTree's text, though. Now I know. Okay, my answer is that cElementTree (in Python 2.5) is simply deranged when it comes to Unicode. It assumes everything's ASCII. Reference: http

Re: Python parsing iTunes XML/COM

2008-07-29 Thread william tanksley
To ask another way: how do I convert from a file:// URL to a local path in a standard way, so that filepaths from two different sources will work the same way in a dictionary? Right now I'm using the following source: track_id = url2pathname(urlparse(track_id).path) url2pathname is from urllib;

Re: iterating by twos

2008-07-29 Thread william tanksley
kj [EMAIL PROTECTED] wrote: Is there a special pythonic idiom for iterating over a list (or tuple) two elements at a time? I don't know of one, and I shouldn't be answering, but the following should work: def gulp_two(items): for i,j in zip(items[0::2], items[1::2]): yield (i,j) Let's

Python parsing iTunes XML/COM

2008-07-28 Thread william tanksley
I'm trying to convert the URLs contained in iTunes' XML file into a form comparable with the filenames returned by iTunes' COM interface. I'm writing a podcast sorter in Python; I'm using iTunes under Windows right now. iTunes' COM provides most of my data input and all of my mp3/aac editing

Bidirectional Generators

2008-07-22 Thread william tanksley
Okay, I'm almost finished with my first bidirectional generator. By almost finished I mean both that it's almost working, and that I'm almost about to replace it with a class that works a bit more like what I currently understand. Surely some other people have worked with this feature... Are

Re: How to get an XML DOM while offline?

2008-03-31 Thread william tanksley
Diez B. Roggisch [EMAIL PROTECTED] wrote: The most pragmatic solution would be to rip the doctype out using simple string methods and/or regexes. Thank you, Diez and Paul; I took Diez's solution, and it works well enough for me. Diez -Wm --

How to get an XML DOM while offline?

2008-03-19 Thread william tanksley
I want to parse my iTunes Library xml. All was well, until I unplugged and left for the train (where I get most of my personal projects done). All of a sudden, I discovered that apparently the presence of a DOCTYPE in the iTunes XML makes xml.dom.minidom insist on accessing the Internet... So