code to retrieve web mail?
I have a free web mail address and would like to use python to retrieve files that have been emailed to me. The basic code would accommodate cookies, a login name and password, then download using the full URL I can provide. From postings here I thought mechanize held promise, but I've found it to contain filenames that are invalid for MSDOS (too many characters, and/or too many dots in the name, etc.) so I have little hope that the mechanize module can be used. I'm running python2.4.2 on plain MSDOS (not windows), so would appreciate a pointer to sample code that can do the job. I know that curl has this capability, but I'll learn something by tinkering with python code. Thanks. -- John Savage (my news address is not valid for email) -- http://mail.python.org/mailman/listinfo/python-list
Re: Hiding Console Output
"Kkaa" <[EMAIL PROTECTED]> writes: >I'm using the os.system command in a python script on Windows to run a >batch file like this: > >os.system('x.exe') Is .exe really a batch file? >The third-party program x.exe outputs some text to the console that I >want to prevent from being displayed. Is there a way to prevent the >output of x.exe from python? To consign stdout to nul in MSDOS you can use os.system('x.exe>nul') so that will probably work for windows, too. This works regardless of x.exe or x.bat so should do for whatever type of prog you are wanting it for. -- John Savage (my news address is not valid for email) -- http://mail.python.org/mailman/listinfo/python-list
Re: Why do I require an "elif" statement here?
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: >--- >whitespace = " " >old_indent = 3 >new_indent = 5 > >x = " starts with 3 spaces" > >x = x.replace(whitespace*old_indent, whitespace*new_indent) >--- > >In this example though, it will replace the 3 spaces no matter where >they are at, not just in the beginning... still, it's probably more >practical for most use cases. You'd corner it with: if x.startswith(' '*3): x=x.replace(' '*3,' '*5,1) -- John Savage (my news address is not valid for email) -- http://mail.python.org/mailman/listinfo/python-list
ERROR "no mem to add parser accelerator"
When I attempt to run the MSDOS version of python I get the error message "no mem to add parser accelerator" and am returned to the DOS prompt. Yet I've been successfully running this python executable for months on this pc and as far as I know I haven't changed anything that could have upset python. Any ideas on a fix? I'm giving it 620k of conventional memory to play with. -- John Savage (my news address is not valid for email) -- http://mail.python.org/mailman/listinfo/python-list
Re: To remove some lines from a file
Sebastian Busch <[EMAIL PROTECTED]> writes: >The task is: > >"Remove the first two lines that don't begin with "@" from a file." > >How would you do it with sed? Why a sed solution in a python group? sed '/^@/!{G;/\n\n\n/{P;d;};s/[^\n]*//;h;d;}' data -- John Savage (my news address is not valid for email) -- http://mail.python.org/mailman/listinfo/python-list
Re: Writing to a certain line?
"Tommy B" <[EMAIL PROTECTED]> writes: >I was wondering if there was a way to take a txt file and, while >keeping most of it, replace only one line. See, I'd have a file like: .. >Is there any easy way to do this? An easy way? If you know how many bytes in from the start of the file your desired changes are to be positioned, the utility of choice is the strange but wonderful "dd" for Unix, MSwindows, MSDOS, etc. That's its name: dd. Are you planning to execute a call to dd from within a python program? Of course, you are constrained to substituting N bytes with another N bytes, exactly. -- John Savage (my news address is not valid for email) -- http://mail.python.org/mailman/listinfo/python-list
Re: Segmentation Fault
"pycraze" <[EMAIL PROTECTED]> writes: >I would like to ask a question. How do one handle the exception due to >Segmentation fault due to Python ? Our bit operations and arithmetic >manipulations are written in C and to some of our testcases we >experiance Segmentation fault from the python libraries. You don't happen to be using the MSDOS executable do you? I find I get a segmentation violation with the MSDOS version when I try to print coloured text. I think I have narrowed it down further: to the situation where coloured text extends to or beyond the edge of the screen--maybe it's the text wrapping that causes the seg fault. -- John Savage (my news address is not valid for email) -- http://mail.python.org/mailman/listinfo/python-list
Re: deleting texts between patterns
Tim Chase <[EMAIL PROTECTED]> writes: >> I wish to delete lines that are in between 'abc' and >> 'xyz' and print the rest of the lines. Which is the best >> way to do it? > >sed -n -e'1,/abc/p' -e'/xyz/,$p' file.txt > >which is pretty straight-forward. While it looks neat, it will not work when /abc/ matches line 1. Non-standard versions of sed, e.g., GNU, allow you to use 0,/abc/ to neatly step around this nuisance; but for standard sed you'll need a more complicated sed script. -- John Savage (my news address is not valid for email) -- http://mail.python.org/mailman/listinfo/python-list
python's YENC.DECODE -> weird output
I save posts from a midi music newsgroup, some are encoded with yenc encoding. This gave me an opportunity to try out the decoders in Python. The UU decoder works okay, but my YENC effort gives results unexpected: import yenc, sys fd1=open(sys.argv[1],'r') #yenc.encode(sys.argv[1],"outfile.yenc",bytes=0) yenc.decode(sys.argv[1],"outfile.mid",bytes=0,crc_in='') I confirmed that yenc.decode exactly reverses yenc.encode, BUT the encoding itself seems to differ from the USENET standard. That is, when I decode USENET files the result isn't a valid music file. (I did try both with and w/o the headers.) Maybe it uses a different character set? I can't quite put my finger on what might be happening. What I can say is that the yenc coding from the newsgroup article, when viewed with Linux 'more', displays roughly 10% of its characters as a question mark, whereas when I give Python's yenc.encode a binary music file and view its output using 'more', it displays about 90% of the output as a question mark. Any ideas? -- John Savage(my news address is not valid for email) -- http://mail.python.org/mailman/listinfo/python-list
Q's: pythonD and range(1,12)
I've very new to python, and am currently toying with pythonD. Could someone please explain the rationale behind python designers' thinking in deciding the function "range(1,12)" should return the sequence 1 to 11 rather than the more intuitively-useful 1 to 12?? After downloading the substantial distribution .zip file, I'm intrigued to find it includes 3 files of identical size and creation date, differing apparently only in name (python, python2.4 and python24.exe) and each of exactly 2,597,888 bytes. What possible purpose could be served by such triplication that couldn't more efficiently be done by other means? Naive but curious minds wish to know! -- John Savage (my news address is not valid for email) -- http://mail.python.org/mailman/listinfo/python-list
interrupting pythonD with ^C
I'm finding that many times when I inadvertently code an endless loop in pythonD code, on MSDOS, execution cannot be interrupted by ctrl-C and I am forced to reboot and this is rapidly loses its novelty. Do users of pythonD have a coding technique, or a library file to include, to endow a program with keyboard interrupt-ability? Endless loops arise when I forget to increment a loop index, or code incorrectly the end condition test, or indent wrongly, etc. -- John Savage (my news address is not valid for email) -- http://mail.python.org/mailman/listinfo/python-list