Re: Need A script to open a excel file and extract the data using autofilter
Prakash wrote: > Need A script to open a excel file and extract the data using > autofilter and write it in a new sheet or new file like I have to > select all rows in which all the columns contain pass as status ... try this: http://www.python-excel.org/ Regards Adam Przybyla -- http://mail.python.org/mailman/listinfo/python-list
Re: Python ++ Operator?
Chris Angelico wrote: > On Sat, Jul 16, 2011 at 6:26 AM, Dan Stromberg wrote: >> >> I don't regard this as a low level versus VHLL issue - I regard it as a >> matter of operators with side effects being too error prone. Adding such >> operators to Python has been discussed (it'd almost certainly be easy to >> add), and rejected. > > It's not that it has or has not, due to its highness of level, but > more a needs or needs not. In Python, iterating over an array is done > with a for loop and the array's own iterator (or enumerate() if you > need the indices), but C doesn't have iterators, so it needs a > convenient notation for incrementing through the array. > >> BTW, array operations optimize to the same thing as pointer arithmetic in >> most C compilers, but the latter tends to be less clear. > > I'm not fully convinced; there are many times when incrementing > pointers allows for much cleaner code. However, we are talking about > the readability of C among Python programmers. Personally, I find > pointer-dereference-and-post-increment to be perfectly readable, but > it's a construct that I use practically on a daily basis. To someone > who's not familiar with Python, list comps could suffer from the same > issues - what does THIS do? oh. list_ptr=list_a list_ptr=list_ptr[1:] Regards Adam Przybyla -- http://mail.python.org/mailman/listinfo/python-list
Re: Call python function from Matlab
nazmul.is...@gmail.com wrote: > I need to call a python function from a Matlab environment. Is it > possible? > > Let's assume, I have the following python code: > > def squared(x): >y = x * x >return y > > I want to call squared(3) from Matlab workspace/code and get 9. > > Thanks for your feedback. ... try this: http://pypi.python.org/pypi/pymatlab Regards Adam Przybyla -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'
cbr...@cbrownsystems.com wrote: > It's clear but tedious to write: > > if 'monday" in days_off or "tuesday" in days_off: >doSomething > > I currently am tending to write: > > if any([d for d in ['monday', 'tuesday'] if d in days_off]): >doSomething > > Is there a better pythonic idiom for this situation? ... hmmm, try this: if set(['monday', 'tuesday'])&set(days_off): dosomething Regards Adam Przybyla -- http://mail.python.org/mailman/listinfo/python-list
Re: yield_all needed in Python
Douglas Alan <[EMAIL PROTECTED]> wrote: > While writing a generator, I was just thinking how Python needs a > "yield_all" statement. With the help of Google, I found a > pre-existing discussion on this from a while back in the Lightweight > Languages mailing list. I'll repost it here in order to improve the > chances of this enhancement actually happening someday. The original > poster from the LL mailing list seems mostly concerned with > algorithmic efficiency, while I'm concerned more about making my > programs shorter and easier to read. The ensuing discussion on the LL > list talks about how yield_all would be somewhat difficult to > implement if you want to get the efficiency gain desired, but I don't > think it would be very difficult to implement if that goal weren't > required, and the goal were limited to just the expressive elegance: > > A Problem with Python's 'yield' ... mayby that way: ython 2.2.3 (#1, Oct 15 2003, 23:33:35) [GCC 3.3.1 20030930 (Red Hat Linux 3.3.1-6)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from __future__ import generators >>> def x(): ... for i in range(10): yield i ... >>> x() >>> for k in x(): print k, ... 0 1 2 3 4 5 6 7 8 9 >>> for k in x(): print k, ... 0 1 2 3 4 5 6 7 8 9 >>> for k in x(): print k, ... 0 1 2 3 4 5 6 7 8 9 >>> yield_all=[k for k in x()] >>> yield_all [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> Regards Adam Przybyla -- http://mail.python.org/mailman/listinfo/python-list
Re: "Collapsing" a list into a list of changes
Alan McIntyre <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a list of items that has contiguous repetitions of values, but > the number and location of the repetitions is not important, so I just > need to strip them out. For example, if my original list is > [0,0,1,1,1,2,2,3,3,3,2,2,2,4,4,4,5], I want to end up with [0,1,2,3,2,4,5]. > > Here is the way I'm doing this now: > > def straightforward_collapse(myList): > collapsed = [myList[0]] > for n in myList[1:]: > if n != collapsed[-1]: > collapsed.append(n) > > return collapsed > > Is there an elegant way to do this, or should I just stick with the code > above? >>> p=[1,1,1,1,1,4,4,4,8,8,9] >>> filter(lambda y: y>0, map(lambda x,y: x==y and -1 or x,[0]+p,p+[0])) [1, 4, 8, 9] >>> Z powazaniem Adam Przybyla -- http://mail.python.org/mailman/listinfo/python-list