Re: It's ...

2009-06-25 Thread Kirk Strauser
they are garbage collected (although I can't make myself not close output files after years of doing so), and map() is largely deprecated in favor of list comprehensions and generator functions. -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo/python-list

Re: tricky nested list unpacking problem

2008-12-15 Thread Kirk Strauser
unpack([1,2,3,5,[7,8,9]]) and unpack([1,2,3,6,[7,8,9]]), compile the results, and return them. -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo/python-list

Re: tricky nested list unpacking problem

2008-12-15 Thread Kirk Strauser
] '-'.join(str(num) for num in flattened) '1-2-3-5-6-10-11-7-9-1-2-3-4-5' He doesn't want to flatten them directly. He's using [1,2,3] sort of like a regular expression, so that 1,[2,3],4 means 1,2,4 or 1,3,4, not 1,2,3,4. -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo

Re: newbie question: if var1 == var2:

2008-12-12 Thread Kirk Strauser
writing the inline version of chomp every time I iterate across a file. -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo/python-list

Re: Removing None objects from a sequence

2008-12-12 Thread Kirk Strauser
is actually surprising to me, since not None is True. 0 is True is False, but 0 is not None is True. Why is that? -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo/python-list

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Kirk Strauser
): for threshold, rate in ((10, .0173), (5, .0149), (25000, .0124), (1, .0085), (0, .006)): if balance threshold: return rate return .0 -- Kirk Strauser The Day

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Kirk Strauser
reversing the order Actually, I just wanted to point out a simplified version of the exact same algorithm. Given enough RAM and if the speed was indeed critical, you could turn that into a tuple of interest rates and jump straight to rate[balance] in O(1). -- Kirk Strauser The Day Companies -- http

Re: newbie question: if var1 == var2:

2008-12-11 Thread Kirk Strauser
if those are important to you. -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo/python-list

Re: Do more imported objects affect performance

2008-12-11 Thread Kirk Strauser
to call a function that many times, you can do something like: import timeit Timer = timeit.Timer for _ in xrange(100): Timer -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie question: if var1 == var2:

2008-12-11 Thread Kirk Strauser
At 2008-12-11T17:24:44Z, rdmur...@bitdance.com writes: ' ab c \r\n'.rstrip('\r\n') ' ab c ' ' ab c \n'.rstrip('\r\n') ' ab c ' ' ab c '.rstrip('\r\n') ' ab c ' I didn't say it couldn't be done. I just like the Perl version better. -- Kirk Strauser

Re: newbie question: if var1 == var2:

2008-12-11 Thread Kirk Strauser
At 2008-12-11T19:49:23Z, Steve Holden st...@holdenweb.com writes: ... and it's so hard to write item = item[:-1] It's easy - and broken. Bad things happen if you're using something other than '\n' for EOL. -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo

Re: Python and Its Libraries--Who's on First?

2008-11-18 Thread Kirk Strauser
At 2008-11-17T11:44:00Z, W. eWatson [EMAIL PROTECTED] writes: See the post by Chris R. In general, it is incumbent on the asker to provide additional information as needed, rather than being the job of the would-be answerer to go searching for it. -- Kirk Strauser -- http://mail.python.org

Re: Printing with interspersed element

2008-11-06 Thread Kirk Strauser
the original string. Right? How about: def alternator(lst, sep): for index, item in enumerate(lst): if index: yield sep yield item for item in alternator(list_of_objects, 10): print item, -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman

Re: Weird behavior with lexical scope

2008-11-06 Thread Kirk Strauser
At 2008-11-06T16:57:39Z, mrstevegross [EMAIL PROTECTED] writes: class Outer: class Inner: def __init__(self): pass def __init__ (self): a = Inner() Outer() Try instead: class Outer: def __init__(self): a = self.Inner() -- Kirk Strauser The Day Companies

Re: Python/Numeric users be aware!

2008-10-29 Thread Kirk Strauser
At 2008-10-29T17:53:43Z, Benyang [EMAIL PROTECTED] writes: It is totally screwed up on 64-bit linux machines: [1 1 1 1 1 1 1 1 1 1] And on 64-bit FreeBSD machines. -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about scope

2008-10-28 Thread Kirk Strauser
() -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo/python-list

Re: Python barcode decoding

2008-10-28 Thread Kirk Strauser
? If they're nice and crisp, I wrote a simple and pretty quick decoder at http://pypi.python.org/pypi/Daycos/1.0 . Look in the Daycos.Imageproc.Barcode module. -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo/python-list

Re: Append a new value to dict

2008-10-13 Thread Kirk Strauser
8.7s, and your way only took 4.7s. If you're doing this in an inner loop, that may be significant. While we're on the subject, use keyword arguments to dict like: foo.update(dict(quux='blah', baz='bearophile', jdd='dict')) was *much* slower, at 11.8s. -- Kirk Strauser The Day Companies -- http

Re: Suggestion for the PythonDevelopment for next version

2008-10-13 Thread Kirk Strauser
to pay for the extra overhead of modify every object I'll ever get from an iterator? Thanks, but no. One of the things I love about Python is its lack of magic. -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo/python-list

Re: RegExp: wontmatch-function

2008-10-13 Thread Kirk Strauser
At 2008-10-13T16:40:07Z, [EMAIL PROTECTED] writes: def nomatch(value): return not(value == '' or pattern.match(value)) -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo/python-list

Re: More regex help

2008-09-24 Thread Kirk Strauser
/to/deep/page', 'http://slashdot.org/foo') 'http://slashdot.org/foo' -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo/python-list

Suggestions for creating a PDF table

2008-07-28 Thread Kirk Strauser
as HTML? -- Kirk Strauser -- http://mail.python.org/mailman/listinfo/python-list

