Re: Fastest way to detect a non-ASCII character in a list of strings.

2010-10-17 Thread Stefan Behnel
Dun Peal, 17.10.2010 21:59: `all_ascii(L)` is a function that accepts a list of strings L, and returns True if all of those strings contain only ASCII chars, False otherwise. What's the fastest way to implement `all_ascii(L)`? My ideas so far are: 1. Match against a regexp with a character ran

Re: Fastest way to detect a non-ASCII character in a list of strings.

2010-10-17 Thread Albert Hopkins
On Sun, 2010-10-17 at 14:59 -0500, Dun Peal wrote: > `all_ascii(L)` is a function that accepts a list of strings L, and > returns True if all of those strings contain only ASCII chars, False > otherwise. > > What's the fastest way to implement `all_ascii(L)`? > > My ideas so far are: > > 1. Matc

ANN: dulce 0.1 - in-memory schema-less relational database

2010-10-17 Thread Paul McGuire
dulce is a syntactic "sweet" wrapper for managing collections of Python objects like relational tables. No schema definition is used; instead table columns are introspected from the attributes of objects inserted into the table, and inferred from index and query parameters. dulce's Tables can be:

Re: Fastest way to detect a non-ASCII character in a list of strings.

2010-10-17 Thread Steven D'Aprano
On Mon, 18 Oct 2010 01:04:09 +0100, Rhodri James wrote: > On Sun, 17 Oct 2010 20:59:22 +0100, Dun Peal > wrote: > >> `all_ascii(L)` is a function that accepts a list of strings L, and >> returns True if all of those strings contain only ASCII chars, False >> otherwise. >> >> What's the fastest w

Re: Fastest way to detect a non-ASCII character in a list of strings.

2010-10-17 Thread Tim Chase
On 10/17/10 19:04, Rhodri James wrote: import string return set("".join(L))<= set(string.printable) I've no idea whether this is faster or slower than any of your suggestions. For set("".join(L)) to return, it has to scan the entire input list/string. Imagine s = UNPRINTABLE_CHAR

Re: Fastest way to detect a non-ASCII character in a list of strings.

2010-10-17 Thread Carl Banks
On Oct 17, 12:59 pm, Dun Peal wrote: > `all_ascii(L)` is a function that accepts a list of strings L, and > returns True if all of those strings contain only ASCII chars, False > otherwise. > > What's the fastest way to implement `all_ascii(L)`? > > My ideas so far are: > > 1. Match against a rege

Re: Fastest way to detect a non-ASCII character in a list of strings.

2010-10-17 Thread Rhodri James
On Sun, 17 Oct 2010 20:59:22 +0100, Dun Peal wrote: `all_ascii(L)` is a function that accepts a list of strings L, and returns True if all of those strings contain only ASCII chars, False otherwise. What's the fastest way to implement `all_ascii(L)`? My ideas so far are: 1. Match against a r

Re: Fastest way to detect a non-ASCII character in a list of strings.

2010-10-17 Thread Seebs
On 2010-10-17, Dun Peal wrote: > What's the fastest way to implement `all_ascii(L)`? Start by defining it. > 1. Match against a regexp with a character range: `[ -~]` What about tabs and newlines? For that matter, what about DEL and BEL? Seems to me that the entire 0-127 range are "ASCII char

Re: Decorator question

2010-10-17 Thread Lucasm
On 16 Okt, 16:49, Peter Otten <__pete...@web.de> wrote: > Lucasm wrote: > > I have a decorator problem and hope someone is able to help me out/ > > assist me. Thanks in advance. > > > Suppose: > > ### Begin some_library_module ### > > > def some_decorator(some_method): > >     def inner(an_arg, *ar

Re: please help explain this result

2010-10-17 Thread Gregory Ewing
Yingjie Lan wrote: So, I assume that when the 'def' is executed, any name occurred will be categorized as either local or global (maybe nonlocal?). Actually it happens earlier than that -- the bytecode compiler does the categorization, and generates different bytecodes for accessing these thr

Re: How to implement retrying a lock tidily in Python?

2010-10-17 Thread Dave Angel
On 2:59 PM, tinn...@isbd.co.uk wrote: I'm writing some code that writes to a mbox file and want to retry locking the mbox file a few times before giving up. I can't see a really tidy way to implement this. Currently I have something like:- dest = mailbox.mbox(mbName, factory=None)

Re: please help explain this result

2010-10-17 Thread Paul Kölle
Am 17.10.2010 19:51, schrieb TomF: On 2010-10-17 10:21:36 -0700, Paul Kölle said: Am 17.10.2010 13:48, schrieb Steven D'Aprano: On Sun, 17 Oct 2010 03:58:21 -0700, Yingjie Lan wrote: Hi, I played with an example related to namespaces/scoping. The result is a little confusing: [snip example

Fastest way to detect a non-ASCII character in a list of strings.

