o need to seek to the
beginning, and files are closed when 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
> [1, 2, 3, 5, 6, 10, 11, 7, 9, 1, 2, 3, 4, 5]
>>>> '-'.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
use it to call
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
> consider 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 Straus
> return 0.0
How 'bout:
def get_rate(balance):
for threshold, rate in ((10, .0173),
(5, .0149),
(25000, .0124),
(1, .0085),
(0, .006)):
if balance
erence exactly? "foo is not None" 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
peol
method because I seem to end up 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
At 2008-12-11T19:49:23Z, Steve Holden 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/python-list
'.rstrip('\r\n')
> ' ab c '
I didn't say it couldn't be done. I just like the Perl version better.
--
Kirk Strauser
The Day Companies
--
http://mail.python.org/mailman/listinfo/python-list
tire module but want 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
worry about losing
leading or trailing spaces if those are important to you.
--
Kirk Strauser
The Day Companies
--
http://mail.python.org/mailman/listinfo/python-list
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.
--
Ki
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()
e [or screen] as
> you go through 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 Compani
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
erated, or
scanned in from other material?
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
alize
initialize.initialize()
def main():
if myGlobals.remote_device_enabled:
process_device()
--
Kirk Strauser
The Day Companies
--
http://mail.python.org/mailman/listinfo/python-list
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
uct to overwrite it? What if I never use enumerate as it is and
don't want 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
= 'dict'
because it seems to more clearly indicate what I'm doing, and has fewer
opportunities for types. Still, there is a performance penalty. Running
"my way" 10,000,000 times took 8.7s, and "your way" only took 4.7s. If
you're doing this in an i
27;/foo')
'http://www.example.com/foo'
>>> urllib.basejoin('http://www.example.com/path/to/deep/page',
'http://slashdot.org/foo')
'http://slashdot.org/foo'
--
Kirk Strauser
The Day Companies
--
http://mail.python.org/mailman/listinfo/python-list
d *almost* perfect, except that it doesn't support colspans.
As I hope I demonstrated in the example, most of our reports depend on that
ability.
So, again, any thoughts on a PDF generator that can generate tables with the
same kind of flexibility as HTML?
--
Kirk Strauser
--
http://mail.python.org/mailman/listinfo/python-list
the function and all
of the HTML print statements to the bottom. And then you realize you've
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 lea
s any to find subject
matter experts.
Thanks,
--
Kirk Strauser
The Day Companies
--
http://mail.python.org/mailman/listinfo/python-list
ut of curiosity, what 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://honeypot.net/project/xbasetopg . If that's too 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 ta
ict_two that's not in dict_one.
--
Kirk Strauser
The Day Companies
--
http://mail.python.org/mailman/listinfo/python-list
item is a list:
compare(item, function)
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
of the same problem
space, but not all of our code is easily bent to its will. Is there
another, more common way of doing this stuff?
Popularity isn't the most important 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
them. So your bar is taking s, adding i 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
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?
--
;__name__',
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__',
'func_closure', 'func_code', 'func_defaults', 'func_dict', 'func_doc',
'func_globals', 'func_name']
There's no nice 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
;>> class Foo(list):
... def __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
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 th
f Windows has os.fork(), having 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.o
ts. However, if you take care to make your functions loosely
coupled and not dependent on execution order, you could get a nice speedup
every single time you give Python permission to schedule your repeated
function calls.
--
Kirk Strauser
--
http://mail.python.org/mailman/listinfo/python-list
3000
""", dtd=file('/etc/weightfile.dtd'))
>>> print foo.weight
3000
...or some variant on that theme.
--
Kirk Strauser
--
http://mail.python.org/mailman/listinfo/python-list
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 t
;> print StateProcessor.__class__.__name__
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
ed method belongs to. This seems
like it should be easy, but I think I've been staring at the problem too
long.
--
Kirk Strauser
--
http://mail.python.org/mailman/listinfo/python-list
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.or
> Makes for a nice figure, too, which Free Software Magazine needs more of.
?
--
Kirk Strauser
--
http://mail.python.org/mailman/listinfo/python-list
say to write for an audience with
technical background. That article was meant for you, not your boss. :-)
--
Kirk Strauser
--
http://mail.python.org/mailman/listinfo/python-list
lling 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
ems like the problem is that _saveresults is only looking inside the
same namespace as Search (where it's originally defined), even if it's
actually been inherited by another class in a different module. Is there a
way around this?
--
Kirk Strauser
--
http://mail.python.org/mailman/listinfo/python-list
45 matches
Mail list logo