Re: Questions about asyncore

2008-07-31 Thread Giampaolo Rodola'
On 31 Lug, 08:30, Frank Millman <[EMAIL PROTECTED]> wrote: > On Jul 30, 7:50 pm, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > > > On 30 Lug, 09:49, Frank Millman <[EMAIL PROTECTED]> wrote: > > Thanks again, Giampaolo, your input is really appreciated. > > > > > I pretty much have the same overv

Re: Python parsing iTunes XML/COM

2008-07-31 Thread John Machin
On Jul 31, 11:54 pm, william tanksley <[EMAIL PROTECTED]> wrote: > 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 g

Re: find and replace with regular expressions

2008-07-31 Thread Mensanator
On Jul 31, 3:07 pm, [EMAIL PROTECTED] wrote: > I am using regular expressions to search a string (always full > sentences, maybe more than one sentence) for common abbreviations and > remove the periods.  I need to break the string into different > sentences but split('.') doesn't solve the whole p

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Matthew Woodcraft
Steven D'Aprano wrote: >On Wed, 30 Jul 2008 20:55:03 +0100, Matthew Woodcraft wrote: >> On the other hand, iterators provide a clear example of problems with >> "if x": __nonzero__ for iterators (in general) returns True even if they >> are 'empty'. > How do you propose telling whether an iterato

Newbie having issues with threads

2008-07-31 Thread James Calivar
I'm a newbie trying to write a script that uses threads. I'm right now a little bit stuck in understanding why the code snippet I wrote doesn't seem to be entering the function defined in the start_new_thread() call. If I run it as is (the threaded version), the output is: UA_1 configuring... UA

Re: Non Continuous Subsequences

2008-07-31 Thread Kay Schluehr
Here is an evil imperative, non-recursive generator: def ncsub(seq): n = len(seq) R = xrange(n+1) for i in xrange(1,2**n): S = [] nc = False for j in R: k = i>>j if k == 0: if nc: yield S

Re: find and replace with regular expressions

2008-07-31 Thread Mensanator
On Jul 31, 3:56 pm, Mensanator <[EMAIL PROTECTED]> wrote: > On Jul 31, 3:07 pm, [EMAIL PROTECTED] wrote: > > > > > > > I am using regular expressions to search a string (always full > > sentences, maybe more than one sentence) for common abbreviations and > > remove the periods.  I need to break th

saving an e-mail attachement

2008-07-31 Thread robinsiebler
I'm trying to figure out how to save an e-mail attachment from a POP3 mailbox. I've scoured the web, but -none- of the examples I have found have actually worked. For instance, in this example: http://groups.google.com/group/comp.lang.python/browse_thread/thread/8423cad79ff21730/0d8922943a164ccf?

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, b

Re: Python parsing iTunes XML/COM

2008-07-31 Thread Jerry Hill
On Thu, Jul 31, 2008 at 9:44 AM, william tanksley <[EMAIL PROTECTED]> wrote: > I'm using a file, a file that's correctly encoded as UTF-8, and it > returns some text elements that are raw bytes (undecoded). I have to > manually decode them. I can't reproduce this behavior. Here's a simple test ca

Re: Standard module for parsing emails?

2008-07-31 Thread Steven D'Aprano
On Thu, 31 Jul 2008 02:25:37 +, Steven D'Aprano wrote: > On Wed, 30 Jul 2008 07:11:45 -0700, Phillip B Oldham wrote: > >> Most clients use ">" which is easy to check for, but I've seen some >> which use "|" and some which *don't* quote at all. Its causing us >> nightmares in parsing responses

Re: Difference between type and class

2008-07-31 Thread Steven D'Aprano
On Thu, 31 Jul 2008 13:32:39 +0200, Thomas Troeger wrote: >> Can someone explain to me the difference between a type and a class? > > If your confusion is of a more general nature I suggest reading the > introduction of `Design Patterns' (ISBN-10: 0201633612), under > `Specifying Object Interface

Re: Difference between type and class