2010-10-17 Thread Dun Peal
`all_ascii(L)` is a function that accepts a list of strings L, and returns True if all of those strings contain only ASCII chars, False otherwise. What's the fastest way to implement `all_ascii(L)`? My ideas so far are: 1. Match against a regexp with a character range: `[ -~]` 2. Use s.decode('a

Re: what difference does redirection make?

2010-10-17 Thread Benjamin Kaplan
On Sun, Oct 17, 2010 at 3:04 PM, Nikola Skoric wrote: > When I execute > n...@rilmir:~/code/simplepyged/docs/examples$ python latex.py > I get expected output (bunch of latex markup). > > But, when I add a redirection, I get: > n...@rilmir:~/code/simplepyged/docs/examples$ python latex.py > foo.te

Re: Reading Outlook .msg file using Python

2010-10-17 Thread John Henry
On Oct 17, 11:37 am, John Henry wrote: > On Oct 17, 4:45 am, Tim Golden wrote: > > > > > On 17/10/2010 6:39 AM, John Henry wrote: > > > > On Oct 12, 10:31 am, Tim Golden  wrote: > > >> On 12/10/2010 4:59 PM, John Henry wrote: > > > >>> According to: > > > >>>http://support.microsoft.com/kb/813745

what difference does redirection make?

2010-10-17 Thread Nikola Skoric
When I execute n...@rilmir:~/code/simplepyged/docs/examples$ python latex.py I get expected output (bunch of latex markup). But, when I add a redirection, I get: n...@rilmir:~/code/simplepyged/docs/examples$ python latex.py > foo.tex File "latex.py", line 87, in print mytemplate.render_uni

Re: How to implement retrying a lock tidily in Python?

2010-10-17 Thread tinnews
Matteo Landi wrote: > On Sun, Oct 17, 2010 at 6:58 PM, wrote: > > I'm writing some code that writes to a mbox file and want to retry > > locking the mbox file a few times before giving up.  I can't see a > > really tidy way to implement this. > > > > Currently I have something like:- > > > >    

Re: Reading Outlook .msg file using Python

2010-10-17 Thread John Henry
On Oct 17, 4:45 am, Tim Golden wrote: > On 17/10/2010 6:39 AM, John Henry wrote: > > > > > On Oct 12, 10:31 am, Tim Golden  wrote: > >> On 12/10/2010 4:59 PM, John Henry wrote: > > >>> According to: > > >>>http://support.microsoft.com/kb/813745 > > >>> I need to reset my Outlook registry keys.  Un

[ANNC] TZMud 0.9 : A Python MUD server

2010-10-17 Thread Lee Harr
TZMud is a Python MUD server. http://tzmud.googlecode.com/ A MUD is a text-based virtual environment accessed via telnet, or with a specialised MUD client. TZMud development is still in early stages, focusing on API and server stability. TZMud uses several high-quality Python libraries to facil

Re: How to implement retrying a lock tidily in Python?

2010-10-17 Thread Chris Torek
In article <4imro7-ds6@chris.zbmc.eu>, wrote: >I'm writing some code that writes to a mbox file and want to retry >locking the mbox file a few times before giving up. ... >dest = mailbox.mbox(mbName, factory=None) >for tries in xrange(3): >try: >dest.lock() >

Re: please help explain this result

2010-10-17 Thread TomF
On 2010-10-17 10:21:36 -0700, Paul Kölle said: Am 17.10.2010 13:48, schrieb Steven D'Aprano: On Sun, 17 Oct 2010 03:58:21 -0700, Yingjie Lan wrote: Hi, I played with an example related to namespaces/scoping. The result is a little confusing: [snip example of UnboundLocalError] Python's sco

Re: please help explain this result

2010-10-17 Thread Paul Kölle
Am 17.10.2010 13:48, schrieb Steven D'Aprano: On Sun, 17 Oct 2010 03:58:21 -0700, Yingjie Lan wrote: Hi, I played with an example related to namespaces/scoping. The result is a little confusing: [snip example of UnboundLocalError] Python's scoping rules are such that if you assign to a vari

Re: How to implement retrying a lock tidily in Python?

2010-10-17 Thread Matteo Landi
You can use the 'else' keyword outside the for loop: for : if : break else The execution will step inside the else branch if the for loop ends normally, i.e. without encountering a break keyword. Hope it helps. Regards, Matteo On Sun, Oct 17, 2010 at 6:58 PM, wrote: > I'm writing som

ANN: stats 0.1a calculator statistics for Python

2010-10-17 Thread Steven D'Aprano
I am pleased to announce the first public release of stats for Python. http://pypi.python.org/pypi/stats stats is a pure-Python module providing basic statistics functions similar to those found on scientific calculators. It currently includes: Univariate statistics including: * arithmetic, har

How to implement retrying a lock tidily in Python?

2010-10-17 Thread tinnews
I'm writing some code that writes to a mbox file and want to retry locking the mbox file a few times before giving up. I can't see a really tidy way to implement this. Currently I have something like:- dest = mailbox.mbox(mbName, factory=None) for tries in xrange(3): try:

