On 2 Sep 2006, [EMAIL PROTECTED] wrote:
>
> Hello all. I post this here since is my first attempt to solve a
> problem with python.
>
> I have fairly big log files that I'm doing some pre-processing to, to
> cleanup the data before they go into a MySQL database. After
> processing the files
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
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 =
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 th
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
> #
> pars
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
> server001 alive 27.2% 7 requests/s 14851125 total
> server002 alive 22.9% 6 requ
On 7 Apr 2006, [EMAIL PROTECTED] wrote:
> Sorry I didn't make my question clearer. Bascially I
> want to replace this line:
>
> address="64.41.134.60"/>
>
> With:
>
> address="64.41.134.60"/>
>
> So the regex grouping are that I want to keep
> portNumber= and tcpORudp= and replace the values.
>
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')
>
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 sayi
On 17 Mrz 2006, [EMAIL PROTECTED] wrote:
> As you see, the problem is that there is another
> directory under testFiles called testDir, but the
> function doesn't check the directory for files. The
> function needs to find every directory (including
> subdirectories within directories). Any hint
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_
On 22 Feb 2006, [EMAIL PROTECTED] wrote:
> my code:
> ..
> .
> import sys, types, string, inspect
>
> input= sys.argv[1]
> print inspect.ismodule(input)
>
>
> here it always give false. as what ever input i take it is string .
>
> my problem is i am not able to take inp
On 8 Okt 2005, [EMAIL PROTECTED] wrote:
> Class SomeClass:
>def __init__(self,a,b):
> self.a = a
> self.b = b
>
>def report(self):
> for i in dir(self):
> print self.i
>
>
>
>
> This is where I run into problems: How do I return all of the variables
> in an in
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.tuto
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 t
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 = glo
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 7 Mai 2005, [EMAIL PROTECTED] wrote:
> It's clear that your code is a more elegant implementation of
> neverEndingStatus() but I am still having to initialize a global variable
> and call .next() when I want to get the next value... So the generator
> function has been cleaned up, but the clie
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 "D:\Python23\
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)
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 ele
On 23 Mrz 2005, [EMAIL PROTECTED] wrote:
> map is (probably) going to be removed in Python3000 :-( So it's
> probably better to not get into the habit of using it.
Au contraire. If enough people use it and are used using it the risk
for `map' getting removed will be a lot lower. Furthermore t
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:
>
> 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*
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():
>
On 11 Feb 2005, [EMAIL PROTECTED] wrote:
>> FOR THE LOVE OF MIKE can someone tell me even one reason why this
>> isn't a misfeature?!?!
> Its the only sane way to implement default arguments. The whole
> point of function definitions is that they provide a single concise
> interface. The funct
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 dig
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) rel
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 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,
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
On 13 Jan 2005, [EMAIL PROTECTED] wrote:
> My list looks like this: List name = probe_pairs
> Name=AFFX-BioB-5_at
> Cell1=96 369 N control AFFX-BioB-5_at
> Cell2=96 370 N control AFFX-BioB-5_at
> Cell3=441 3 N control AFFX-BioB-5_at
> Cell4=441 4
On 28 Dez 2004, [EMAIL PROTECTED] wrote:
> Karl,
> The ''.join() method was the first one suggested. Roel then suggested
> a math-based method, which I attempted to improve upon.
I know. I read it all; ''.join() was suggested together with a list
comprehension (in such simple situations map() is
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
On 9 Dez 2004, [EMAIL PROTECTED] wrote:
> I have a list of dictionaries, each representing info about a file,
> something like:
>
> [{'name':'foo.txt','size':35}, {'name':'bar.txt','size':35}, ...]
>
> I want to present a sorted list of all the files' data, sorting on the
> keys 'name' or 'size'.
On 7 Dez 2004, [EMAIL PROTECTED] wrote:
> I have two lists names x and seq.
>
> I am trying to find element of x in element of seq. I
> find them. However, I want to print element in seq
> that contains element of x and also the next element
> in seq.
[...]
> 3. TRIAL 3:
> I just asked to prin
39 matches
Mail list logo