Re: installing lxml ?

2009-11-11 Thread 7stud
On Nov 11, 5:59 pm, 7stud wrote: > > 1) Maybe the installation instructions for mac osx should read: > > > Installation Instructions > > > MAC OS X: > We're not sure how mac osx works with easy_install.  Apple's system > installations of lib

Re: Monkeypatching an object to become callable

2009-08-09 Thread 7stud
On Aug 9, 1:02 pm, Nikolaus Rath wrote: > Hi, > > I want to monkeypatch an object so that it becomes callable, although > originally it is not meant to be. (Yes, I think I do have a good reason > to do so). > > But simply adding a __call__ attribute to the object apparently isn't > enough, and I d

print() and unicode strings (python 3.1)

2009-08-24 Thread 7stud
==python 2.6 == import sys print sys.getdefaultencoding() s = u"\u20ac" print s.encode("utf-8") $ python2.6 1test.py ascii € =python 3.1 === import sys print(sys.getdefaultencoding()) s = "€" print(s.encode("utf-8")) print(s) $ python3.1 1test.py utf-8 b'\xe2\x82\xac' Tra

Re: print() and unicode strings (python 3.1)

2009-08-24 Thread 7stud
On Aug 24, 9:56 am, "Martin v. Löwis" wrote: > > I don't understand why I'm getting an encode error in python 3.1. > > The default encoding is not relevant here at all. Look at > sys.stdout.encoding. > > Regards, > Martin Hi, Thanks for the response. I get US-ASCII for both 2.6 and 3.1: ===pyt

Re: print() and unicode strings (python 3.1)

2009-08-24 Thread 7stud
On Aug 24, 12:19 pm, Stefan Behnel wrote: > 7stud wrote: > > python 3.1 won't let me > > explicitly encode my unicode string > > Sure it does. But encoding a non-ASCII string to ASCII will necessarily fail. > As you should be able to see in the python 3.1 example I

Re: print() and unicode strings (python 3.1)

2009-08-24 Thread 7stud
On Aug 24, 2:41 pm, "Martin v. Löwis" wrote: > > I can't figure out a way to programatically set the encoding for > > sys.stdout.  So where does that leave me? > > You should be setting the terminal encoding administratively, not > programmatically. > The terminal encoding has always been utf-8.

Re: best way to display photos

2009-08-24 Thread 7stud
On Aug 24, 8:01 pm, Paul Rubin wrote: > samwyse writes: > > My big question is, what's the > > best way to display the photos.  I've used PIL in the past, but IIRC > > it uses an external program.  Pygame is the next obvious choice, but > > like PIL it requires an ad

Re: print() and unicode strings (python 3.1)

2009-08-25 Thread 7stud
On Aug 24, 10:09 pm, Ned Deily wrote: > In article > , > > > > 7stud wrote: > > On Aug 24, 2:41 pm, "Martin v. Löwis" wrote: > > > > I can't figure out a way to programatically set the encoding for > > > > sys.stdout. So where

Re: Need help with Python scoping rules

2009-08-25 Thread 7stud
On Aug 25, 12:11 pm, John Posner wrote: > Diez said: > > > > > Classes are not scopes. > > > So the above doesn't work because name resolution inside functions/methods > > looks for local variables first, then for the *global* scope. There is no > > class-scope-lookup. > > Buthttp://docs.python.or

Re: Need help with Python scoping rules

2009-08-26 Thread 7stud
On Aug 25, 7:26 pm, Dave Angel wrote: > Stephen Fairchild wrote: > > You are trying to run code in a class that does not exist yet. > > > def Demo(): > >     def fact(n): > >         if n < 2: > >             return 1 > >         else: > >             return n * fact(n - 1) > >     return type("De

Re: print() and unicode strings (python 3.1)

2009-08-26 Thread 7stud
On Aug 25, 6:34 am, Nobody wrote: > The underlying OS primitive can only handle bytes. If you read or write a > (unicode) string, Python needs to know which encoding is used. For Python > file objects created by the user (via open() etc), you can specify the > encoding; for those created by the ru

Re: Sending email

2009-08-28 Thread 7stud
On Aug 28, 2:37 am, Fencer wrote: > Hello, I'm using Python version 2.6.2 and I discovered it has built-in > libraries for sending email (imports smtplib and email). On the web I > discovered how to send mail through smtp.gmail.com: > > mail_server = smtplib.SMTP() > > mail_server.connect('smtp.gm

Re: Sending email

2009-08-30 Thread 7stud
On Aug 28, 8:18 am, Fencer wrote: > 7stud wrote: > > [snip] > > Thanks for your reply. After consulting the sysadmins here I was able to > get it to work. > > - Fencer Ok, but how about posting your code so that a future searcher will not be left screaming, "

Re: efficiently splitting up strings based on substrings

2009-09-06 Thread 7stud
On Sep 5, 5:29 pm, per wrote: > On Sep 5, 7:07 pm, "Rhodri James" wrote: > > > > > On Sat, 05 Sep 2009 23:54:08 +0100, per wrote: > > > On Sep 5, 6:42 pm, "Rhodri James" wrote: > > >> On Sat, 05 Sep 2009 22:54:41 +0100, per wrote: > > >> > I'm trying to efficiently "split" strings based on wha

Re: efficiently splitting up strings based on substrings

2009-09-06 Thread 7stud
On Sep 6, 1:14 am, 7stud wrote: > On Sep 5, 5:29 pm, per wrote: > > > > > On Sep 5, 7:07 pm, "Rhodri James" wrote: > > > > On Sat, 05 Sep 2009 23:54:08 +0100, per wrote: > > > > On Sep 5, 6:42 pm, "Rhodri James" wrote: > >

Re: efficiently splitting up strings based on substrings

2009-09-06 Thread 7stud
On Sep 6, 1:23 am, 7stud wrote: > On Sep 6, 1:14 am, 7stud wrote: > > > > > On Sep 5, 5:29 pm, per wrote: > > > > On Sep 5, 7:07 pm, "Rhodri James" wrote: > > > > > On Sat, 05 Sep 2009 23:54:08 +0100, per wrote: > > > > &g

Re: simple string question

2009-09-06 Thread 7stud
On Sep 6, 11:29 pm, "jwither" wrote: > Given a string (read from a file) which contains raw escape sequences, > (specifically, slash n), what is the best way to convert that to a parsed > string, where the escape sequence has been replaced (specifically, by a > NEWLINE token)? > > James Withers 1

Re: Something confusing about non-greedy reg exp match

2009-09-07 Thread 7stud
On Sep 6, 8:46 pm, "gburde...@gmail.com" wrote: > If I do this: > > import re > a=re.search(r'hello.*?money',  'hello how are you hello funny money') > > I would expect a.group(0) to be "hello funny money", since .*? is a > non-greedy match. But instead, I get the whole sentence, "hello how > are

Re: Function to apply superset of arguments to a function

2009-09-09 Thread 7stud
On Sep 9, 10:45 am, Andrey Fedorov wrote: > Hi all, > > I've written a function [1] called apply_some which takes a set of > keywords arguments, filters only those a function is expecting, and > calls the function with only those arguments. This is meant to > suppress TypeErrors - a way to abstrac

<    1   2   3   4   5   6