Re: How to improve writing code in python?

2013-02-06 Thread Piet van Oostrum
Banh banh0...@gmail.com writes: Hi, I have a problem with learning Python. My code is really bad and I can't solve many problems. I really want to improve it. Do you know any website which helps me to learn python effectively (for beginners)? This is my first programming language and I am

Re: How to improve writing code in python?

2013-02-06 Thread Jean-Michel Pichavant
- Original Message - Hi, I have a problem with learning Python. My code is really bad and I can't solve many problems. I really want to improve it. Do you know any website which helps me to learn python effectively (for beginners)? This is my first programming language and I am

Re: How to improve writing code in python?

2013-02-06 Thread rusi
On Feb 6, 4:52 am, Banh banh0...@gmail.com wrote: Hi, I have a problem with learning Python. My code is really bad and I can't solve many problems. I really want to improve it. Do you know any website which helps me to learn python effectively (for beginners)? This is my first programming

Re: How to improve this code?

2009-09-18 Thread Sergey Simonenko
elements_present = lambda seq, match: any(((x in match) for x in seq)) On Mon, 14 Sep 2009 19:08:59 -0600, Oltmans rolf.oltm...@gmail.com wrote: Hello, Is there someway I can improve the following code(pythonically)? (Copying from IDLE) match=[1,2,3,4,5] def elementsPresent(aList):

Fwd: Re: How to improve this code?

2009-09-16 Thread Hendrik van Rooyen
From a private email, forwarded to the list: -- Forwarded Message -- Subject: Re: How to improve this code? Date: Tuesday 15 September 2009 From: Oltmans rolf.oltm...@gmail.com To: hend...@microcorp.co.za On Sep 15, 1:13 pm, Hendrik van Rooyen hend...@microcorp.co.za wrote

Re: Fwd: Re: How to improve this code?

2009-09-16 Thread Thomas Lehmann
otherwise. Given this, I'm just trying to write a method are_elements_present(aList) whose job is to return True if and only if all elements in aList are present in page's HTML. So here is how missingItems = [str(ele) for ele in eleLocators if not selenium.is_element_present(ele)] if

Re: Fwd: Re: How to improve this code?

2009-09-16 Thread Duncan Booth
Hendrik van Rooyen hend...@microcorp.co.za wrote: def are_elements_present(eleLocators): elePresent=False if not eleLocators: return False for ele in eleLocators: if selenium.is_element_present(ele): elePresent=True else:

Re: How to improve this code?

2009-09-15 Thread Hendrik van Rooyen
On Tuesday 15 September 2009 03:08:59 Oltmans wrote: match=[1,2,3,4,5] def elementsPresent(aList): result=False if not aList: return False for e in aList: if e in match: result=True else:

Re: How to improve this code?

2009-09-15 Thread Sol Toure
def are_elements_present(sourceList, searchList):for e in searchList: if e not in sourceList: return False return True Using set: def are_elements_present(sourceList, searchList): return len(set(sourceList).intersection(set(searchList)) ==

Re: How to improve this code?

2009-09-15 Thread Tim Golden
Sol Toure wrote: def are_elements_present(sourceList, searchList):for e in searchList: if e not in sourceList: return False return True Using set: def are_elements_present(sourceList, searchList): return

Re: How to improve this code?

2009-09-15 Thread Tim Golden
Tim Golden wrote: Unless I'm missing something, (and I didn't bother to read the original code so I may be) that's a subset test: set (searchList) = set (searchList) (cough) or, rather: set (searchList) = set (sourceList) TJG -- http://mail.python.org/mailman/listinfo/python-list

Re: Re: How to improve this code?

2009-09-15 Thread Dave Angel
Oltmans wrote: On Sep 15, 1:13 pm, Hendrik van Rooyen hend...@microcorp.co.za wrote: (i) a True if All the elements in match are in aList, else False? (ii) a True if any one or more of the members of match are in aList? (iii) Something else? That's a good question because I

Re: How to improve this code?

2009-09-15 Thread Andreas Waldenburger
On Mon, 14 Sep 2009 18:33:17 -0700 (PDT) André andre.robe...@gmail.com wrote: Here's an example using sets: def is_present(list_1, list_2): ...if set(list_1).intersection(set(list_2)): ... return True ...return False ... Not that it matters, but I'd probably write: def

Re: How to improve this code?

2009-09-14 Thread Diez B. Roggisch
Oltmans schrieb: Hello, Is there someway I can improve the following code(pythonically)? (Copying from IDLE) match=[1,2,3,4,5] def elementsPresent(aList): result=False if not aList: return False for e in aList: if e in match:

Re: How to improve this code?

2009-09-14 Thread André
On Sep 14, 10:16 pm, Diez B. Roggisch de...@nospam.web.de wrote: Oltmans schrieb: Hello, Is there someway I can improve the following code(pythonically)? (Copying from IDLE) match=[1,2,3,4,5] def elementsPresent(aList):    result=False    if not aList:            return False

Re: How to improve this code?

2009-09-14 Thread Tim Chase
def elementsPresent(aList, match): match = set(match) for item in aList: if item in match: return True return False This could be rewritten in Python2.5+ as def elementsPresent(aList, match): match = set(match) return any(elem in match for elem in