Fwd: Issues in python 3.11.0 (64-bit) installation
-- Forwarded message - From: Suresh Babu Date: Thu, 3 Nov 2022, 16:37 Subject: Issues in python 3.11.0 (64-bit) installation To: Sir/ Madam, I downloaded the latest version of python i.e. python 3.11.0 ( 64-bit) in my laptop recently. But the " py launcher " and " available for all users " option is not working in the customization menu of python 3.11.0 . Kindly help me in solving this issue. My operating system is Windows 11. Kindly guide me in this regard. Yours sincerely, Sureshbabu. -- https://mail.python.org/mailman/listinfo/python-list
Re: module: zipfile.writestr - line endings issue
Paul Carter wrote: > On Aug 14, 1:32 pm, towers <[EMAIL PROTECTED]> wrote: >> Thanks - your code works for me also. >> >> But I still get the issue when I read the file directly and add it to >> the archive. >> >> Say if I: >> >> 1. Use the test.csv file created with your code - currently the line >> endings look good (viewed in notepad on Win XP) >> 2. Run the following code: >> >> # begin code >> import zipfile >> import os.path >> >> # Now, create the zipfile >> dfile = open('test.csv', 'r') >> zip_file = zipfile.ZipFile(r'C:\temp\ice\line endings\test.zip', 'w', >> zipfile.ZIP_DEFLATED) >> zip_file.writestr('test.csv',dfile.read()) >> dfile.close() >> zip_file.close() >> >> 3. Then extract the file and the file endings have been corrupted. Now >> one long line in notepad. (Other programs interpret correctly though.) >> >> Maybe the issue lies with this way (i.e. dfile.read()) of writing the >> file to the archive...possibly. >> >> Damon >> > > Please don't top post. > > The problem is with how you are opening the file. You need to open in > binary mode if you wish to read your file unaltered. Also, file() is > preferred over open() these days I think. Use: > > dfile = file('test.csv', 'rb') From Python 2.5 library documentation. When opening a file, it's preferable to use `open()' instead of invoking this constructor directly. `file' is more suited to type testing (for example, writing `isinstance(f, file)'). Python documentation seem to recommend using open(). I personally prefer to use open, just because python open has same signature as POSIX open, even beginner programmers can understand the intent of the code clearly. Kolla -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess -popen - reading stdout from child - hangs
[EMAIL PROTECTED] wrote: > Let's say I have this Python file called loop.py: > > import sys > print 'hi' > sys.stdout.flush() > while 1: > pass > > And I want to call it from another Python process and read the value > 'hi'. How would I do it? > > So far I have tried this: > proc = subprocess.Popen('python /home/chiefinnovator/loop.py',shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE) proc.stdout.read() > From python documentation `read([size])' Read at most SIZE bytes from the file (less if the read hits `EOF' before obtaining SIZE bytes). If the SIZE argument is negative or omitted, read all data until `EOF' is reached. The bytes are returned as a string object. An empty string is returned when `EOF' is encountered immediately. (For certain files, like ttys, it makes sense to continue reading after an `EOF' is hit.) Note that this method may call the underlying C function `fread()' more than once in an effort to acquire as close to SIZE bytes as possible. Also note that when in non-blocking mode, less data than what was requested may be returned, even if no SIZE parameter was given. read call in your code is waiting for EOF, since the script never exits EOF is not reached. Change read code to proc.stdout.readline() or remove while 1 loop from loop.py. HTH Kolla -- http://mail.python.org/mailman/listinfo/python-list