pybsddb + python 2.7

2010-10-17 Thread Micky
Hi, I do have an ActivePython 2.7 installation (Win. XP) and some programm that has to read and write to a Berkeley DB. I read that starting from python version 2.6(?) pybsddb was deprecated. I dont understand the reason and I am looking to make this run. I found some pybsddb 4.8.4, but could n

ANN: PyGUI 2.3

2010-10-17 Thread Gregory Ewing
PyGUI 2.3 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ This version works on Snow Leopard with PyObjC 2.3. What is PyGUI? -- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. -- Gregory Ewing greg.ew...@can

Re: "Strong typing vs. strong testing"

2010-10-17 Thread Nick Keighley
On 10 Oct, 10:44, Lie Ryan wrote: > On 10/02/10 20:04, NickKeighleywrote: > >>> > > In a statically typed language, the of-the-wrong-type is something > >>> > > which > >>> > > can, by definition, be caught at compile time. > > >> > Any time something is true "by definition" that is an indicati

Re: please help explain this result

2010-10-17 Thread Yingjie Lan
--- On Sun, 10/17/10, Steven D'Aprano wrote: > (1) If you assign to a variable *anywhere* in the function, > it is a local > *everywhere* in the function. > > There is no way to have a variable refer to a local in some > places of a > function and a global in other places of the same functi

Re: please help explain this result

2010-10-17 Thread Yingjie Lan
> From: Nobody > The determination of local or global is made when the "def" > statement is > executed, not when the function is called. Thanks a lot for your reply, which is of great help! So, I assume that when the 'def' is executed, any name occurred will be categorized as either local or

Re: please help explain this result

2010-10-17 Thread Steven D'Aprano
On Sun, 17 Oct 2010 03:58:21 -0700, Yingjie Lan wrote: > Hi, > > I played with an example related to namespaces/scoping. The result is a > little confusing: [snip example of UnboundLocalError] Python's scoping rules are such that if you assign to a variable inside a function, it is treated as

Re: Reading Outlook .msg file using Python

2010-10-17 Thread Tim Golden
On 17/10/2010 6:39 AM, John Henry wrote: On Oct 12, 10:31 am, Tim Golden wrote: On 12/10/2010 4:59 PM, John Henry wrote: According to: http://support.microsoft.com/kb/813745 I need to reset my Outlook registry keys. Unfortunately, I don't have my Office Install CD with me. This would

Re: please help explain this result

2010-10-17 Thread Nobody
On Sun, 17 Oct 2010 03:58:21 -0700, Yingjie Lan wrote: > I played with an example related to namespaces/scoping. The result is a > little confusing: a=1 def f(): > a = a + 1 > return a > f() > UnboundLocalError: local variable 'a' referenced before assignment If you

Re: Spreadsheet-style dependency tracking

2010-10-17 Thread Florian Weimer
* Chris Torek: > In article <87y69xbz6h@mid.deneb.enyo.de> > Florian Weimer wrote: >>Are there libraries which implement some form of spreadsheet-style >>dependency tracking? The idea is to enable incremental updates to >>some fairly convoluted computation. I hope that a general dependency

please help explain this result

2010-10-17 Thread Yingjie Lan
Hi, I played with an example related to namespaces/scoping. The result is a little confusing: >>> a=1 >>> def f(): a = a + 1 return a >>> f() I suppose I will get 2 ( 'a' is redefined as a local variable, whose value is obtained by the value of the global variable 'a' plus 1)

Re: Starting Python in XP Pro

2010-10-17 Thread Dave Angel
On 10/16/2010 11:27 PM, Grant Andrew wrote: I hear that...God knows if I had a more complete question, I'd type it - basically, when I click the IDLE GUI icon from the Start Menu, there is a flash of a command prompt loading, then nothing happens. I've tried a number of things at the command pr

Re: Minimal D

2010-10-17 Thread Jonas H.
On 10/16/2010 06:04 PM, Kruptein wrote: Hey, I've written a small "IDE". It is written in python using the python toolkit and offers an advanced text-editor, file-manager, ftp-client, sql- client(in development) and more towards the future. You definitely want to have a look at PEP8. -- http:/

Package data distribution and installation

2010-10-17 Thread Alejandro Dubrovsky
I've got a script that is an executable and it reads template files that should be packaged with the script. How do I tell the script where to find the templates? In distutils, there's a package_data option, but that installs the templates under the /usr/lib/pythonX.XX/... directory, which se

Re: asyncore.poll() question

2010-10-17 Thread Von
The urlparse module is load only when this module run as main entry. Its for test purpose of modules. 2010/10/17, chad : > On Oct 16, 11:02 am, Felipe Bastos Nunes > wrote: >> You edited the source of asyncore.py puttin the print statments and >> nothing happend? It should work as the method is