fcntl.fcntl breaking on 64bit
Hello Friends: I'm running into issues with using fcntl on a 64 bit servers. Python version: 2.4.3 system Arch: # uname -m x86_64 code keeps erroring out with: fcntl.fcntl(fd, rhn_fcntl.F_SETLKW, UNLOCK) IOError: [Errno 22] Invalid argument The same python code block runs fine on a i386/686. Does anyone have any thoughts? Is this a known issue? any workarounds? Any suggestions appreciated. Thanks, ~ PK -- http://mail.python.org/mailman/listinfo/python-list
nested looping
So I'm trying to see whats the cleanest way to do this: I have a checklist = [ax, bx, by, cy ..] (a combination of a,b,c with x and y, either both on one) allist = [a,b,c,] xlist = [x, y, ..] now I wanna loop through alist and xlist and see if the combination exists in checklist so something like, for alpha in alist: for xy in xlist: if alpha+xy not in checklist: missing.append(alpha) now the problem is I want to include alpha in missing list only if none of the combinations from xlist with alpha are in checklist. The above will exclude the possibility where ax doesn't exist but ay or az does exist. Hope There is a cleaner way to accomplish this. Thanks in advance, PK -- http://mail.python.org/mailman/listinfo/python-list
Re: nested looping
Excellent! Thanks all. Since I need to have this running on python 2.4 as well, I think I'll choose, for alpha in alist: for xy in xlist: if alpha+xy in checklist: break else: missing.append(alpha) jus tested and worked like a charm. Appreciate your help!! On Wed, Apr 8, 2009 at 6:12 PM, Luis Alberto Zarrabeitia Gomez wrote: > > Quoting PK : > > > So I'm trying to see whats the cleanest way to do this: > > > > I have a > > > > checklist = [ax, bx, by, cy ..] (a combination of a,b,c with x and y, > > either both on one) > > > > allist = [a,b,c,] > > xlist = [x, y, ..] > > > [...] > > now the problem is I want to include alpha in missing list only if > > none of the combinations from xlist with alpha are in checklist. > > This is untested: > > for alpha in alist: >for xy in xlist: > if alpha+xy in checklist: >break >else: >missing.append(alpha) > > (note that the "else" is for the "for", not the "if") > > You could also try the any/all functions from python2.5: > > for alpha in alist: >if not any(alpha + xy in checklist for xy in xlist): >missing.append(alpha) > > > Or the really not recommended one-liner: > > missing = [alpha for alpha in alist if not any(alpha + xy in checklist for > xy in > xlist)] > > (remember, all of this is untested) > > -- > Luis Zarrabeitia > Facultad de Matemática y Computación, UH > http://profesores.matcom.uh.cu/~kyrie<http://profesores.matcom.uh.cu/%7Ekyrie> > > > -- > Participe en Universidad 2010, del 8 al 12 de febrero de 2010 > La Habana, Cuba > http://www.universidad2010.cu > > -- http://mail.python.org/mailman/listinfo/python-list
identify checksum type?
Given a checksum value, whats the best way to find out what type it is? meaning. I can use hashlib module and compute a md5 or sha1 for a given data etc..but given a checksum value say "d2bda52ee39249acc55a75a0f3566105" whats the best way for me to identify if its a sha1 or md5 or anyother sum type for that matter? is there a nice way to do this in python? ~ PK -- http://mail.python.org/mailman/listinfo/python-list
how should i add extension and unzip again?
This script untars .gz file to file without extension import gzip import glob import os.path import tarfile source_dir = "C:\\TEST" dest_dir = "C:\\TEST" for src_name in glob.glob(os.path.join(source_dir, '*.gz')): base = os.path.basename(src_name) dest_name = os.path.join(dest_dir, base[:-3]) with tarfile.open(src_name, 'r') as infile: with open(dest_name, 'w') as outfile: for line in infile: outfile.write(str(line)) - but i know it is a compressed file so I need to add extension .zip to it and run untar/unzip one more time so it will fully unzip to folders and files, not sure how, can someone help please? Thank you. -- https://mail.python.org/mailman/listinfo/python-list
Re: how should i add extension and unzip again?
On Wednesday, March 18, 2015 at 4:58:34 PM UTC-7, MRAB wrote: > On 2015-03-18 23:22, PK Khatri wrote: > > This script untars .gz file to file without extension > > > > import gzip > > import glob > > import os.path > > import tarfile > > > > source_dir = "C:\\TEST" > > dest_dir = "C:\\TEST" > > for src_name in glob.glob(os.path.join(source_dir, '*.gz')): > > base = os.path.basename(src_name) > > dest_name = os.path.join(dest_dir, base[:-3]) > > with tarfile.open(src_name, 'r') as infile: > > with open(dest_name, 'w') as outfile: > > for line in infile: > > outfile.write(str(line)) > > - > > but i know it is a compressed file so I need to add extension .zip to it > > and run untar/unzip one more time so it will fully unzip to folders and > > files, not sure how, can someone help please? > > Thank you. > > > > There's a method called 'extractall': > > with tarfile.open(src_name, 'r') as infile: > infile.extractall(dest_dir) Wow!! Thank you so much, that did it. thank you. PK. -- https://mail.python.org/mailman/listinfo/python-list
How to use regex (re)
I have a following script which extracts xyz.tgz and outputs to a folder which contains several sub-folders and files. source_dir = "c:\\TEST" dest_dir = "c:\\TEST" for src_name in glob.glob(os.path.join(source_dir, '*.tgz')): base = os.path.basename(src_name) dest_name = os.path.join(dest_dir, base[:-4]) with tarfile.open(src_name, 'r') as infile: infile.extractall(dest_dir) When above script is ran, the output is a single directory within that directory the structure looks like this: folder_1 folder_2 folder_n file_1 file_2 file_n In these folder, there are sub-folders and files. Among those file there are some data i am interested in to search and output to a file. For eg. Among the folders there is a file called **'localcli_network-ip-neighbor-list.txt**' which contains IP address(s) which I would like to output to a file. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to use regex (re)
On Friday, August 7, 2015 at 9:48:35 AM UTC-7, Peter Pearson wrote: > On Thu, 6 Aug 2015 13:06:36 -0700 (PDT), PK Khatri wrote: > > I have a following script which extracts xyz.tgz and outputs to a > > folder which contains several sub-folders and files. > > > > source_dir = "c:\\TEST" > > dest_dir = "c:\\TEST" > > for src_name in glob.glob(os.path.join(source_dir, '*.tgz')): > > base = os.path.basename(src_name) > > dest_name = os.path.join(dest_dir, base[:-4]) > > with tarfile.open(src_name, 'r') as infile: > > infile.extractall(dest_dir) > > > > When above script is ran, the output is a single directory within that > > directory the structure looks like this: > > > > folder_1 > > folder_2 > > folder_n > > file_1 > > file_2 > > file_n > > > > In these folder, there are sub-folders and files. Among those file > > there are some data i am interested in to search and output to a file. > > > > For eg. Among the folders there is a file called > > **'localcli_network-ip-neighbor-list.txt**' which contains IP > > address(s) which I would like to output to a file. > > Are you asking how to determine whether the string > "localcli_network-ip-neighbor-list.txt" appears in a filename? > If so, the logical expression > > "localcli_network-ip-neighbor-list.txt" in filename > > will do the job. > > -- > To email me, substitute nowhere->runbox, invalid->com. Thanks Peter. -- https://mail.python.org/mailman/listinfo/python-list
Geeting the error Open failed: : Expected BOF record; found 0x3f3c
hallo everybody, when i m running the command python runxlrd.py 3rows a.xls i m getting the following error === File: a.xls === *** Open failed: : Expected BOF record; found 0x3f3c what is the reason regards prasanna -- http://mail.python.org/mailman/listinfo/python-list
getting error...... Traceback (most recent call last): File "", line 1, in File "C:\Python25\Lib\site-packages\xlrd\__init__.py", line 370, in open_workbook biff_version = bk.getbof(XL
hallo everybody,
when i am running the following command
>>> import xlrd
>>> book=xlrd.open_workbook("C:\\a.xls")
i am getting the following error..
*Traceback (most recent call last):
File "", line 1, in
File "C:\Python25\Lib\site-packages\xlrd\__init__.py", line 370, in
open_workb
ook
biff_version = bk.getbof(XL_WORKBOOK_GLOBALS)
File "C:\Python25\Lib\site-packages\xlrd\__init__.py", line 1323, in
getbof
raise XLRDError('Expected BOF record; found 0x%04x' % opcode)
xlrd.biffh.XLRDError: Expected BOF record; found 0x3f3c*
what is the reason
pz help me out..
regards
prasanna
*
*
--
http://mail.python.org/mailman/listinfo/python-list
