"and" and "or" on every item in a list
Is this the best way to test every item in a list? def alltrue(f,l): return reduce(bool.__and__,map(f,l)) def onetrue(f,l): return reduce(bool.__or__,map(f,l)) >>> alltrue(lambda x:x>1,[1,2,3]) False >>> >>> alltrue(lambda x:x>=1,[1,2,3]) True >>> Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: "and" and "or" on every item in a list
Thanks for the answers, I suspected something like any(), all() existed. Also got me thinking about generator expressions, my code is full of list comprehensions for lists I don't keep. -- http://mail.python.org/mailman/listinfo/python-list
Re: Noob question
Had the same issue. What you want is: reload() -- http://mail.python.org/mailman/listinfo/python-list
Re: Recommended SOAP library?
if you require a SOAP client, then I would recommend SUDS https://fedorahosted.org/suds/ Other options are not in active development, so is difficult to get support. -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing paramiko and pycrypto
I installed from here: http://bazaar-vcs.org/WindowsInstall first pycrypto-2.0.1.win32-py2.5.zip then paramiko-1.7.1-ctypes.win32.exe -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is there no GUI-tools like this for Windows?
There is http://www.codeplex.com/IronPythonStudio -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I compare files?
On Jul 23, 1:27 am, Clay Hobbs <[EMAIL PROTECTED]> wrote: > I am making a program that (with urllib) that downloads two jpeg files > and, if they are different, displays the new one. I need to find a way > to compare two files in Python. How is this done? > > -- Ratfink import hashlib file = open(path) m = hashlib.md5() m.update(file.read()) digest = m.hexdigest() file.close() and compare the digest on both files -- http://mail.python.org/mailman/listinfo/python-list
filter in for loop
I would like to say something like: for x in l if : e.g. for filename in os.listdir(DIR) if filename[-4:] == '.xml': instead of having to say: for filename in os.listdir(DIR): if filename[-4:] == '.xml': or for filename in (f for f in os.listdir(DIR) if f[-4] == '.xml'): is there a shortcut I'm missing? -- http://mail.python.org/mailman/listinfo/python-list