Re: How do web templates separate content and logic?

2008-07-01 Thread Kirk Strauser
written your very own page template, and that it's ugly, and that you should've used something different from the very beginning. That's why you don't embed HTML in Python, at least not for anything more complicated than Hello, world. -- Kirk Strauser The Day Companies -- http://mail.python.org

Re: newb question on strings

2008-06-27 Thread Kirk Strauser
kind of processing? The only time I've really had to mess with escaping quotes involved SQL. There is *no* reason why you'd ever directly generate SQL strings yourself today unless you're writing a database connector. -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo

Django or TurboGears for a new project

2008-06-27 Thread Kirk Strauser
, -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo/python-list

Re: dict order

2008-06-18 Thread Kirk Strauser
. -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo/python-list

Re: question relateding to parsing dbf files.

2008-06-18 Thread Kirk Strauser
complicated, I've written a replacement in straight C but I haven't published it yet. I use these programs to sync our legacy FoxPro database to our new PostgreSQL servers on an hourly basis. Syncing 4GB of data tables about 10 minutes. -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman

Re: Pattern Matching Over Python Lists

2008-06-17 Thread Kirk Strauser
) def check(list): if list starts with [1, 2] and length of the list 2: return True else: return False -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo/python-list

Good cross-host IPC?

2008-06-16 Thread Kirk Strauser
thing in the world, but I like the warm fuzzies of knowing that thousands of others are testing and using the same project as we are. -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo/python-list

Calling instance methods from a decorator

2008-05-30 Thread Kirk Strauser
im_self to bounce off of or anything. I seem to be going about this all wrong. What's a good approach to get the desired effect? -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling instance methods from a decorator

2008-05-30 Thread Kirk Strauser
At 2008-05-30T17:40:17Z, Diez B. Roggisch [EMAIL PROTECTED] writes: Of course you can get the self - just use the first paramter, because it *is* self. Self is just a parameter - nothing special. If I blame it on being a long week, can I keep my geek card? -- Kirk Strauser The Day Companies

Re: accumulator generators

2008-05-30 Thread Kirk Strauser
to it, then assigning the value back to the local variable named s. -- Kirk Strauser The Day Companies -- http://mail.python.org/mailman/listinfo/python-list

Subclassing list the right way?

2008-04-25 Thread Kirk Strauser
__getitem__(self, index): ... return 5 ... a = Foo([1, 2, 3, 4, 5]) print a [1, 2, 3, 4, 5] print a[2:4] [3, 4] print a[3] 5 I first expected that to instead behave like: print a [5, 5, 5, 5, 5] print a[2:4] [5, 5] Is there a right way to do this? -- Kirk Strauser -- http

Auto-parallelizing with decorators?

2007-07-06 Thread Kirk Strauser
repeated function calls. -- Kirk Strauser -- http://mail.python.org/mailman/listinfo/python-list

Re: Auto-parallelizing with decorators?

2007-07-06 Thread Kirk Strauser
never looked for it). I know something like this wouldn't be the easiest thing to implement, but honestly, having such beautiful constructs as map() and list comprehensions available is just begging for an application like this. -- Kirk Strauser -- http://mail.python.org/mailman/listinfo/python

Re: Auto-parallelizing with decorators?

2007-07-06 Thread Kirk Strauser
In article [EMAIL PROTECTED], Kirk Strauser [EMAIL PROTECTED] wrote: I was thinking about how a lot of Lisp proponents claim that Lisp is inherently parallelizable because its functions don't have (or are not supposed to have) side effects, and therefore the compiler can easily tell which

Recommended validating XML parser?

2007-05-07 Thread Kirk Strauser
/weightfile.dtd')) print foo.weight 3000 ...or some variant on that theme. -- Kirk Strauser -- http://mail.python.org/mailman/listinfo/python-list

Finding the name of a class

2006-08-01 Thread Kirk Strauser
think I've been staring at the problem too long. -- Kirk Strauser -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the name of a class

2006-08-01 Thread Kirk Strauser
type I'm looking for something that would print 'StateProcessor' but am not having much luck. -- Kirk Strauser -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the name of a class

2006-08-01 Thread Kirk Strauser
Bruno Desthuilliers wrote: Kirk Strauser wrote: class foo(object): pass how can I find its name, such as: b = foo I suppose you mean b = foo() ? Actually, I meant 'b = foo' in this case - I want to find the name of the class that b references, but the name of an instance (which

Re: Python article in Free Software Magazine

2006-01-04 Thread Kirk Strauser
Software Magazine needs more of. ? -- Kirk Strauser -- http://mail.python.org/mailman/listinfo/python-list

Re: Python article in Free Software Magazine

2006-01-04 Thread Kirk Strauser
Michele Simionato wrote: when I think Zope is the less Pythonic application I have ever seen;) You do? Why so? I'm not arguing, but that's different than my experience with it and I'm curious about how you reached that conclusion. -- Kirk Strauser -- http://mail.python.org/mailman/listinfo

Re: Python article in Free Software Magazine

2006-01-01 Thread Kirk Strauser
with technical background. That article was meant for you, not your boss. :-) -- Kirk Strauser -- http://mail.python.org/mailman/listinfo/python-list

Python article in Free Software Magazine

2005-12-31 Thread Kirk Strauser
mechanism as pass-by-reference, because that's close enough for newcomers to get the gist of it. Anyway, the article's available under an open license. If you like it, feel free to pass it around. Enjoy! -- Kirk Strauser -- http://mail.python.org/mailman/listinfo/python-list

Pickling and inheritance are making me hurt

2005-02-04 Thread Kirk Strauser
this? -- Kirk Strauser -- http://mail.python.org/mailman/listinfo/python-list