Re: Sorting a list of objects by multiple attributes

2006-04-11 Thread Kent Johnson
Scott David Daniels wrote: > Kent Johnson wrote: >> In Python 2.5 you can do this with operator.attrgetter(): >> L.sort(key=operator.attrgetter('whatever', 'someother', 'anotherkey')) > > Note: this is also available in Python 2.4 No, the abil

Re: Sorting a list of objects by multiple attributes

2006-04-11 Thread Kent Johnson
gry@ll.mit.edu wrote: > For multiple keys the form is quite analogous: > >L.sort(key=lambda i: (i.whatever, i.someother, i.anotherkey)) > > I.e., just return a tuple with the keys in order from your lambda. > Such tuples sort nicely. In Python 2.5 you can do this with operator.attrgetter()

Re: jpype and zxJDBC

2006-04-10 Thread Kent Johnson
benchline wrote: > So, I decided to try to see if I could use jdbc from cpython using > jpype and that works great. It's quite a bit faster then using jython > and the db api on the same database my tests too. Did you compare jpype/jdbc with jython/jdbc? I wonder if the slowdown might be in zxJ

Re: unboundlocalerror with cgi module

2006-04-10 Thread Kent Johnson
Tim Hochberg wrote: > Kent Johnson wrote: >> David Bear wrote: >> >>> I'm attempting to use the cgi module with code like this: >>> >>> import cgi >>> fo = cgi.FieldStorage() >>> # form field names are in the form if &

Re: unboundlocalerror with cgi module

2006-04-10 Thread Kent Johnson
David Bear wrote: > I'm attempting to use the cgi module with code like this: > > import cgi > fo = cgi.FieldStorage() > # form field names are in the form if 'name:part' > keys = fo.keys() > for i in keys: > try: > item,value=i.split(':') > except NameError, Unboun

Re: Is this code snippet pythonic

2006-04-10 Thread Kent Johnson
Peter Hansen wrote: > [EMAIL PROTECTED] wrote: >>> class E(object): >> _count = 0 >> def __init__(self): >> E._count += 1 >> count = property(lambda self: E._count ) > 2. You don't need the "self" in the lambda, since you're not using it > anyway. Yes he does, it's a propert

Re: Automated Graph Plotting in Python

2006-04-09 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > My python program spits lot of data. I take that data and plot graphs > using OfficeOrg spredsheet. I want to automate this task as this takes > so much of time. I have some questions. > > 1. Which is the best graph plotting utility in python or linux. Can I > write a co

Re: Name of the calling method

2006-04-08 Thread Kent Johnson
Saptarshi Guha wrote: > Hello, > Say Boo is a class with a method called x. In the body of x i wish to > know from which method x was called. How would i do this? > Thanks in advance > Saptarshi > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66062 Kent -- http://mail.python.org/mai

Re: How's python's web scraping capabilities (vs LWP) ...

2006-04-08 Thread Kent Johnson
ArKane wrote: > Hello all, > > I've been hacking away at perl for a few months now, mainly using the > LWP module, used for web scraping. Amoung its capabilities include > support for HTTPS and proxies, authentication, cookies (including the > ability to automatically import Internet Explorer cook

Re: Characters contain themselves?

2006-04-08 Thread Kent Johnson
WENDUM Denis 47.76.11 (agent) wrote: > While testing recursive algoritms dealing with generic lists I stumbled > on infinite loops which were triggered by the fact that (at least for my > version of Pyton) characters contain themselves.See session: Strings are sequences and this is a problem for

Re: Unicode, command-line and idle

