Hi,
I ask a question and receive answer. Should I thanks to mailing list (Reply-All) or just private to answer-sender?
Question: Hi. Where is problem? Thanks
Answer: Line 32. Regards.
Is there a situation where the use of a list leads to an error, and you must use a tuple instead?
I know something about the properties of both tuples and lists, but not enough to find out the answer to this question. If the question would be the other way around, it would be that lists can be adjusted but tuples don't.
I have two models device and log setup as such:
class device(models.Model):
name = models.CharField(max_length=20)
code = models.CharField(max_length=10)
description = models.TextField()
class log(model.Model):
device = models.ForeignKey(device)
date = models.DateField()
time = models.TimeField()
data = models.CharField(max_length=50)
how do I get a list which contains only the most recent record/log (based on time and date) for each device and combine them in the format below:
name,code,date,time,data
being a Django newbie I would like to implement this using Django's ORM. TIA!
I need to transform a list into dictionary as follows.
The odd elements has the key, and even number elements has the value.
x = (1,'a',2,'b',3,'c') - {1: 'a', 2: 'b', 3: 'c'}
def set(self, val_):
i = 0
for val in val_:
if i == 0:
i = 1
key = val
else:
i = 0
self.dict[key] = val
My solution seems to long, is there a better way to get the same results?
I am new to struts2.I am unable to populate value in side a table in my jsp page from my Action class.I have a List in my Action class.Can any body help me.
Can any one please guide me to look in depth about the Data Structures used and how is it implemented in the List, Set and Maps of Util Collection page.
In Interviews most of the questions will be on the Algorithms, but I never saw anywhere the implementation details, Can any one please share the information.
I want to sort a list of strings based on the string length. I tried to use sort as follows, but it doesn't seem to give me correct result.
xs = ['dddd','a','bb','ccc']
print xs
xs.sort(lambda x,y: len(x) < len(y))
print xs
['dddd', 'a', 'bb', 'ccc']
['dddd', 'a', 'bb', 'ccc']
What might be wrong?
What i want to do is
for (list<cPacket *>::iterator i = cache.begin(); i != cache.end(); i++){
if( strcmp(i->getName(),id) == 0 ){
return true;
}
}
where getName is function of the class cPacket, But it does not work, i tries also
i.operator->()->getName(), and again nothing.
Can anybody help me?
My professor provided me with a file called CursorList.cpp that implements a "Cursor Linked List". The problem is - I have no idea what that even is!
Could anybody give me the gist of it?
Thanks!
Given a list of numbers how to find differences between every (i)-th and (i+1)-th of its elements? Should one better use lambda or maybe lists comprehension?
Hey
I have to search through a list and replace all occurrences of one element with another. I know I have to first find the index of all the elements, and then replace them, but my attempts in code are getting me nowhere. Any suggestions?
Using the lists webservice I retrieve the items from a list. In the XML returned I can see the attribute ows__IsCurrentVersion="1" which I assume is the same as the file object model (i.e. a boolean to say if it is current or not).
However I do not see a way to identify what revision it is? What should that attribute be?
What are the differences between these built-in Python data types: list, sequence and slice? As I see it, all three essentially represent what C++ and Java call array.
When i use this code I get elements wich containing one number or letter. How to combine two neighbors?
data = '4D41544C414220352E30204D41542D66696C652C20506C6174666F726D3A20504357494E2C2043726561746564206F6E3A20576564204D61792030352031363A31393A3337203230313020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020200001494D0F00000026000000789CE36360607000623620E680D220C00AE53343312310BA00692620E604F351010025BE00C8'
data2 = list(data)
print data2
Hay, i have a field in one of my models which saves the creation date of an object
created_on = models.DateTimeField(blank=False, auto_now_add=True)
This works as expected.
In my templates i want to list objects like this
June 15
{{ objects here which was created on June 15 }}
June 14
{{ objects here which was created on June 14 }}
etc
Any idea how i would go about doing this?
Thanks in advance.
Hi, Assuming a definition like this,
list<MyCommand*> subList
...
MyCommand* pCmd = (MyCommand*)(m_treeSM.GetItemData(node));
I tried these statements below, but failed.
pCmd->subList[2]
(pCmd->subList)[2]
How can I get the array member values(such as subList[2]). I want to replace the value of subList[2] with other same type value. Thank you.
Hey,
I have a list control and i want the user to be able to select many items at a time. Thus I want it to act that if the control key is pressed while he is clicking. Eg if he clicks on a selected row it should become unselected and if he clicks on a unselected row it should become selected.
Do you have any idea how to do this?
Thanks,
Dennis
I need to do this:
(sorry not in javascript syntax-still learning object language :) )
object=car
attibutes:top-speed, brand....
now I want to sort the list of those cars in order by top-speed, brand...
How do I do this (please note the solution must be javascript only, no php or other stuff) ?
If I wanted to have a collection that described the (recursive) contents of a root directory, including directories and files, how would I store them? Or do I need to come up with an object that holds:
-Current directory
-Parent directory
-Files in directory
..and slap them all in one big list and manually work out the relationship at runtime from each entries Parent directory.
If a std::set or std::list contains a sequence of natural numbers (1, 2, 3..). would there be a function in standard library to find the missing number?
In what cases I should use Array(Buffer) and List(Buffer). Only one difference that I know is that arrays are nonvariant and lists are covariant. But what about performance and some other characteristics?
I have a dynamic sql query which contains more than one table joined. Normally I get this query to a datatable and use it. For now I want to get result of this query to a list object. Does anyone help me about this case?
If I have an object of type MyBull and a List<MyBull>:
// Just an example
MyBull x = getMeTheObjectWithIdFromDB(9);
orig.add(x);
// Again same? data object
MyBull y = getMeTheObjectWithIdFromDB(9);
Why is this false then?
// This is false, even though all the properties
// of x and y are the same.
orig.Contains<MyBull>(y);