My poor understanding is that the difference between `sorted(somelist,
key=lambda x:...)` and `somelist.sort(lambda x,y...)` is that one
returns a new list and the other sorts in-place.
Does that mean that .sort() is more efficient and should be favored
when you can (i.e. when you don't mind chang
On Jun 2, 12:34 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Peter Bengtsson wrote:
> > In my unittest I want to override the logger of a working module so
> > that it puts all logging messages in /tmp/test.log instead so that in
> > my unittest I can
On Jun 2, 12:34 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Peter Bengtsson wrote:
> > In my unittest I want to override the logger of a working module so
> > that it puts all logging messages in /tmp/test.log instead so that in
> > my unittest I can
In my unittest I want to override the logger of a working module so
that it puts all logging messages in /tmp/test.log instead so that in
my unittest I can inspect that it logs things correctly. Hopefully
this "pseudo" code will explain my problem::
>>> import logging, os
>>> logging.basicConfig(f
On Jan 15, 5:22 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Peter Bengtsson wrote:
> > root = Element('feed', xmlns='http://www.w3.org/2005/Atom')
> > root.set('xmlns:se', NS_URL)
> > entry = SubElement(root, 'entry')
>
Here's my code (simplified):
NS_URL = 'http://www.snapexpense.com/atom_ns#'
ElementTree._namespace_map[NS_URL] = 'se'
def SEN(tag):
return "{%s}%s" % (NS_URL, tag)
root = Element('feed', xmlns='http://www.w3.org/2005/Atom')
root.set('xmlns:se', NS_URL)
entry = SubElement(root, 'entry')
SubEle
On Oct 15, 10:57 pm, John Machin <[EMAIL PROTECTED]> wrote:
> On Oct 16, 2:33 am, Peter Bengtsson <[EMAIL PROTECTED]> wrote:
>
>
>
> > In UTF8, \u0141 is a capital L with a little dash through it as can be
> > seen in this image:http://static.peterbe.com/luka
On Oct 15, 4:09 pm, sophie_newbie <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm wondering how do you set a 'timeout' or expiry date/time for a
> cookie set using a python cgi script. I can set a cookie ok but I
> dunno how to set the expiry time so it always expires at the end of
> the session.
>
Easy,
In UTF8, \u0141 is a capital L with a little dash through it as can be
seen in this image:
http://static.peterbe.com/lukasz.png
I tried this:
>>> import unicodedata
>>> unicodedata.normalize('NFKD', u'\u0141').encode('ascii','ignore')
''
I was hoping it would convert it it 'L' because that's what
On Apr 1, 5:48 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> Peter Bengtsson wrote:
> > Hi, I'm trying to pickle an object instance of a class that is like a
> > dict but with a __getattr__ and I'm getting pickling errors.
> > This is what happens when I
Hi, I'm trying to pickle an object instance of a class that is like a
dict but with a __getattr__ and I'm getting pickling errors.
This works but is not good enough.
$ python2.4
>>> import cPickle as pickle
>>> class Dict(dict):
... pass
...
>>>
>>>
>>> friend = Dict(name='Zahid', age=40)
>>>
On Feb 23, 2:38 pm, [EMAIL PROTECTED] wrote:
> Hi,
>
> I'm updating my program to Python 2.5, but I keep running into
> encoding problems. I have no ecodings defined at the start of any of
> my scripts. What I'd like to do is scan a directory and list all the
> files in it that contain a non ascii
I love the dropshadow effect I managed to make with this recipe:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/474116
Here's what it can look like:
http://www.peterbe.com/test/188-tequilacat.2.jpg
It takes a background as a parameter but it's just a colour. What I
want is to put the ima
tle()
> ...
> >>> re.compile("(peter)", re.I).sub(process, "Peter Bengtsson PETER, or
> PeTeR")
> '_Peter_ Bengtsson _Peter_, or _Peter_'
> >>>
Ahaa! Great. I didn't realise that I can substitute with a callable that gets
the match object. Hadn't thought of it that way.
Will try this now.
--
http://mail.python.org/mailman/listinfo/python-list
I've got a regular expression that finds certain words from a longer string.
>From "Peter Bengtsson PETER, or PeTeR" it finds: 'Peter','PETER','PeTeR'.
What I then want to do is something like this:
def _ok(matchobject):
# more complicated
15 matches
Mail list logo