Re: Convert from numbers to letters

2005-05-19 Thread Gary Wilson Jr
Bill Mill wrote: > On 5/19/05, Peter Otten <[EMAIL PROTECTED]> wrote: > >>Bill Mill wrote: >> >> Traceback (most recent call last): File"",line1,in? NameError: name 'sorted' is not defined I think you're probably using 2.4 ?? >>> >>>Yes, sorted() is new in python 2.4 .You coul

Re: Convert from numbers to letters

2005-05-19 Thread Gary Wilson Jr
Gary Wilson Jr wrote: > alpha = 'abcdefghijklmnopqrstuvwxyz'.upper() > pairs = [x for x in alpha] + [''.join((x,y)) for x in alpha for y in alpha] I forget, is string concatenation with '+' just as fast as join() now (because that would look even nicer)

PAM authentication?

2005-05-24 Thread Gary Wilson Jr
I would like my application to be able to authenticate through PAM. Is there any code out there that implements this? All I could find was PyPAM (http://www.pangalactic.org/PyPAM/), which doesn't look like it has been touched in almost 6 years and requires python1.5. -- http://mail.python.org/mai

__init__.py in packages

2005-06-08 Thread Gary Wilson Jr
I'm creating a python package foo. What is intended use for __init__.py files? Well, I found this: http://www.python.org/doc/essays/packages.html >From what I can gather it is for initialization of the package when doing an import, but I would really like to see an example or situation that makes

Re: Perl s/ To Python?

2005-06-10 Thread Gary Wilson Jr
John Abel wrote: > Does anyone know of a quick way of performing this: > > $testVar =~ s#/mail/.*$##g Use the re (regular expression) module. Since you are iterating over a lot of entries, it is good to compile the regular expression outside of the loop. >>> import re >>> mailRE = re.compile('/

Re: Set/Get attribute syntatic sugar

2005-06-28 Thread Gary Wilson Jr
Заур Шибзухов wrote: > There is a syntactic sugar for item access in > dictionaries and sequences: > > o[e] = v <-> o.__setitem__(e, v) > o[e] <-> o.__getitem__(e) > > where e is an expression. > > There is no similar way for set/get attribute for objects. > If e is a given name, then > >

trying to use swig for the first time

2006-01-23 Thread Gary Wilson Jr
...I have some C code (foo.c and foo.h) that I would like to be able to access using python. I've written my interface file (foo.i) like so: %module foo %{ #include "foo.h" %} %include "foo.h" I then do the following on the command line: $ swig -python foo.i $ gcc -c foo.c foo_wrap.c -I /usr/inc

Re: Cleaning strings with Regular Expressions

2005-09-08 Thread Gary Wilson Jr
sheffdog wrote: > Using regular expressions, the best I can do so far is using the re.sub > command but it still takes two lines. Can I do this in one line? Or > should I be approaching this differently? All I want to end up with is > the file name "ppbhat.tga". A regular expression to do what you

Re: My First Python Script

2005-09-16 Thread Gary Wilson Jr
Ed Hotchkiss wrote: > def ZeroThrough255(): > x = 0 > while x <= 255: > if len(x) == 1: > mySet = '00' + str(x) > elif len(x) == 2: > mySet = '0' + str(x) > else: > mySet = x >