2006-04-07 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Martin v. Löwis wrote: >> [EMAIL PROTECTED] wrote: >>> This works if I use the console but gives the following error if I use >>> IDLE: >>> >>> Traceback (most recent call last): >>> File "C:\test.py", line 4, in ? >>> text2 = unicode(raw_input(), sys.stdin.encoding

Re: Quickie: converting r"\x2019" to int

2006-04-06 Thread Kent Johnson
Robin Haswell wrote: > Hey guys. This should just be a quickie: I can't figure out how to convert > r"\x2019" to an int - could someone give me a hand please? Is this what you mean? In [9]: int(r'\x2019'[2:], 16) Out[9]: 8217 or maybe you meant this: In [6]: ord(u'\u2019') Out[6]: 8217 Kent --

Re: How to change the docs - a case study

2006-04-06 Thread Kent Johnson
Fredrik Lundh wrote: > Kent Johnson wrote: > >> Here is an example. This morning I noticed a minor discrepancy in the >> docs for the 'rot13' encoding. I posted a bug to SourceForge at 10:05 >> GMT. At 10:59 someone commented that maybe the code was broken

How to change the docs - a case study

2006-04-06 Thread Kent Johnson
There has been a lot of discussion here recently about making changes to the docs, and what new system should be in place, etc., wiki, etc. I occasionally chime in with a note that it's pretty easy to submit a doc patch through SourceForge and they are often accepted quickly. The point being th

Re: Unicode question : turn "José" into u"José"

2006-04-05 Thread Kent Johnson
ianaré wrote: > maybe a bit off topic, but how does one find the console's encoding > from within python? > In [1]: import sys In [3]: sys.stdout.encoding Out[3]: 'cp437' In [4]: sys.stdin.encoding Out[4]: 'cp437' Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: String pattern matching

2006-04-05 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Thanks to all for the various good approaches. Kent's plain RE approach > seems the most straightforward - did not know that RE can handle this > situation - good to know! Thanks to Eddie Corns also who showed how to express the problem as a parsing problem. I am also

Re: scraping nested tables with BeautifulSoup

2006-04-04 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Thanks Kent that works perfectly.. How can I strip all the HTML and > create easily a dictionary of {location:price} ?? This should help: prices = priceGuide.table for tr in prices: print tr.a.string, tr.a.findNext('font').string Kent -- http://mail.python.org/

Re: scraping nested tables with BeautifulSoup

2006-04-04 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hey Kent, > > thanks for your reply. how did you exactly save the file in firefox? if > I save the file locally I get the same error. The Firefox version, among other things, turns all the funky and tags into comments. Here is a way to do the same thing with BS: imp

Re: scraping nested tables with BeautifulSoup

2006-04-04 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hey Kent, > > thanks for your reply. how did you exactly save the file in firefox? if > I save the file locally I get the same error. I think I right-clicked on the page and chose "Save page as..." Here is a program that shows where BS is choking. It finds the last lea

Re: how to comment lot of lines in python

2006-04-04 Thread Kent Johnson
Rick Zantow wrote: >> Thank you! I don't suppose you have any tricks to make it work with >> UTF-8 data outside the cp1252 character set, do you? >> > > Sadly, I don't. TP claims Unicode support, but I'm not sure what they > mean; it does seem to be restricted to cp1252. TP will correctly read

Re: scraping nested tables with BeautifulSoup

2006-04-04 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > I'm trying to get the data on the "Central London Property Price Guide" > box at the left hand side of this page > http://www.findaproperty.com/regi0018.html > > I have managed to get the data :) but when I start looking for tables I > only get tables of depth 1 how do I

Re: String pattern matching

2006-04-03 Thread Kent Johnson
Jim Lewis wrote: > Anyone have experience with string pattern matching? > I need a fast way to match variables to strings. Example: > > string - variables > > abcaaab - xyz > abca - xy > eeabcac - vxw > > x matches abc > y matches a > z matches aab > w maches ac > v maches ee > You

Re: String pattern matching

2006-04-03 Thread Kent Johnson
Eddie Corns wrote: > Off topic I know but I've been learning snobol pattern matching recently so I > thought I'd give this one a bash. Here is my effort: > > define('foo(str)') > &fullscan = 1 > '/abcaaab/abca/eeabcac/' '/' arb $ x arb $ y arb $ z '/' *x *y '/' > +

Re: "definitive" source on advanced python?

2006-04-03 Thread Kent Johnson
vdrab wrote: > Hi all, > > Is there some sort of coherent source (dead tree format, maybe?) on > some of the more advanced features > of python (decorators, metaclasses, etc)? I'm sort of looking for a > python book that actually gets to the good stuff at some point, without > first spending 6 cha

Re: how to comment lot of lines in python

2006-04-03 Thread Kent Johnson
Rick Zantow wrote: > Kent Johnson <[EMAIL PROTECTED]> wrote in news:44310867$1_1 > @newspeer2.tds.net: > >> Sion Arrowsmith wrote: >>> Out of curiousity, is there a modern editor which *doesn't* allow you >>> to comment/uncomment a selected bunch of l

Re: Problem with wrapping GNU Units

2006-04-03 Thread Kent Johnson
TheSeeker wrote: > Hi, > As part of a larger project, I am trying to use the GNU Units program > to provide unit conversions between quantities. Maybe Unum would be a useful alternate: http://home.tiscali.be/be052320/Unum.html Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: how to comment lot of lines in python

2006-04-03 Thread Kent Johnson
Sion Arrowsmith wrote: > Eric Deveaud <[EMAIL PROTECTED]> wrote: >> some moderns editors allow you to comment/uncomment a selected Bunch >> of lines of code > > Out of curiousity, is there a modern editor which *doesn't* allow you > to comment/uncomment a selected bunch of lines of code? > Tex

Re: Doc suggestions

2006-04-01 Thread Kent Johnson
Terry Reedy wrote: > Yes, there have been claims that doc patches have to be in Latex or are > otherwise not welcome. This is counter to my own experience and this page which says, "There's no need to worry about text markup; our documentation team will gladly take care of that." http://docs.

Re: running IDLE from another program?

2006-04-01 Thread Kent Johnson
John Salerno wrote: > Kent Johnson wrote: > >>The working directory must be wrong. Try calling Python directly with >>full paths: >> >>C:\Python24\pythonw C:\Python24\Lib\idlelib\idle.pyw -r C:\path\to\myprog.py > > > Perfect! Thank you so much! > &

Re: running IDLE from another program?

2006-04-01 Thread Kent Johnson
John Salerno wrote: > Kent Johnson wrote: >>One thing that is really useful about running in an editor window is >>that (in TextPad, anyway) I can double-click on an error message and go >>directly to the line with the error. > > > Interesting. The way I have it

Re: Python 2.5 licensing: stop this change

2006-04-01 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Aww, but I liked the idea of copying Perl 6 REs, and porting python to > the toy CPU :-) I think if PSF is going to support porting of Python to "toy" CPUs then the Digi-Comp should be the first target. This will breathe new life into these toys which for years have be

