list

Unpacking a 1-tuple in a list of length 1

Suppose I have a tuple in a list like this: >>> t = [("asdf", )] I know that the list always contains one 1-tuple. Currently I do this: >>> dummy, = t >>> value, = dummy >>> value 'asdf' Is there a shorter and more elegant way to do this? ...

Wrap first level of "li" tags into one div using Jquery

Hi Have the following question: Say we have a multi-level html list that looks like this: <ul class="catalog"> <li> <ul> <li> <ul> <li>subcat subcat 1</li> <li>subcat subcat 2</li> <li>subcat subcat 3</li> </ul>...

Java: One constructor or method that will accept array or set or list or ...?

In Java is there anyway to have one constructor that will accept an array or a collection? I have been fiddling with this for a while but I don't think it is possible. I would like to be able to initialize MyClass, like this: MyClass c = new MyClass({"rat", "Dog", "Cat"}); And like this: LinkedList <String> l = new <String> Link...

How to get an Alertdialog with the background out of focus (fuzzy).

I know how to make AlertDialog's of various types. But, how can I make an AlertDialog with the background fuzzy as if it is out of focus (i.e. like using a telephoto lens)? Whenever I search for 'focus' the result relaits to something like the onFocus commands, etc. which isn't what I mean. An example would be if you press the power bu...

Python: Indexing a list of lists

Simple question, i have a list if lists x = [['1','2','3'],['4','5','6'],['7','8','9']] whats the simpliest way of indexing through each list in a single for loop? For example for i in x: print 1st_list_in_list print 2nd_list_in_list print 3rd_list_in_list EDIT Let me elaborate further, I wish to print each list how ...

Tree-view Alternatives

Heya Guys im currently working on a project that involves listing contacts with a photo and email address, kind of like messengers contact lists. The problem is ListView just dont cut it! I need something that's like the MSN Live Messenger contact lists, Witch consist of a large padded area with photo(32px), And text to the right of t...

Listing Files Using PHP

I'm needing to make a web site, that should list all the files that are in the directory /Files(where / is the Apache public - htdocs), but excluding if there is any sub-directory. Also, they should have links for every file. Like this: echo "<a href='Link to the file'>Test.doc</a>" . "\n" How could I do it? ...

How meny items cn contain tuple or list in python?

How many items can contain tuple or list in python? What will be if it is 10 000? ...

Change foreground/background color of Item in Listbox programmatically in WPF

How can i add different items with either background/foreground color different in WPF listbox? ...

java get sub list from a list of objects

there is a dependent list Dependents contains String emp_Id, name etc, List<Dependent> dependentList; dependentList contains all the dependent information of an employee. how to get the list of dependents by providing the emp_Id ? for example an employee will have 2 or 3 dependents. ok i dont want to loop over it. i tried binar...

Output html from CouchDB list

Hi, I am trying to create a list in CouchDB 0.11 which responds with some html, I am having problems getting CouchDB to set the correct header, whatever I try, I just get an application/json response header. Here is my list function. function(head, req) { var rows = []; var row; while(row = getRow()) { rows.push(...

Python - Finding index of first non-empty item in a list

What would be the most efficient\elegant way in Python to find the index of the first non-empty item in a list? For example, with list_ = [None,[],None,[1,2],'StackOverflow',[]] the correct non-empty index should be: 3 ...

Slicing python lists

Hi If I have a list of say 'n' elements (each element is a single byte ) which represents a rectangular 2d matrix, how can I split this into rectangles of say w * h, starting from the first element of the list , just using the python standard functions for example l = [ 1,2,3,4,5,6,7,8,9,10, 11,12,13,14,15....20. 21,22,2...

Dynamic let List Destructuring in Clojure

I have a let statement in which I would like to dynamically destructure a list. The following is my solution: symList ;; list of some Strings which will become the vector of Symbols to assign to valList ;; list of some values, same length as symList (let [(map read-string symList) valList] ...) An example value of symList would b...

Python list comprehension for dictionaries in dictionaries?

I just learned about list comprehension, which is a great fast way to get data in a single line of code. But something's bugging me. In my test I have this kind of dictionaries inside the list: [{'y': 72, 'x': 94, 'fname': 'test1420'}, {'y': 72, 'x': 94, 'fname': 'test277'}] The list comprehension s = [ r for r in list if r['x'] > 92...

Sorting dicts (contained in lists) alphanumerically in Python

I'm having an issue with sorting a list that contains a dict. Currently I am sorting it by a key called 'title' with the following line: list.sort(key=operator.itemgetter('title')) The problem with this is that some of my data gets sorted looking like this: title_text #49 title_text #5 title_text #50 How would I go about sorting it...

Return a list of lists to template and render it

In my project I deal with various sorts of events taking places in different cities. I'd like to present list of events per city in a template, but how to do that ? My view now looks like this : def events_by_state(request, state): cities = City.objects.filter(state_slug=state) For each city I'd like do a query : for c in cities...

100% horizontal cross-browser menu HTML/CSS?

How to make 100% horizontal cross-browser menu HTML/CSS? 1. with keeping clean HTML, li list 2. no image/javascript, tableless, W3C standards compliance Example for invalid example: /*CSS doesn't make `block` right/left space between `li` items (see attached image)*/ #nav{ text-align:justify; } #nav li{ /*border:1px solid #000; mar...

Pushing back object, then erasing it at its previous location in std::list

Note that the order can go either way (erase first then push back, just that this way doesn't require creating a local reference to the object). for ( GameObjItr gameObj = m_gameObjects.begin(); gameObj != m_gameObjects.end(); gameObj++ ) { if ( *gameObj && *gameObj != gameObject ) { const sf::FloatRect &otherObj = (...

How to concat lists in erlang without creating nested lists?

I'm trying to be a good erlanger and avoid "++". I need to add a tuple to the end of a list without creating a nested list (and hopefully without having to build it backwards and reverse it). Given tuple T and lists L0 and L1: When I use [T|L0] I get [tuple,list0]. But when I use [L0|T], I get nested list [[list0]|tuple]. Similarly, [L...