2008-07-31 Thread Miles
On Thu, Jul 31, 2008 at 1:59 PM, Nikolaus Rath wrote: > If it is just a matter of different rendering, what's the reason for > doing it like that? Wouldn't it be more consistent and straightforward > to denote builtin types as classes as well? Yes, and in Python 3, it will be so: >>> class myint(

Re: find and replace with regular expressions

2008-07-31 Thread Paul McGuire
On Jul 31, 3:07 pm, [EMAIL PROTECTED] wrote: > > middle_abbr = re.compile('[A-Za-z0-9]\.[A-Za-z0-9]\.') > When defining re's with string literals, it is good practice to use the raw string literal format (precede with an 'r'): middle_abbr = re.compile(r'[A-Za-z0-9]\.[A-Za-z0-9]\.') What abbre

Re: How smart is the Python interpreter?

2008-07-31 Thread Steven D'Aprano
On Thu, 31 Jul 2008 04:09:57 -0700, ssecorp wrote: > def str_sort(string): > s = "" > for a in sorted(string): > s+=a > return s > > > if i instead do: > > def str_sort(string): > s = "" > so = sorted(string) > for a in so: > s+=

Re: simple problem with lists I am just forgetting

2008-07-31 Thread Paul McGuire
On Jul 31, 2:51 pm, Alexnb <[EMAIL PROTECTED]> wrote: > Lets say we have this list: > > funlist = ['a', 'b', 'c'] > > and lets say I do this: > > if funlist[4]: >     print funlist[4] > > I will get the exception "list index out of range" > > How can I test if the list item is empty without getting

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Steven D'Aprano
On Thu, 31 Jul 2008 22:01:48 +0100, Matthew Woodcraft wrote: > Steven D'Aprano wrote: >>On Wed, 30 Jul 2008 20:55:03 +0100, Matthew Woodcraft wrote: > >>> On the other hand, iterators provide a clear example of problems with >>> "if x": __nonzero__ for iterators (in general) returns True even if

Re: Attack a sacred Python Cow

2008-07-31 Thread Paul McGuire
On Jul 28, 12:15 pm, Kay Schluehr <[EMAIL PROTECTED]> wrote: > On 28 Jul., 06:42, "Russ P." <[EMAIL PROTECTED]> wrote: > > > > > > > On Jul 27, 8:58 pm, castironpi <[EMAIL PROTECTED]> wrote: > > > > On Jul 27, 2:39 pm, Bruno Desthuilliers > > > > <[EMAIL PROTECTED]> wrote: > > > > Derek Martin a éc

Re: Python parsing iTunes XML/COM

2008-07-31 Thread John Machin
On Aug 1, 7:44 am, william tanksley <[EMAIL PROTECTED]> wrote: > 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 d

Problem with pyodbc, Python?

2008-07-31 Thread john.goodleaf
I've just built pyodbc 2.0.58 against freetds and unixodbc. When I attempt to invoke it, either from the test script or from the interpreter, I get: ImportError: build/lib.linux-x86_64-2.5/pyodbc.so: undefined symbol: PyUnicodeUCS2_Resize I'm not quite sure how to go about troubleshooting this. M

Re: find and replace with regular expressions

2008-07-31 Thread MRAB
On Jul 31, 9:07 pm, [EMAIL PROTECTED] wrote: > I am using regular expressions to search a string (always full > sentences, maybe more than one sentence) for common abbreviations and > remove the periods.  I need to break the string into different > sentences but split('.') doesn't solve the whole p

Re: Function References

2008-07-31 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: On Jul 31, 10:47 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: I take the freedom to do so as I see fit - this is usenet... Fine, then keep beating a dead horse by replying to this thread with things that do nobody any good. It seems like there are a lot better w

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Matthew Woodcraft
Steven D'Aprano wrote: >On Thu, 31 Jul 2008 22:01:48 +0100, Matthew Woodcraft wrote: >> The point is that if you tell people that "if x" is the standard way to >> check for emptiness, and also support a general principle along the >> lines of "write your function using the interfaces you expect, an

Decoding an attachment

2008-07-31 Thread robinsiebler
I figured out how to save an e-mail message as a text file, but I'm not sure how to decode the encoded part as I am not sure how much I need to include to decode it properly. Here is what a message looks like: Received: from INGESTOR2SQA ([10.220.83.198]) by sqaserver300 with Microsoft SMTPSVC(6

when does the GIL really block?

2008-07-31 Thread Craig Allen
I have followed the GIL debate in python for some time. I don't want to get into the regular debate about if it should be gotten rid of (though I am curious about the status of that for Python 3)... personally I think I can do multi-threaded programming well, but I also see the benefits of a multi

Re: Non Continuous Subsequences

2008-07-31 Thread bearophileHUGS
Kay Schluehr: >[Yes, I have too much time...] Thank you for your code. If you allow me to, I may put some code derived from yours back into the rosettacode.org site. >Here is an evil imperative, non-recursive generator: I like imperative, non-recursive code :-) If you count the number of item

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Carl Banks
On Jul 31, 1:27 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > I'm really not sure where you're going with this or what you're trying > to prove. "if x" is a duck-type test for a boolean value. Obviously if > you know the type and want a more *specific* test, then you can use an > explicit one. An

