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
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
]
'-'.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
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
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
):
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
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
if those are important to you.
--
Kirk Strauser
The Day Companies
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
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
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
()
--
Kirk Strauser
The Day Companies
--
http://mail.python.org/mailman/listinfo/python-list
?
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
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
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
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
/to/deep/page',
'http://slashdot.org/foo')
'http://slashdot.org/foo'
--
Kirk Strauser
The Day Companies
--
http://mail.python.org/mailman/listinfo/python-list
as HTML?
--
Kirk Strauser
--
http://mail.python.org/mailman/listinfo/python-list
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
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
,
--
Kirk Strauser
The Day Companies
--
http://mail.python.org/mailman/listinfo/python-list
.
--
Kirk Strauser
The Day Companies
--
http://mail.python.org/mailman/listinfo/python-list
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
)
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
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
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
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
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
__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
repeated
function calls.
--
Kirk Strauser
--
http://mail.python.org/mailman/listinfo/python-list
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
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
/weightfile.dtd'))
print foo.weight
3000
...or some variant on that theme.
--
Kirk Strauser
--
http://mail.python.org/mailman/listinfo/python-list
think I've been staring at the problem too
long.
--
Kirk Strauser
--
http://mail.python.org/mailman/listinfo/python-list
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
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
Software Magazine needs more of.
?
--
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.org/mailman/listinfo
with
technical background. That article was meant for you, not your boss. :-)
--
Kirk Strauser
--
http://mail.python.org/mailman/listinfo/python-list
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
this?
--
Kirk Strauser
--
http://mail.python.org/mailman/listinfo/python-list
45 matches
Mail list logo