Re: running IDLE from another program?

2006-04-01 Thread Kent Johnson
John Salerno wrote: > Kent Johnson wrote: > >>John Salerno wrote: >> >>>Kent Johnson wrote: >>> >>>>You probably don't need to do that. Just run the file in python >>>>directly. I don't know UE, but when you configure an exte

Re: running IDLE from another program?

2006-03-31 Thread Kent Johnson
John Salerno wrote: > Kent Johnson wrote: >>You probably don't need to do that. Just run the file in python >>directly. I don't know UE, but when you configure an external tool, tell >>it to run python.exe and pass the current file as a command line param

Re: logging producing redundant entries

2006-03-31 Thread Kent Johnson
Jed Parsons wrote: > > Thanks, Kent and Peter, > > Definitely making progress here. I've got propagate = 0, and am testing > for handlers before doing any addHandler business. (The handlers test > seems to make the most difference.) > > I'm down to two entries per time now! And prodding Zop

Re: running IDLE from another program?

2006-03-31 Thread Kent Johnson
John Salerno wrote: > If I want to write my code in a separate text editor (I like UltraEdit) > but then press a single button to have that code run in the IDLE > environment, is that possible? I know that you can configure UE to run > external tools, but I can't figure out how to run IDLE this

Re: logging producing redundant entries

2006-03-31 Thread Kent Johnson
Jed Parsons wrote: > Thanks, Peter and alex23, > > The metalog test shows that the code is only being executed once at a time. > > And if I take those lines and put them in a shell script (fixing the > FileHandler - sorry about the bad copy there), they work as expected, > producing a single lo

Re: member variables in python

2006-03-31 Thread Kent Johnson
PyPK wrote: > ok I reason I was going with globals is that i use this variable in > another class something like this along with above > > testflag = 0 > > class AA: >def __init__(...): > > def methos(self,...): >global testflag >testflag = xx > > class BB: > def __ini

Re: member variables in python

2006-03-31 Thread Kent Johnson
PyPK wrote: > hi how do I write this better with member variables rather than global > as you see below. > > eg: > > test-flag = 0 > > class AA: >def __init__(...): > > def methos(self,...): >global test-flag >test-flag = xx > > instead of something like above ..how do i

Re: How to debug python code?