Re: win32com ChartObject pythonwin vs idle

2008-07-31 Thread Roger Upole
"sterling" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm curious as to why the difference between IDLE and pythonWin when > using win32com. > opening an excel file, i've attempted to grab the chart information > out of the file. > > commands like co = ChartObjects(1) works in

Re: Decoding an attachment

2008-07-31 Thread Terry Reedy
[EMAIL PROTECTED] wrote: I figured out how to save an e-mail message as a text file, but I'm not sure how to decode the encoded part as I am not sure how much I need to include to decode it properly. Here is what a message looks like: The email.parser and email.message modules will do this fo

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Carl Banks
On Jul 31, 12:13 am, Ethan Furman <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > So I stand by the point I was trying to make: for your average day-to- > > day programming, the main benefit of "if x" is to save keystrokes. It > > doesn't help your code become more polymophic in practice. A li

Re: Genital Hair Removal

2008-07-31 Thread Paul McGuire
On Jul 31, 10:40 pm, "dr.jonver" <[EMAIL PROTECTED]> wrote: > Genital Hair Removal > http://misspelled_words_in_URLs_are_funny.blogspot.com/2008/07/genital-hair-removal.html Python provides the del command, as in: del self.genital_hair If "Genital Hair" is an element in a list, you can remo

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Carl Banks
On Jul 30, 10:05 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Russ P. wrote: > > On Jul 30, 1:07 am, Erik Max Francis <[EMAIL PROTECTED]> wrote: > >> Russ P. wrote: > >>> Oh, Lordy. I understand perfectly well how boolean tests, __len__, and > >>> __nonzero__ work in Python. It's very basic st

Re: How smart is the Python interpreter?

