Re: Handling NameError in a list gracefully

2009-04-20 Thread Jesse Aldridge
On Apr 20, 3:46 pm, Chris Rebert wrote: > On Mon, Apr 20, 2009 at 1:36 PM, Jesse Aldridge > wrote: > > from my_paths import * > > > def get_selected_paths(): > >    return [home, desktop, project1, project2] > > > --- > > > So I have a functio

Re: Handling NameError in a list gracefully

2009-04-20 Thread Jesse Aldridge
Nevermind, I figured it out right after I clicked the send button :\ from my_paths import * def get_selected_paths(): return [globals()[s] for s in ["home", "desktop", "project1", "project2"] if s in globals()] -- http://mail.python.org/mailman/listinfo/python-list

Handling NameError in a list gracefully

2009-04-20 Thread Jesse Aldridge
from my_paths import * def get_selected_paths(): return [home, desktop, project1, project2] --- So I have a function like this which returns a list containing a bunch of variables. The real list has around 50 entries. Occasionally I'll remove a variable from my_paths and cause get_sele

Re: regex alternation problem

2009-04-17 Thread Jesse Aldridge
On Apr 17, 5:30 pm, Paul McGuire wrote: > On Apr 17, 5:28 pm, Paul McGuire wrote:> -- Paul > > > Your find pattern includes (and consumes) a leading AND trailing space > > around each word.  In the first string "I am an american", there is a > > leading and trailing space around "am", but the tra

regex alternation problem

2009-04-17 Thread Jesse Aldridge
import re s1 = "I am an american" s2 = "I am american an " for s in [s1, s2]: print re.findall(" (am|an) ", s) # Results: # ['am'] # ['am', 'an'] --- I want the results to be the same for each string. What am I doing wrong? -- http://mail.python.org/mailman/listinfo/python-list

Re: Can someone explain this behavior to me?

2009-02-27 Thread Jesse Aldridge
Ah, I get it. Thanks for clearing that up, guys. -- http://mail.python.org/mailman/listinfo/python-list

Can someone explain this behavior to me?

2009-02-26 Thread Jesse Aldridge
I have one module called foo.py - class Foo: foo = None def get_foo(): return Foo.foo if __name__ == "__main__": import bar Foo.foo = "foo" bar.go() - And another one called bar.py - import foo def go(): assert f

Put the output from all my programs in one place

2008-09-01 Thread Jesse Aldridge
I want to put all the output from all of my python programs in one place. I've been trying to get this working for the last few days, but there are lots of annoying little details that are making the process quite difficult. I'm wondering if anyone can help me get this working. Currently I have o

dynamic method question

2008-06-12 Thread Jesse Aldridge
So in the code below, I'm binding some events to a text control in wxPython. The way I've been doing it is demonstrated with the Lame_Event_Widget class. I want to factor out the repeating patterns. Cool_Event_Widget is my attempt at this. It pretty much works, but I have a feeling there's a be

Best way to modify code without breaking stuff.

2008-06-04 Thread Jesse Aldridge
I've got a module that I use regularly. I want to make some extensive changes to this module but I want all of the programs that depend on the module to keep working while I'm making my changes. What's the best way to accomplish this? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Data Utils

2008-04-07 Thread Jesse Aldridge
> But then you introduced more. oops. old habits... > mxTextTools. This looks cool, so does the associated book - "Text Processing in Python". I'll look into them. > def normalise_whitespace(s): >     return ' '.join(s.split()) Ok, fixed. > a.replace('\xA0', ' ') in there somewhere. Added.

Re: Python Data Utils

2008-04-06 Thread Jesse Aldridge
> Docstrings go *after* the def statement. Fixed. > changing "( " to "(" and " )" to ")". Changed. I attempted to take out everything that could be trivially implemented with the standard library. This has left me with... 4 functions in S.py. 1 one of them is used internally, and the others a

Re: Python Data Utils

2008-04-06 Thread Jesse Aldridge
On Apr 6, 6:14 am, "Konstantin Veretennicov" <[EMAIL PROTECTED]> wrote: > On Sun, Apr 6, 2008 at 7:43 AM, Jesse Aldridge <[EMAIL PROTECTED]> wrote: > > In an effort to experiment with open source, I put a couple of my > >  utility files up http://github.com

Re: Python Data Utils

2008-04-06 Thread Jesse Aldridge
Thanks for the detailed feedback. I made a lot of modifications based on your advice. Mind taking another look? > Some names are a bit obscure - "universify"? > Docstrings would help too, and blank lines I changed the name of universify and added a docstrings to every function. > ...PEP8 I ma

Python Data Utils

2008-04-05 Thread Jesse Aldridge
In an effort to experiment with open source, I put a couple of my utility files up http://github.com/jessald/python_data_utils/ tree/master">here. What do you think? -- http://mail.python.org/mailman/listinfo/python-list

Re: Weird cgi error

2008-02-25 Thread Jesse Aldridge
> This is some kind of crooked game, right? Your code works fine on a > local server, and there's no reason why it shouldn't work just fine on > yours either. All you are changing is the standard input to the process. > > Since you claim to have spotted this specific error, perhaps you'd like > to

Re: Weird cgi error

2008-02-25 Thread Jesse Aldridge
On Feb 25, 11:42 am, Jesse Aldridge <[EMAIL PROTECTED]> wrote: > > If you cant have access to the apache (?) error_log, you can put this in > > your code: > > import cgitb > > cgitb.enable() > > > Which should trap what is being writed on the error

Re: Weird cgi error

2008-02-25 Thread Jesse Aldridge
> If you cant have access to the apache (?) error_log, you can put this in > your code: > import cgitb > cgitb.enable() > > Which should trap what is being writed on the error stream and put it on > the cgi output. > > Gerardo I added that. I get no errors. It still doesn't work. Well, I do ge

Weird cgi error

2008-02-24 Thread Jesse Aldridge
I uploaded the following script, called "test.py", to my webhost. It works find except when I input the string "python ". Note that's the word "python" followed by a space. If I submit that I get a 403 error. It seems to work fine with any other string. What's going on here? Here's the script i