On 22 Jul 2006, [EMAIL PROTECTED] wrote:
On Sat, 2006-07-22 at 14:11 +0100, John CORRY wrote:
Hi,
I am refactoring my code. I am trying to reduce the amount of lines
by using more loops. I tend to use copy and paste a lot instead of
writing a loop to do the work.
For example, I
On 25 Jun 2006, [EMAIL PROTECTED] wrote:
[...]
This code works as intended. Now my idea is to provide
an optional argument to the constructor. So I change
it to:
def __init__(self, q =[]):
self.queue = q
Now, something very strange happens:
a = Queue()
b = Queue()
On 24 Mai 2006, [EMAIL PROTECTED] wrote:
I have two Perl expressions
If windows:
perl -ple s/([^\w\s])/sprintf(q#%%%2X#, ord $1)/ge somefile.txt
If posix
perl -ple 's/([^\w\s])/sprintf(%%%2X, ord $1)/ge' somefile.txt
The [^\w\s] is a negated expression stating that any character
On 16 Mai 2006, [EMAIL PROTECTED] wrote:
Is there a way to leverage optionparser so it can accept input from both
command line and a configuration file?
Current code block is:
#
# Parse command line options and automatically build
# help/usage display
#
parser =
On 25 Apr 2006, [EMAIL PROTECTED] wrote:
[...]
Here's the list I'm starting with:
for i in rLst:
print i, type(i)
server001 alive 17.1% 2 requests/s 14805416 total type 'str'
server001 alive 27.2% 7 requests/s 14851125 total type 'str'
server002 alive 22.9%
On 7 Apr 2006, [EMAIL PROTECTED] wrote:
Sorry I didn't make my question clearer. Bascially I
want to replace this line:
srm:socket portNumber=138 tcpORudp=UDP
address=64.41.134.60/
With:
srm:socket portNumber=2 tcpORudp=TCP
address=64.41.134.60/
So the regex grouping are that I want
On 3 Apr 2006, [EMAIL PROTECTED] wrote:
I had several list comprehensions that I was mucking with; these lists
are working on a simple subclass of the built-in list object. They
looked liked this:
filelist = getFilesToAdd()
filelist2 = getFilesToDel()
adds = MyList('foo')
dels =
On 19 Mrz 2006, [EMAIL PROTECTED] wrote:
I had a feeling I could do this:
foo
[[1, 2, 3], [1, 2, 3], [1, 2, 3]]
for c in foo:
... for b in c:
... print b
...
1
2
3
1
2
3
1
2
3
Using a list comprehension, as it seemed to me like I was saying: b
I wouldn't use a
On 11 Mrz 2006, [EMAIL PROTECTED] wrote:
I'm trying to think of a way to sort a list of dictionaries. In pseudo-code:
l = [ { host:foo, db:bob},
{ host:foo, db:dave},
{ host:fee, db:henry}
]
l.sort( key = lambda item: item[host], second_key = lambda item: item[db])
On 9 Jun 2005, [EMAIL PROTECTED] wrote:
I'm switching over from email digests to a newsreader and I can't
find a reference for this tutor list.
For example, I have the lists comp.lang.python and
comp.lang.python.announce setup, but can't find something like
comp.lang.python.tutor?
On 6 Jun 2005, [EMAIL PROTECTED] wrote:
Hello, I'm having a bit of trouble resizing/reshaping an array of strings.
here's what I'm trying to do:
myString = ['hi','my','name','is','Jeff']
reshape(myString, (2,2))
What I get from this is something like:
[['h','i'],
On 16 Mai 2005, [EMAIL PROTECTED] wrote:
Thanks to all who helped me with my questions regarding testing for
commandline arguments and list assignment. I have finished my first
Python program (included below). It is slightly more secure than the
Perl program I rewrote, but also about a
On 14 Mai 2005, [EMAIL PROTECTED] wrote:
Here's the problem - I want a list (array) of the files in a directory,
and then I want to iterate over the list testing for image-ness (with
imghdr.what()) and put all the image filenames in a global list.
What I've tried is this:
files =
On 10 Mai 2005, [EMAIL PROTECTED] wrote:
I'm creating a small database using a dictionary of dictionaries, and I
want to output it to a file. It seems that only strings can be output to
files, and I cannot quite figure out how to quickly and simply convert my
dictionary to a list of
On 7 Mai 2005, [EMAIL PROTECTED] wrote:
I came across a rather odd issue with scoping. Can someone explain why
testa and testc works, but not testb. I am running under python 2.4.1 on
[...]
x = 5
def testa(astr):
print astr, x
testa(22)
def testb(astr):
x = x - 1
On 6 Mai 2005, [EMAIL PROTECTED] wrote:
The following test script is kind of got me baffled:
#!/usr/local/bin/python
class Eval:
def __getitem__(self,key):
return eval(key)
##def test():
## i = 100
## b = [My, name, is, Tim]
## test = this is number %(str(i))s for a test %('
On 6 Mai 2005, [EMAIL PROTECTED] wrote:
I tried to use the mailserver script in library reference to send
mails but it gives an error:The script and the error are below.Why
does it give this error?How can i fix?
[...]
ERROR:
Traceback (most recent call last):
File
On 3 Mai 2005, [EMAIL PROTECTED] wrote:
What would be the simplest way to extract the Month and Year for one month
prior to the current month? I have been looking for a way to create a Date
object with the current date, and then subtract a month from it. Say it is
currently January 1st,
On 1 Mai 2005, [EMAIL PROTECTED] wrote:
I'm trying to produce something of a similar structure to generate the
permutations of a sequence by translating the ffg bit of Haskell:-
perms [] = [[]]
perms xs = [ x : ps | x - xs , ps - perms ( xs\\[x]) ]
'\\' applies to lists means elements of
On 19 Mrz 2005, [EMAIL PROTECTED] wrote:
[Code]
Maybe sombody likes to compare these algorithms to the
ones mentioned before in this thread. I would be
interested in the results.
I did it and on my machine here (a slow one) the following straight
forward version is the fastest one.
It's no
On 13 Feb 2005, [EMAIL PROTECTED] wrote:
what's the Python way of accessing local variables in nesting functions? For
The way you want to work with closures the Python way is not to do it
but use a class to hold the state. That's sometimes sad but true.
example if I have:
def p():
var1
On 13 Feb 2005, [EMAIL PROTECTED] wrote:
Karl Pflästerer wrote on Sun, 13 Feb 2005 12:15:03 +0100:
what's the Python way of accessing local variables in nesting functions? For
I didn't wrote that; please quote correctly. Thanks.
Karl
--
Please do *not* send copies of replies to me
On 6 Feb 2005, [EMAIL PROTECTED] wrote:
Actually, generating the digits from the right complicates the algorithm quite
a bit. It's hidden in
the Python version, but s = str(i % 2) + s is a relatively expensive
operation here - it has to copy
all of s to make room for the new digit.
On 31 Jan 2005, [EMAIL PROTECTED] wrote:
I've got an issue that's been driving me a bit nuts. I'm sure it _can_
be done with a regexp, although I'm missing a piece needed to tie it
together to work for all cases.
I need to parse out a list of RPMs in this case, but it seems the RPM
On 31 Jan 2005, [EMAIL PROTECTED] wrote:
Slight correction which I realized after sending, see below for
version/release seperation, which I should have seen but blame lack of
sleep ;-)
corrected versions:
4.3.0
3.2.3d
3
5.42a
1.10
(new) releases:
On 26 Jan 2005, [EMAIL PROTECTED] wrote:
The following Python code works correctly; but I can't help but wonder if
my for loop is better implemented as something else: a list comprehension
or something else more Pythonic.
[Code]
w1 = Water(50,0)
w2 = Water(50,100)
On 19 Jan 2005, [EMAIL PROTECTED] wrote:
I have two lists:
1. Lseq:
len(Lseq)
30673
Lseq[20:25]
['NM_025164', 'NM_025164', 'NM_012384', 'NM_006380',
'NM_007032','NM_014332']
2. refseq:
len(refseq)
1080945
refseq[0:25]
['gi|10047089|ref|NM_014332.1| Homo sapiens small
muscle
On 28 Dez 2004, [EMAIL PROTECTED] wrote:
Though, of course, by modifying your way (using str() ), it will still work:
def listtoint(digits):
result = 0
for digit in digits:
result *= (10**len(str(digit))) ## just multiply it by 10
result += digit ## to the power of
28 matches
Mail list logo