2006-03-31 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > hi, >I am new to Python programming.I am not getting exactly pdb.Can > anyone tell me effective way to debug python code? I too rely mostly on unit tests and print statements for debugging, but occasionally I use winpdb which is a pretty nice GUI debugger. http

Re: a hobbyist's dilemma

2006-03-30 Thread Kent Johnson
John Salerno wrote: > benchline wrote: > >>Since you want to learn to use python with a database you may want to >>try it with SQLite. > > The thing about mysql is that it's also the db used on my website, so I > figure it might be nice to learn that one in case I ever need to use > that db a

Re: tips for this exercise?

2006-03-28 Thread Kent Johnson
John Salerno wrote: > Brian Quinlan wrote: > >>I would just write the function like this: >> >>def genNumbers(): >>shuffle_nums = numbers[:]# copy the list to preserve the orginal >> # order (if it matters) >>random.shuffle(shuffle_nums) # shuffle the en

Re: Seems like I want a pre-processor, but...

2006-03-28 Thread Kent Johnson
Russell Warren wrote: > After some digging it seems that python does not have any equivalent to > C's #if directives, and I don't get it... > > For example, I've got a bit of python 2.3 code that uses > collections.deque.pop(0) in order to pop the leftmost item. In python > 2.4 this is no longer

Re: pysqlite

2006-03-27 Thread Kent Johnson
Kent Johnson wrote: > abcd wrote: > >>>>anyone have v2.x of pysqlite that I could download? the website is >>>>down for a hardware upgrade with no date as to when it will be back. >>>> >>> >>I need v 2.x for windows, running python v2.4

Re: pysqlite

2006-03-27 Thread Kent Johnson
abcd wrote: >>>anyone have v2.x of pysqlite that I could download? the website is >>>down for a hardware upgrade with no date as to when it will be back. >>> >> > > I need v 2.x for windows, running python v2.4 I sent pysqlite-2.0.4.win32-py2.4.exe Kent -- http://mail.python.org/mailman/listin

Re: [ANN] Firedrop 0.2.0 - The Python Blog Client

