list

Python: How to find presence of every list item in string

Hi, What is the most pythonic way to find presence of every directory name ['spam', 'eggs'] in path e.g. "/home/user/spam/eggs" Usage example (doesn't work but explains my case): dirs = ['spam', 'eggs'] path = "/home/user/spam/eggs" if path.find(dirs): print "All dirs are present in the path" Thanks ...

Why does converting a datasource to a datatable prevent formating

I have come accross a strange problem that can be illustrated using the 2 seperate code blocks below. If i use the first block, you can clearly see that column 5 has a currency format applied to it. Using the second block where the only difference is that the string array is added to a datatable and then used as the datasource -> no ...

What is the reason for a segmentation fault with this C++ code using lists?

I have some complicated C++ code but the problem narrows down to doing a push_back on a list of structures: list<cache_page> cachedPages; void f() { cache_page cpage(a,b); cachedPages.push_back(cpage); } I have commented all the data members of the struct cache_page and still the error persists. If I comment the push_back lin...

How to do apply in Tcl 8.4?

Hi, In Tcl 8.5 I can do something like this: apply llength { 1 2 3 } But that apply is not defined in v8.4. How would I define apply using Tcl in v8.4? I need this because I am converting some lisp code to Tcl. The lisp code has some constructs that I would like to port like this: array set levels { TRACE 0 DEBUG 1 INFO ...

SharePoint, List.Items and List.GetItems(Query) and Linq

Following on from suggestions, I am trying to use List.GetItems(Query) to retrieve my initial data subset rather than the entire list contents via List.Items. However, whereas List.Items.Cast() results in a usable IEnumerable for Linq, List.GetItems(Query).Cast() does not. Working Code: IEnumerable<SPListItem> results = SPContext.Curr...

C# List - Group By - Without Linq

I have an object: IObject { string Account, decimal Amount } How do I group by Account and Sum the Amount, returning a List without Linq. 2.0 Framework ... that is why no Linq. Here is what I have: ListofObjects = List<IObject>; foreach (var object in objects) { var objectToAdd = new Object(object); ...

How can I get the element of a list that has a minimum/maximum property in Python?

I have the following array in Python: points_list = [point0, point1, point2] where each of points_list is of the type: class point: __init__(self, coord, value): self.coord = numpy.array(coord) self.value = value # etc... And a function: def distance(x,y): return numpy.linalg.norm(x.coord - y.coord) And I...

C#: How to convert a list of objects to a list of a single property of that object?

Say I have: IList<Person> people = new List<Person>(); And the person object has properties like FirstName, LastName, and Gender. How can I convert this to a list of properties of the Person object. For example, to a list of first names. IList<string> firstNames = ??? ...

C# Serializing a Collection of Objects

I am working on a ASP.NET application that has a class that inherits a List of a Custom Object. public class UserRoleList : List<UserRoleBO> { public UserRoleList() { } } How do I make this class serializable in C#? ...

What is the pythonic way of checking if an object is a list?

I have a function that may take in a number or a list of numbers. Whats the most pythonic way of checking which it is? So far I've come up with try/except block checking if i can slice the zero item ie. obj[0:0] Edit: I seem to have started a war of words down below by not giving enough info. For completeness let me provide more detail...

how to rewrite this loop in a more efficient way in python

I have a loop of the following type: a = range(10) b = [something] for i in range(len(a)-1): b.append(someFunction(b[-1], a[i], a[i+1])) However the for-loop is killing a lot of performance. I have try to write a windows generator to give me 2 elements everything time but it still require explicit for-loop in the end. Is there a w...

How to draw a progress bar inside a list widget in Qt

I want to have a list of items that need to be processed in a QListWidget. Similar to Windows Media Player CD import, there should be a progress bar for every item in the list. Now there seems to be a way to do this by creating a regular progress bar, using QPixmap::grabWidget() to save its appearance in a QPixmap and then adding this Q...

Arrays.asList() not working as it should?

I have a float[] and i would like to get a list with the same elements. I could do the ugly thing of adding them one by one but i wanted to use the Arrays.asList method. There is a problem though. This works: List<Integer> list = Arrays.asList(1,2,3,4,5); But this does not. int[] ints = new int[] {1,2,3,4,5}; List<Integer> list = Arr...

how do I get the difference between two R named lists?

OK, I've got two named lists, one is "expected" and one is "observed". They may be complex in structure, with arbitrary data types. I want to get a new list containing just those elements of the observed list that are different from what's in the expected list. Here's an example: Lexp <- list(a=1, b="two", c=list(3, "four")) Lobs <- lis...

Create new List object in python

I am a beginner in python. I want to Create new List object in python. My Code: recordList=[] mappedDictionay={} sectionGroupName= None for record in recordCols: item = record print item if not sectionGroupName == record[0]: sectionGroupName = record[0] del recordList[0:] # Here I want to create new list...

grouping nodes in drupal with taxonomy

I have a problem that i cant seem to get my head around. What i need to do is to create lists in drupal, where you can group nodes together depending on what category they belong to, and also have that category as a header. ex: - January (category, header) -- week 1 (category, header) --- 1. bananas (node) --- 2. apples (node) --- 3....

Working with a List of Lists in Java

I'm a newbie java programmer and having some difficulties with [Array]List. Specifically, I'm trying to read a CSV file into a list of lists (of strings), pass it around for getting some data from a database, build a new list of lists of new data, then pass that list of lists so it can be written to a new CSV file. I've looked all over a...

Return only available items in Ruby on Rails

I've created a method that allows me to return all of the Books. I'd like to limit the books returned to those that are not not loaned. What do I need to add to *available_books* to ensure only unloaned books are returned. Can I leverage my preexisting loaned? method? class Book < ActiveRecord::Base has_many :book_loans has_many :bo...

Scheme: Extract every number in the list and reconstruct the list?

This is a homework question, but I really just need some hints, that's all. Basically, I need to create this function flat that's supposed to re-contract a new list from the input list (but here, the input list can have a nested list inside): ex. flat of (A (B (C) D) A) is (A B C D A) My algorithm is the following, not sure if it's co...

Can i use text box names as values in a list?

im creating a list to update a MySql db with values form text boxes, how can i make somthing like this work? if i use the verdierX[0] = (int)decimal.Parse(box1.Text); it works just fine but when i try to use it in a loop like this is blowes up. Anyone got a suggestion on how to solve this? int[] dbNavnX = new int[8]; ...