Converting HTML to ASCII
Hi. I'm looking for a Python lib to convert HTML to ASCII. Of course, a quick Google search showed several options (although, I must say, less than I would expect, considering how easy this is to do in *other* languages... :| ), but, I have 2 requirements, which none of them seem to meet: 1) Be able to handle badly formed, or illegal, HTML, as best as possible. Some of the converters I tried ended up dieing on a weird character (that is, a high ascii char). Others somehow got confused and dumped the JavaScript as well. 2) Not embellish the text in any way - no asterisks, no bracket links, no __ for underlines. Can anyone direct me to something which could help me for this? --Thanks a mil. __ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail -- http://mail.python.org/mailman/listinfo/python-list
Flushing print()
Is there any way to make Python's print() flush automatically, similar to...mmm...that other language's $|=1 ? If not, how can I flush it manually? sys.stdout.flush() didn't seem to work. __ Do you Yahoo!? Yahoo! Mail - now with 250MB free storage. Learn more. http://info.mail.yahoo.com/mail_250 -- http://mail.python.org/mailman/listinfo/python-list
Trace exceptions
Is there anyway to do something like this: try: ... except Exception: print the Exception message (and maybe other info) __ Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. http://promotions.yahoo.com/new_mail -- http://mail.python.org/mailman/listinfo/python-list
Converting HTML to ASCII
Hans, Thanks for the tip. I took a look at Beatiful Soup, and it looked like it was a framework to parse HTML. I'm not really interetsed in going through it tag by tag - just to get it converted to ASCII. How can I do this with B. Soup? --Thanks PS William - thanks for the reference to lynx, but I need a Python solution - forking and execing for each file I need to convert is too slow for my application Hans wrote: Try Beautiful Soup! > 1) Be able to handle badly formed, or illegal, HTML, > as best as possible. From the description: "It won't choke if you give it ill-formed markup: it'll just give you access to a correspondingly ill-formed data structure." > Can anyone direct me to something which could help me > for this? http://www.crummy.com/software/BeautifulSoup/ Hans Christian __ Do you Yahoo!? Yahoo! Mail - Easier than ever with enhanced search. Learn more. http://info.mail.yahoo.com/mail_250 -- http://mail.python.org/mailman/listinfo/python-list
Making things more functional in Python
Is there a better, more FP style, more Pythonic way to write this: def compute_vectors(samples, dset): vectors = {} for d in dset: vectors[d] = [sample.get_val(d) for sample in samples] return vectors Namely, I'd like to get rid of the initilization (vectors = {}) and also the loop Yet, I'd hate to put an assignment into Python's FP list comprehensions. Ideally, I'd like something like this: vectors.dict_add({d:result}) for [sample.get_val(d) for sample in samples for d in dset]. Is there anything like that? Am I missing the picture? Thanks. PS If possible, please cc me on all responses, thanks. __ Celebrate Yahoo!'s 10th Birthday! Yahoo! Netrospective: 100 Moments of the Web http://birthday.yahoo.com/netrospective/ -- http://mail.python.org/mailman/listinfo/python-list
Dictionaries of Lists
I'd like to associate certain lists with keywords, and retrieve them. But this is not possible as lists are not hashable. What is the best workaround? I don't mind making my lists immutable. Is there a way to tupelize them? I tried mydict[mykey]=([a for a in list]) but it didn't seem to work. Thanks! PS If possible please cc me on all responses. __ Celebrate Yahoo!'s 10th Birthday! Yahoo! Netrospective: 100 Moments of the Web http://birthday.yahoo.com/netrospective/ -- http://mail.python.org/mailman/listinfo/python-list
Why is lower() deprecated and how should I replace it?
I read that lower() is deprecated. Unfortunately, I can't find the preferred way of lowercasing a string. What is it? Thanks PS Please cc me on all responses. __ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ -- http://mail.python.org/mailman/listinfo/python-list
Dumping an instance
If I want to dump (for debugging) an instance and all of it's member attributes, what's the simplest way? print myInstance just gives a pointer to its location in memory Thanks! __ Do you Yahoo!? Yahoo! Mail - 250MB free storage. Do more. Manage less. http://info.mail.yahoo.com/mail_250 -- http://mail.python.org/mailman/listinfo/python-list
Python Debug logging
Is there a simple way to log to a debug console in Python? In .NET, you can Debug.Write(str), which does nothing if there is no debug console open, but, if there is, debugs the message. Is there something similar? Alternatively, is there a very simple log4j type setup? I emphasize very simple, since, for me, having to go through all the log4j xml configuration defeats the purpose of coding quickly in python anyway... I'm looking for something along the lines of log4p(DEBUG, str) and then just a one line config somewhere log4p.DEBUG=stderr or =/dev/null Anything like this? Thanks PS Please cc me on all responses, muchos gracias __ Do you Yahoo!? Make Yahoo! your home page http://www.yahoo.com/r/hs -- http://mail.python.org/mailman/listinfo/python-list
Calling a Perl Module from Python
I've recently made the switch. Wow, is Python great! One thing which I haven't been able to do is replace Perl's great lib collection (HTML::Parser, for instance, can do a lot that Soup just can't). Is there anyway to call Perl modules from Python? Thanks PS Please cc me on all responses __ Do you Yahoo!? Yahoo! Mail - Find what you need with new enhanced search. http://info.mail.yahoo.com/mail_250 -- http://mail.python.org/mailman/listinfo/python-list
Re: Calling a Perl Module from Python ( future direction of Python)
Really! That's a pity... Instead of trying to recreate a repository the size of CPAN, a Python interface to Perl modules is really called for. Instead of fretting over decorator syntax and lispiness, might I suggest that development efforts be directed to this? Developers, are you listening? Guido? PS And I don't mean waiting for Perl 6 to condense... --- Swaroop C H <[EMAIL PROTECTED]> wrote: > On Apr 6, 2005 8:23 AM, gf gf > <[EMAIL PROTECTED]> wrote: > > I've recently made the switch. Wow, is Python > great! > > One thing which I haven't been able to do is > replace > > Perl's great lib collection (HTML::Parser, for > > instance, can do a lot that Soup just can't). > > You've just discovered the only limitation of Python > (in my view) - it > doesn't have a module repository to rival CPAN. > > AFAIK, there isn't any reliable way to call Perl > modules from Python. > > > -- > Swaroop C H > Blog: http://www.swaroopch.info > Book: http://www.byteofpython.info > __ Yahoo! Messenger Show us what our next emoticon should look like. Join the fun. http://www.advision.webevents.yahoo.com/emoticontest -- http://mail.python.org/mailman/listinfo/python-list