2006-03-26 Thread Kent Johnson
Fuzzyman wrote: > It has finally happened, the release of `Firedrop 0.2.0 > * `ConfigObj `_ is > now used to edit all the config files. You should add this to the dependency list in the install page, it tripped me up. Kent -- http://mail.pytho

Re: Accessing func_name from inside a function

2006-03-25 Thread Kent Johnson
James Thiele wrote: > I'd like to access the name of a function from inside the function. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66062 Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Custom behavior defined in the imported module

2006-03-25 Thread Kent Johnson
Paul McGuire wrote: > The alternatives I've come up with for the user to enable this packrat parse > mode are: > > 1. Add a staticmethod enablePackrat() to the pyparsing ParserElement class, > to modify the ParserElement defintion of the internal (non-packrat) parse() > method. This method essent

Re: how to format a return value by using re.sub(regx,rep1,str)?

2006-03-25 Thread Kent Johnson
dongdong wrote: > for example: > re.sub(']+)+\s?>[^<^>]*','',' asd ga href="http://www.sine.com"; class="wordstyle"> asdgasdghae rha') > > I wish to get the return value "asd ga asdgasdghae rha",how do do? > I have a impression on "%" and "{number}",but forgot how to use them. > Use a group to c

Re: don't understand popen2

2006-03-24 Thread Kent Johnson
Sion Arrowsmith wrote: > Kent Johnson <[EMAIL PROTECTED]> wrote: > >>Sion Arrowsmith wrote: >> >>>(and please avoid the abuse of raw strings for Windows paths). >> >>Why do you consider that abuse of raw strings? > > I consider it abuse because

Re: Why are so many built-in types inheritable?

2006-03-24 Thread Kent Johnson
Fabiano Sidler wrote: > Hi folks! > > For debugging purposes I tried this: > > --- snip --- > def foo(): pass > function = type(foo) > > class PrintingFunction(function): > def __init__(self, func): > self.func = func > def __call__(self, *args, **kwargs): > print args, kwargs >

Re: converting to a binary number?

2006-03-24 Thread Kent Johnson
John Salerno wrote: > I'm having some trouble finding a function that converts numbers > (whether integer, hex, whatever) to its binary representation. Is there one? You might like this recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/111286 Kent -- http://mail.python.org/mailman

Re: don't understand popen2

2006-03-23 Thread Kent Johnson
Sion Arrowsmith wrote: > Try: > std_out, std_in = popen2.popen2("F:/coding/pwSync/popen_test/testia.py") > or: > std_out, std_in = popen2.popen2("F:\\coding\\pwSync\\popen_test\\testia.py") > (and please avoid the abuse of raw strings for Windows paths). Why do you consider that abuse of raw strin

Re: Can't get the real contents form page in internet as the tag "no-chche"

2006-03-22 Thread Kent Johnson
dongdong wrote: > using web browser can get page's content formally, but when use > urllib2.open("http://tech.163.com/2004w11/12732/2004w11_1100059465339.html";).read() > > the result is > > CONTENT="0;URL=http://tech.163.com/04/1110/12/14QUR2BR0009159H.html";> > content="no-cache">?y?ú'ò?aò3??

Re: Why TypeError: 'str' object is not callable?

2006-03-22 Thread Kent Johnson
Carl J. Van Arsdall wrote: > Randall Parker wrote: >> >>Getting: >>TypeError: 'str' object is not callable >> >>on this line: >> >> > > You have a boo boo > > >>TmpErrMsg1 = "State machine %s " (StateMachineName) >> > > Should be > > TmpErrMsg1 = "State machine %s " %(StateMachineName) An

Re: string.upto() and string.from()

2006-03-22 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Sure, you're right I forgot about rsplit ! > I guess the negative indexes & al could be done with > > sep.join(xyz.split(sep)[:index]) For index=-1 use xyz.rsplit(sep, 1)[0] Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: string.upto() and string.from()

2006-03-22 Thread Kent Johnson
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > >>I often need to re-code for myself a small code snippet to define >>string.upto() and string.from(), which are used like : FWIW this is pretty easy to do with str.split() and rsplit(): >> >># canonical examples >> >>>"1234456789".upto("45") >

Re: struct size confusion:

2006-03-22 Thread Kent Johnson
Michael Yanowitz wrote: > Hello: > >I am relatively new to Python and this is my first post on > this mailing list. > >I am confused as to why I am getting size differences in the following > cases: > > print struct.calcsize("I") > > 4 > print struct.calcsize("H") > > 2 > >>

Re: Use of Python with GDAL. How to speed up ?

2006-03-22 Thread Kent Johnson
Julien Fiore wrote: > Thanks Caleb for the advice, > > I profiled my code with the following lines: > > import profile, pstats > > profile.runctx('openness(infile,outfile,R)',globals(),locals(),'profile.log') > p = pstats.Stats('profile.log') > p.sort_stats('time') > p.print_stat

Re: Installing PyExcelerator to write Excel files from Python

2006-03-21 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > I downloaded PyExcelerator.zip as I need to write some data into Excel > files, and tried unsuccessfully to install it. I unzipped the files > into C:/Python24/Lib/site-packages/PyExcelerator You should unzip to somewhere else, the install step will put the correct file

Re: ** Operator

2006-03-20 Thread Kent Johnson
Christoph Zwerschke wrote: >>http://docs.python.org/lib/typesnumeric.html > > You're right, it's mentioned there in section 2.3.4, but the explanation > of pow() is already in section 2.1 prior to that. > > So it would be nice if the paragraph explaining pow() would mention that > you can also

Re: Counting number of each item in a list.

2006-03-19 Thread Kent Johnson
sophie_newbie wrote: > Hey Bruno, > > I got an invalid syntax error when i tried using your "str_counts = > dict((s, str_list.count(s) for s in set(str_list))" bit of code? Maybe > there is a missing bracket or comma? Or maybe I need to import > something. It should be str_counts = dict((s, str_l

Re: ANNOUNCE: xlrd 0.5.2 -- extract data from Excel spreadsheets

2006-03-19 Thread Kent Johnson
John Machin wrote: > On 19/03/2006 2:30 PM, Kent Johnson wrote: >>That didn't shed much light. I'm interested in your biased opinion, >>certainly you must have had a reason to write a new package. > > * It's not new. First public release was on 2005-05-15.

Re: Can I use a conditional in a variable declaration?

2006-03-18 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > I want the equivalent of this: > > if a == "yes": >answer = "go ahead" > else: >answer = "stop" > > in this more compact form: > > > a = (if a == "yes": "go ahead": "stop") If the value for the 'true' case can never have a boolean value of False, you can use

Re: POP3 Mail Download

2006-03-18 Thread Kent Johnson
Bob Piton wrote: > On Sat, 18 Mar 2006 18:34:56 -0500, Kevin F wrote: >>i have no idea what you are hinting at, can you please just tell me what i >>need to change? > > > I know how you feel; it's brutal trying to get elementary information from > this group. You could try the python-tutor list,

Re: ANNOUNCE: xlrd 0.5.2 -- extract data from Excel spreadsheets

2006-03-18 Thread Kent Johnson
John Machin wrote: > On 19/03/2006 8:31 AM, Kent Johnson wrote: >>How does xlrd compare with pyexcelerator? At a glance they look pretty >>similar. >> > > I have an obvious bias, so I'll just leave you with a not-very-PC > analogy to think about: > &g

Re: POP3 Python Mail Download

2006-03-18 Thread Kent Johnson
Kevin F wrote: > However, if I try to actually download the messages themselves, my > python editor highlights 'msgSize' and says "invalid syntax" when I run > the following subsequent lines of code: > > > > emails = [] > for msg in messagesInfo: > msgNum = in

Re: ANNOUNCE: xlrd 0.5.2 -- extract data from Excel spreadsheets

2006-03-18 Thread Kent Johnson
John Machin wrote: > I am pleased to announce a new general release (0.5.2) of xlrd, a Python > package for extracting data from Microsoft Excel spreadsheets. How does xlrd compare with pyexcelerator? At a glance they look pretty similar. Thanks, Kent -- http://mail.python.org/mailman/listinfo/

Re: Parsing Hints

2006-03-17 Thread Kent Johnson
mwt wrote: > Hi - > I'm working on parsing a file that has data that looks like the sample > below. > > Here's a sample of the data: > > Index 4: folding now > server: 171.65.199.158:8080; project: 1809 > Folding: run 17, clone 19, generation 35; benchmark 669; misc: 500, > 400 > issue: W

Re: Detecting arguments of a function - possible?

2006-03-17 Thread Kent Johnson
Chance Ginger wrote: > I am trying to write a tool to examine a function (I'd like it > to work with pyc files only). So here are a few questions I > have; any pointers would be very welcome. > > Can I determine the number of arguments required of a function? See inspect.getargspec() > Is there

Re: Counting nested loop iterations

2006-03-16 Thread Kent Johnson
Derek Basch wrote: > Fredrik Lundh wrote: >>(the real question here is of course why you need the counter. what's >>the loop doing? if the code you posted is all you have, you can replace >>it with index = sum(len(animal) for animal in zoo), but I assume you want >>to do more stuff in there...) >

Re: Install Universal Encoding Detector

2006-03-16 Thread Kent Johnson
Jacob wrote: > How do I uninstall? Delete the chardet folder from site-packages (Python24\Lib\site-packages on Windows, not sure of the exact path on other OS's). Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Install Universal Encoding Detector

2006-03-15 Thread Kent Johnson
Jacob wrote: > How do I install Universal Encoding Detector > (http://chardet.feedparser.org/)? The usual process: download unpack with your favorite tool - tar or WinZip, maybe cd chardet-1.0 python setup.py install Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Little Help with Exceptions and ConfigParser

2006-03-15 Thread Kent Johnson
mwt wrote: > (Whoops, again.) > > def __init__(self, config_file): > self.fahdata = fahdata.FAHData() > self.INI = ConfigParser.ConfigParser() > if os.path.exists(config_file): > try: > self.INI.read(config_file) > except ConfigParser

Re: Little Help with Exceptions and ConfigParser

2006-03-14 Thread Kent Johnson
mwt wrote: > Hi - > I'm having a little trouble using exceptions properly. I currently have > an initialization function on a little app that looks like this: > > def __init__(self, config_file): > self.fahdata = fahdata.FAHData() > self.INI = ConfigParser.ConfigParser() >

Re: Localized month names?

2006-03-14 Thread Kent Johnson
Peter Otten wrote: > Sibylle Koczian wrote: >>What did you leave out? > > > Nothing, most likely. > > >>I get >> >>Traceback (most recent call last): >> File "", line 1, in -toplevel- >>locale.nl_langinfo(locale.MON_1) >>AttributeError: 'module' object has no attribute 'nl_langinfo' >> >

Re: Is this possible in Python?

2006-03-13 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hello again, > I am disappointed. You are the experts, you've got to try harder ;-) > What i want is a generalisation of this tiny function: Why? Maybe we can find a better way... Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Love :)

2006-03-13 Thread Kent Johnson
Paul Rubin wrote: > So what's the most concise way > of turning it back into a string? ''.join(list(reversed(a_string))) ? You don't need the list(), join() can take an iterator: ''.join(reversed(a_string)) Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: trying to find repeated substrings with regular expression

2006-03-13 Thread Kent Johnson
Robert Dodier wrote: > Hello all, > > I'm trying to find substrings that look like 'FOO blah blah blah' > in a string. For example give 'blah FOO blah1a blah1b FOO blah2 > FOO blah3a blah3b blah3b' I want to get three substrings, > 'FOO blah1a blah1b', 'FOO blah2', and 'FOO blah3a blah3b blah3b'.

Re: Please, I Have A Question before I get started

2006-03-13 Thread Kent Johnson
Ravi Teja wrote: > I do not think that technology has gone backwards. Hyper card > alternatives still exist. > http://www.metacard.com/ At $995 per seat it's not likely to be used for a home project. Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: lighter weight options to Python's logging package?

2006-03-12 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Trent> Do you have any profile information for where in the logging > Trent> package the time is being spent? > > Looking back at a recent run from a few days ago Formatter.formatTime() > seems to be a current problem. You might try using the raw creation time %

Re: cgi problem

2006-03-09 Thread Kent Johnson
Paul Rubin wrote: > Tim Roberts <[EMAIL PROTECTED]> writes: > >>Yes, but the CGI module doesn't write anything, so the advice of writing a >>"Location:" header still applies. > > > Aha, it's coming from CGIHTTPServer.py:CGIHTTPRequestHandler.run_cgi() > where it says > > self.send_respo

Re: advice on this little script

2006-03-09 Thread Kent Johnson
Alex Martelli wrote: > John Salerno <[EMAIL PROTECTED]> wrote: >... > >>I think the 'from time import sleep' looks cleaner, because I'm only >>taking what I need (is an import any more expensive than this from?), >>but I also feel like the 'time.sleep' syntax is much more >>self-describing a

Re: cgi problem

2006-03-08 Thread Kent Johnson
Paul Rubin wrote: > I'm trying to write a simple cgi that reads a post from the user's > browser, does some stuff with the form data, and redirects the browser > back to the originating url, i.e. I want the cgi to send a 302 > redirect. > > There's no obvious way in the cgi module to set the respo

Re: generators shared among threads

2006-03-08 Thread Kent Johnson
Paul Rubin wrote: > Hmm (untested, like above): > > class Synchronized: >def __init__(self, generator): > self.gen = generator > self.lock = threading.Lock() >def next(self): > self.lock.acquire() > try: > yield self.gen.next

Re: Getting File Permissions

2006-03-07 Thread Kent Johnson
Hari wrote: > Hi, > For getting permissions of a file, the following script has been > suggested in the same group > > import os, stat > st = os.stat(myfile) > mode = st[stat.ST_MODE] > print "mode is", octal(mode & 0777) > > But while executing I am getting error message as follows > > Tracebac

Re: Mixin class error

2006-03-06 Thread Kent Johnson
Ed Leafe wrote: > On Mar 6, 2006, at 8:08 PM, Kent Johnson wrote: >> One workaround might be to use delegation instead of subclassing... > > Yeah, but that would involve a lot more work at this point. The > mixin approach has been working quite well up until this p

Re: Is this not infinite?

2006-03-06 Thread Kent Johnson
John Salerno wrote: > From a book: > > class Derived(Base): > def __init__(self, etc): > self.__init__(self, etc...) This should be def __init__(self, etc): Base.__init__(self, etc...) or possibly def __init__(self, etc): super(Derived, self).

Re: Does '#hash' mean anything in IDLE?

2006-03-06 Thread Kent Johnson
Paul Rubin wrote: > Scott David Daniels <[EMAIL PROTECTED]> writes: >>Using a variant of DSU (Decorate-Sort-Undecorate) with max for S, >>rather than sort: >> >> print max((len(words), words) for words in d.itervalues()) >>or: >> size, words = max((len(words), words) for words in d.itervalu

Re: Python and Java

2006-03-06 Thread Kent Johnson
JKPeck wrote: > Suppose you have an application written in Java, and you want to enable > other applications or processes written in Python to communicate with > it, i.e., to use Python as a scripting language for the application. > On Windows you could do this with COM and various addons such as >

Re: Mixin class error

2006-03-06 Thread Kent Johnson
Ed Leafe wrote: > In Dabo, we create cursor classes that combine the backend-specific > dbapi cursor class with our own mixin class that adds framework- > specific behaviors. This has been working well for a couple of years > now with many different backends, but today I'm getting errors w

Re: Suggesting the use of StandardError as base of error Exceptions.

2006-03-06 Thread Kent Johnson
Diez B. Roggisch wrote: > Antoon Pardon schrieb: >> Now I was wondering if it wouldn't be better that for exception >> that indicate some error condition that these would inherit >> from StandardError and that this would be indicated in the >> documentation and reflected in the stdlib? >> >> Would

Re: Python version of XMLUnit?

2006-03-06 Thread Kent Johnson
Benjamin Niemann wrote: > http://www.logilab.org/projects/xmldiff > > You'd still have to integrate this into your test framework though... Thanks, that looks promising. > > And I'll have a look at XMLUnit - seem's like something I could use for my > current project ;) XMLUnit is *very* useful.

Re: Package organization: where to put 'common' modules?

2006-03-05 Thread Kent Johnson
Paul Boddie wrote: > Yes, Python does this - it puts the directory of bar.py (B in this > case) in sys.path, but not the directory in which you're sitting when > you run the program from the shell (A in this case). This seems to be OS dependent. If I put 'print sys.path' at the start of site.py (

Re: Package organization: where to put 'common' modules?

2006-03-05 Thread Kent Johnson
fortepianissimo wrote: > Hm this doesn't work. Say I have the following directory structure: > A > |--- util > ||--- foo.py > | > |--- B > |--- bar.py > > And bar.py has this line > > from util import foo > > I then run > > python B/bar.py > > in directory A. Still got er

Python version of XMLUnit?

2006-03-05 Thread Kent Johnson
I have found XMLUnit to be very helpful for testing Java and Jython code that generates XML. At its heart XMLUnit is an XML-aware diff - it parses expected and actual XML and pinpoints any differences. It is smart enough to ignore things like attribute order, different quoting and escaping styl

Re: how to overload sqrt in a module?

2006-03-05 Thread Kent Johnson
Michael McNeil Forbes wrote: > Is there anything really bad about the > following? It works exactly as I would like, but I don't want to get in > trouble down the road: > > module_f > > import math as my_math > > def set_math(custom_math): > globals()['my_math'] = custom_math Thi

Re: spliting on ":"

2006-03-04 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > hi > > i have a file with > > xxx.xxx.xxx.xxx:yyy > xxx.xxx.xxx.xxx:yyy > xxx.xxx.xxx.xxx:yyy > xxx.xxx.xxx.xxx > xxx.xxx.xxx.xxx > xxx.xxx.xxx.xxx:yyy > > i wanna split on ":" and get all the "yyy" and print the whole line out > so i did > > print line.split(":")[-1]

Re: Package organization: where to put 'common' modules?

2006-03-04 Thread Kent Johnson
fortepianissimo wrote: > Say I have the following package organization in a system I'm > developing: > > A > |B > |C > |D > > I have a module, say 'foo', that both package D and B require. What is > the best practice in terms of creating a 'common' package that hosts > 'foo'

Re: Convert dictionary to HTTP POST

2006-03-03 Thread Kent Johnson
Laszlo Zsolt Nagy wrote: > The values of some inputs are encoded using html entities. > How can I decode a string like "Bessy's cat" in "Bessy's cat"? http://groups.google.com/group/comp.lang.python/browse_frm/thread/819731a536a4c1a2/fce6c2f6c3d46e9c?q=htmlentitydefs&rnum=2#fce6c2f6c3d46e9c Kent

Re: object's list index

2006-03-03 Thread Kent Johnson
William Meyer wrote: > hi, > > I need to get the index of an object in a list. I know that no two objects > in the list are the same, but objects might evaluate as equal. for example > > list = [obj1, obj2, obj3, obj4, obj5] > for object in list: > objectIndex = list.index(object) > p

<    1   2   3   4   5   6   7   >