ignoring some placeholders in string formatting

2010-02-10 Thread Michal Ludvig
Hi all, when I've got a string, say: URL="http://xyz/blah?session=%(session)s&message=%(message)s" is it possible to fill in only 'session' and leave "%(message)s" as is when it isn't present in the values dict? For example: URL % { 'session' : 123 } raises KeyError because of missing 'message'

Re: Unicode encoding - ignoring errors

2008-12-29 Thread Michal Ludvig
Chris Rebert wrote: > On Mon, Dec 29, 2008 at 4:06 AM, Michal Ludvig wrote: >> Hi, >> >> in my script I have sys.stdout and sys.stderr redefined to output >> unicode strings in the current system encoding: >> >>encoding = locale.getp

Re: setup.py installs modules to a wrong place

2008-12-29 Thread Michal Ludvig
Hi Omer, > I'm seeing this on fc8 with a custom built python2.6. Not happening > with any other packages (e.g. boto). Workaround of course was just to > copy the S3 dir to /usr/local/lib/python2.6/site-packages. I've found it. The culprit was a pre-set install prefix in setup.cfg - I can't reme

Unicode encoding - ignoring errors

2008-12-29 Thread Michal Ludvig
Hi, in my script I have sys.stdout and sys.stderr redefined to output unicode strings in the current system encoding: encoding = locale.getpreferredencoding() sys.stdout = codecs.getwriter(encoding)(sys.stdout) However on some systems the locale doesn't let all the unicode chars

Re: setup.py installs modules to a wrong place

2008-12-18 Thread Michal Ludvig
/Python.framework/Versions/2.5/lib/python2.5 While this directory *is* in sys.path, the .../site-packages one isn't, see below in my original post. So why did Python decide to put the modules there? Why not one of the directories that are in sys.path? Is this configurable somewhere? Thanks! Michal M

setup.py installs modules to a wrong place

2008-12-13 Thread Michal Ludvig
Hi, I have recently seen some reports from users of my s3cmd script [1] who installed the package using the provided distutils-based setup.py and immediately after installation the script failed to run because it couldn't find its modules. Here's an example session from Mac OS X, but similar beha

File names, character sets and Unicode

2008-12-12 Thread Michal Ludvig
Hi all, is there any way to determine what's the charset of filenames returned by os.walk()? The trouble is, if I pass argument to os.walk() I get the filenames as byte-strings. Possibly UTF-8 encoded Unicode, who knows. OTOH If I pass to os.walk() all the filenames I get in the loop are alrea