[FAQTS] Python Knowledge Base Update -- October 29th, 2000
Hi Guys, What's happened in the python knowledge base since last post(9/10). regards, Fiona Czuczman ## Unanswered Questions ######################################## ------------------------------------------------------------- How do I get the UID from os.stat mapped to a real username in NT? http://www.faqts.com/knowledge-base/view.phtml/aid/6374 ------------------------------------------------------------- Lance ------------------------------------------------------------- I'm getting an error stating that "None" object has no attribute "groups" during setup of numpy, any ideas? http://www.faqts.com/knowledge-base/view.phtml/aid/6245 ------------------------------------------------------------- Michael Risser ------------------------------------------------------------- how can i create a pop up window with entry on it, so that i can get the value from the entry and process it with the original frame, thanks http://www.faqts.com/knowledge-base/view.phtml/aid/6347 ------------------------------------------------------------- tony zhang ------------------------------------------------------------- How do you access the printer from Python under Linux??? http://www.faqts.com/knowledge-base/view.phtml/aid/6376 ------------------------------------------------------------- Dave Berry ------------------------------------------------------------- How do I check and retrieve the error conditions & message of script executed via the Python/C API (without using PyErr_Print) http://www.faqts.com/knowledge-base/view.phtml/aid/6234 ------------------------------------------------------------- Kostas Karanikolas ## New Entries ################################################# ------------------------------------------------------------- How can I get my _full_ program name (eg. "mylongpythonscript.py") under eg. NT? sys.argv[0] gives me the truncated MS-DOS style, "MYLONG~1.PY" etc. http://www.faqts.com/knowledge-base/view.phtml/aid/6159 ------------------------------------------------------------- Jon Nicoll, Fiona Czuczman Alex Martelli This seems to work in my setup (2.0b2, Win98): import sys try: raise RuntimeError except: x=sys.exc_info()[2] print x.tb_frame.f_code.co_filename Placing this in alongfilename.py and running python alongfilename.py results in the expected output: alongfilename.py ################################################## # Under (NT4, Python v1.5.2), the above also gives # the 'short' form for me. # This is a bit more Win32 specific, but works for my environment import sys import win32api print win32api.FindFiles(sys.argv[0])[0][8] ## Edited Entries ############################################## ------------------------------------------------------------- Where can I best learn how to parse out both HTML and Javascript tags to extract text from a page? http://www.faqts.com/knowledge-base/view.phtml/aid/3680 ------------------------------------------------------------- Paul Allopenna, Matthew Schinckel, Magnus Lyckå Python Documentation If you want to (quickly) strip all HTML tags from a string of data, try using the re module: import re file = open(filename,'r') data = file.read() file.close() text = re.sub('<.*?>', '', data) #Remove comments first, or '>' in #comments will be interpreted as #end of (comment) tag. text = re.sub('<!--.*?-->', '', text) This will also strip any javascript, but only if the page has been made 'properly' - that is, the javascript is within HTML comments. If you want to know how it works, read the 're' chapter in the library reference, as it discusses the usefulness of 'non-greedy' regular expressions. ------------------------------------------------------------- How do I change the name of a process (as viewed by 'ps') from Python? http://www.faqts.com/knowledge-base/view.phtml/aid/6149 ------------------------------------------------------------- Adam Feuer, Fiona Czuczman Oleg Broytmann Don't know much about Mac. Probably, there is no such thing as "process name". :) On Windows, it is possible, and I saw a code doing that. Probably, Mark Hammond was the author, if I remember it right. On UNIX it is impossible now. To do this, someone will need to wrap one of "setproctitle" sources. The most known code is "setproctitle" from sendmail, but it accompanied with not-so-free license. More liberal license is for similar code in PostgreSQL, so if anyone is interested to do some work and produce a working module - PostgreSQL is a good place to start.
participants (1)
-
Fiona Czuczman