back soft

مطالب مرتبط با «python list of objects» در back soft | نویسنده: استخدام کار

What's wrong with Python datetime.now() in this piece of codes?

Vote count: 0 here is the codes: >>> from datetime import datetime >>> t=datetime.now() >>> print(t) And I got such a result: 2016-05-28 16:17:56.192505 How does the float number come? How could I solve it? Environment: Python 3.5.1 on Windows 10. asked 40 secs ago陈梓泉 Let's block ads!...

ادامه مطلب

selecting an item from listbox and using the name of the item later

Vote count: 0 I'm making a small project using Python 3.4/5 in conjunction with Tkinter. I have make a list box that shows all items in a directory. I can't seem to find a way to select an item and then save the name in a variable for later use. listnotes = Listbox(notebox, selectmode=SINGLE) listnotes.pack(side=LEFT, fill=Y, padx=10, pady=10) listnotes.insert(END, "notes") for i in glob.glob("TESTFOLDER*.txt"): i = i[12:] listnotes.insert(END, i) I have read around that using listnotes.get(ACTI...

ادامه مطلب

How to drop and add a new list of columns to a .csv file?

Vote count: 0 I am saving to a .csv file a preprocessed file with pandas to_csv() function as follows: retu df.to_csv(output_file, sep = '|') The output of the .csv file looks like this: |id|content|content2 0|id1|some content|some content 1|id1|some content|some content .... n|idn|more content|even more content As you can see from the above pandas objetct, the columns are not well formed: |id|content|content2 How can I remove the above columns and replace them for this new columns setting: id|c...

ادامه مطلب

Python3 Selenium Load Offline Files

Vote count: 0 So I have an rpi that will be used to display a webpage on a monitor, and I'm using python3 selenium to do it. I want it to be able to download the webpage offline so that if something happens to its coection, it still functions. I have downloaded the webpage, and it works if I manually load it (There is the main.html and main_files folder with the css, images, etc.) just by double clicking the main.html file. However, I think the issue is that selenium doesn't know where to find t...

ادامه مطلب

Fetch list of iOS contacts based on the organization name or the jobtitle

Vote count: 0 Is it possible to fetch a particular contact information or the list of contact informations based on organization name or the job title using both AddressBook and contacts framework ?? asked 2 mins agoMohamed yaseen Let's block ads!...

ادامه مطلب

Limit addition of oval objects to line object in tkinter canvas

Vote count: 0 I am trying to figure out if there is a way to associate one object to another in Tkinter. I would like to add ovals onto my Tkinter canvas but only to a pre-existing line object, i.e., I do not want the user to be able to add ovals anywhere on a canvas except for on the line object. Is there another way to do this other than restricting the addition of the oval to the x0, x1, and y0, y1 min/max of the pre-existing line object? Thanks in advance! asked 35 secs agouser1332577 Let's ...

ادامه مطلب

Python for/in/if List Comprehension Becomes Very Slow With Large Number of Matches

Vote count: 0 I have the following list comprehension in my Python 2.7 code which retus the line number (index) and the line from a long list of lines: results = [[lines.index(line), line] for line in lines if search_item in line.lower()] This is lightning quick if the number of results is low: The search item is: [ 1330 ] Before string pre-processing, the time is: 0.0000 The number of lines is: 1,028,952 After string pre-processing, the time is: 0.2500 The number of results is: 249 "String pre-...

ادامه مطلب

Alphabetical sorting list of chars using lambda expression in C++

Vote count: 0 I'm new in C++, could you explain me how can I sort list of chars, for ex. list letters[] = {'a','c','b'}; in alphabetically order? Was looking for some friendly explanations but I found only sorting of integers using lambda expression. asked 1 min agoloup4 Let's block ads!...

ادامه مطلب

Efficient way of parsing through genetic mutation data in python

Vote count: 0 Simplistically the question I'm asking is in a given set of DNA sequencing reads what bases were mutated. To do this I created a data structure like this: baseDict = {'a':0, 't':0, 'g':0, 'c':0} varDict = {'a':baseDict, 't':baseDict, 'g':baseDict, 'c':baseDict} So, a given base can be either A, T, G, or C, and then can be mutated to any of the four bases. So and A could be mutated to a T. I am reading through a file containing mutations, and using a lot of if...elif statements to p...

ادامه مطلب

Changing Colors and ClickEvent of an Item inside a ListView(Xamarin Android)

Vote count: 0 I've just started programming not long ago so please bare with me. The problem I am facing is I am unable to change the color of my Items inside the Listview to Black color. My ListView's background (Which I've removed in order to see the items inside Listview) is supposed to be white background as well. Inside my activity, I added my items using the adapter.add("Item"). Therefore I am lost trying to add an click event on that Item since it's a string. Tried : 1) Changing propertie...

ادامه مطلب

How to use .split, enumerate and lists to find positions of a word in a sentence

Vote count: 0 I have been asked to find the position(s) of an input word from an input sentence and I am having trouble figuring out how to use enumerate, .split and lists together. This is what I have so far: sntc=str(input("Please input a sentence with no punctuation.")) wrd=str(input("Please input a word from that sentence.")) words=sntc.split list(enumerate(sntc)) for x in y in enumerate: if x==(wrd): print ("The chosen word is in postion(s):",x+1) asked 38 secs agoBig Man Let's block ads!...

ادامه مطلب

How can I sort some objects depending on one of their properties

Vote count: 0 I want to sort a number of objects in certain order (ascending or descending) depending on one of their properties. I leaed that interfaces can help doing this but can't figure out how to do this. asked 56 secs agouser6307983 Let's block ads!...

ادامه مطلب

Out Of Range Exception 2D Array To List Of Type Int

Vote count: 0 Why do I get an Out of Range Exception here? My Code -the method takes int[][] numbers as a Parameter- : List myList = new List(); for (int i = 0; i < numbers.GetUpperBound(0); i++) { for (int z = 0; z < numbers.GetUpperBound(1); z++) { myList.Add(intervals[i][z]); } } I tried to Google it, but I don't have any glue. asked 3 mins agoMatthias Herrma Let's block ads!...

ادامه مطلب

How to bind the multiple selected items of list box in xaml

Vote count: 0 I have Flags Enum value which I have bound into the item source of listbox.I have used SelectionMode as Multiple.I want assign all the selected items of the listbox to flag Enum property.How can I bind the selected items? asked 2 mins agoMS.Dev Let's block ads!...

ادامه مطلب

How to write wav sound file from a list of samples?

Vote count: 0 I've got a source code on the inteet which do extract the sample values from a WAV file to a text file, like this: 1.17667 1.23074 3.07474 -0.00396729 -0.00393677 -0.00558472 -0.0159912 -0.0299072 -0.128143 -0.0204773 -0.206482 -0.252014 -0.0100098 -0.0585938 -0.317963 -0.253143 -0.302917 -0.0115967... .. How can I use it the write back, and create a wav file ? here is the code for extracting the samples value : http://pastebin.com/K375dbdj Thank you ! asked 2 mins agoHung Nguyen L...

ادامه مطلب

IndexError: list index out of range, but error is inconsistent?

Vote count: 0 I am in a intro to GIS programming class and doing a hangman game for my final project. I am very much an amateur so this might be an easy fix that I am not understanding...Here is my code: import random, sys class Hangman: def init(self,word): self.word = word self.incorrect_letters = [] self.letters_guessed = [] def hangman_loss(self): retu self.hangman_win() or (len(self.incorrect_letters) == 7) def hangman_win(self): if '_' not in self.unknown_word(): retu True retu False def g...

ادامه مطلب

List of pointers in class. Expression must have pointer type

Vote count: -1 , class Node { public: string m_label; list m_adjacent; }; int main() { Node tab[5]; tab[0].m_label = "AWK"; tab[1].m_label = "ASCII"; tab[2].m_label = "Matery"; tab[3].m_label = "2016"; tab[4].m_label = "actor"; map map; map[tab[0].m_label] = tab[0]; map[tab[1].m_label] = tab[1]; map[tab[2].m_label] = tab[2]; map[tab[3].m_label] = tab[3]; map[tab[4].m_label] = tab[4]; Node * temp[4] = { &tab[1], &tab[2], &tab[3], &tab[4] }; map[tab[0].m_label].m_adjacent.push_back(temp[0]); map[t...

ادامه مطلب

How to avoid duplicate objects displaying in a list

Vote count: 0 I spent a lot of time to avoid duplicate objetcs displaying in a dynamic array and i used trac by $index with ng-repeat but it still displaying duplicate elements is there any solution asked 1 min agojishnu ms Let's block ads!...

ادامه مطلب

I'd'd like to take a list of strings, find them in another csv file and print a field from the matching line

Vote count: 0 I have a large .csv file with a few thousand lines and a handful of columns. For simplicity, it looks a little like Name, ID One, 1 Two, 2 I'd like to write a script which takes a list of strings, treating each line as a separate entity, and finds the line containing a match to that entry on the list. Once it's found the line which matches, I'd like to print one of the fields to a new file. For example, given a list: 1 2 I'd like to be able to produce a file containing the associat...

ادامه مطلب

Python 3: Convert a single element list to a variable

Vote count: 0 I have a list called [[ 0.99950892]] I want to have just 0.99950892 However when I use [[ 0.99950892]][0][0][0]. The output is (0.99975443124+0j). I don't want the parenthesis and the imaginary part. What should I do? asked 3 mins agopeter 1 Answer Vote count: 0 >>> [[x]] = [[0.99950892]] >>> x.real 0.99950892 answered 55 secs agowim Let's block ads!...

ادامه مطلب