2008-07-31 Thread Terry Reedy
ssecorp wrote: def str_sort(string): s = "" for a in sorted(string): s+=a return s if i instead do: def str_sort(string): s = "" so = sorted(string) for a in so: s+=a return s will that be faster or the

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Carl Banks
On Jul 31, 11:44 pm, Carl Banks <[EMAIL PROTECTED]> wrote: [snip excellent explanation of why it's hard to for "if x" to be extensively polymorphic] By the way, one thing I forgot to mention is Matt Fitzgibbons' filter example. As I said, it's hard to write code that works for both numeric and c

Re: interpreter vs. compiled

2008-07-31 Thread Terry Reedy
Duncan Booth wrote: Terry Reedy <[EMAIL PROTECTED]> wrote: 1. Portability: The Microsoft C# JIT compiler runs under Windows .NET on x86/amd64 and maybe it64 and what else? Just porting .NET to run 0n Linux on the same processors was/is a bit task. Does MONO have a JIT also? Technically t

Re: HELP - Attribute Error, no matter what I do on PAMIE...

2008-07-31 Thread alex23
On Aug 1, 1:00 am, frankrentef <[EMAIL PROTECTED]> wrote: > Greetings all. I'm new to PAMIE and I've watched / followed to PAMIE > videos on Show me Do. I've tried to duplicate the "scriptWrite" > function in an attempt to automate the forms process... without > success. I haven't seen the video,

Re: Optimizing size of very large dictionaries

2008-07-31 Thread Terry Reedy
Raymond Hettinger wrote: Background: I'm trying to identify duplicate records in very large text based transaction logs. I'm detecting duplicate records by creating a SHA1 checksum of each record and using this checksum as a dictionary key. This works great except for several files whose size

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Erik Max Francis
Carl Banks wrote: If you recall, I agreed with his statement. Would you like to claim that I don't understand the fundamentals of Python? Since you've invented this connection out of nowhere, not particularly. I've never said anything about _anyone_ not understanding the fundamentals of Py

Re: interpreter vs. compiled

2008-07-31 Thread castironpi
On Jul 31, 1:17 am, Tim Roberts <[EMAIL PROTECTED]> wrote: > castironpi <[EMAIL PROTECTED]> wrote: > > >In C, we have: > > >int x, y; > >x= 10; > >y= x+ 1; > > >It translates as, roughly: > > >8000 .data > >7996 #x > >7992 #y > >7988 .end data > >7984 loadi reg0 7996 > >7980 loadi

Re: Questions about asyncore

2008-07-31 Thread Frank Millman
On Jul 31, 10:39 pm, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > On 31 Lug, 08:30, Frank Millman <[EMAIL PROTECTED]> wrote: > > > I don't know why you find more convenient running asyncore.loop in a > separate thread but if your purpose is writing a test suite in which a > client checks respon

Re: how to split text into lines?

2008-07-31 Thread alex23
Chris wrote: > or what about 'string'.splitlines(True) as that retains newline > characters. ;) Okay, you win :) Man, you'd think with the ease of object introspection I'd have at least looked at its docstring :) Cheers, Chris! -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between type and class

2008-07-31 Thread Nikolaus Rath
Miles <[EMAIL PROTECTED]> writes: > On Thu, Jul 31, 2008 at 1:59 PM, Nikolaus Rath wrote: >> If it is just a matter of different rendering, what's the reason for >> doing it like that? Wouldn't it be more consistent and straightforward >> to denote builtin types as classes as well? > > Yes, and in

Re: Difference between type and class

2008-07-31 Thread Nikolaus Rath
Steven D'Aprano <[EMAIL PROTECTED]> writes: > So, to the Original Poster: > > In Python, new-style classes and types are the same, but it is > traditional to refer to customer objects as "class" and built-in > objects as "types". Old-style classes are different, but you are > discouraged from using

py2exe bug with email.MIMEText

2008-07-31 Thread Marcus.CM
There is a bug with py2exe when (at least under windows) when importing email # example testmime.py import email msg = email.MIMEText.MIMEText("dsafdafdasfA") print "ok" 1. Save the text above and setup as testmime.py 2. Run it and u can see "ok" 3. Create setup.py and run : python setup.py py

Re: py2exe bug with email.MIMEText

2008-07-31 Thread Marcus.CM
Hi, After some debugging, i found the solution is to :- import email import email.mime.text import email.iterators import email.generator import email.utils Marcus. Marcus.CM wrote: There is a bug with py2exe when (at least under windows) when importing email # example testmime.py import e

Re: like py2exe, but on a mac

2008-07-31 Thread Python.Arno
oops didn't send it to the list... On 31 jul 2008, at 23:28, Python.Arno wrote: On 30 jul 2008, at 20:48, William McBrine wrote: On Wed, 30 Jul 2008 16:57:35 +, I wrote: [bundlebuidler] does put in a version-specific #! line, but if I change that to #!/usr/bin/env python, the app stil

<    1   2