Vote count: 0 If I have two files myclass.h and myclass.cpp how to separate this code to declaration of class member and implementation of constructor where I need to set the values in brackets {}? std::string predefinedArgs[] = { "Some", "Other", "Strings" }; I tried header: class Wrapper { public: std::map arguments; Wrapper(int argc, char ** argv); private: int argc; char ** argv; std::vector args; std::string predefinedArgs[12]; void parseArguments(); }; And .cpp: Wrapper::Wrapper(int argc, ...
ادامه مطلبVote count: 0 I am looking for a pythonic way to iterate through a large number of lists and use the index of repeated values from one list to calculate a total value from the values with the same index in another list. For example, say I have two lists a = [ 1, 2, 3, 1, 2, 3, 1, 2, 3] b = [ 1, 2, 3, 4, 5, 6, 7, 8, 9] What I want to do is find the unique values in a, and then add together the corresponding values from b with the same index. My attempt, which is quite slow, is as follows: a1=list...
ادامه مطلبVote count: 0 Suppose I have a nametag, which is UI component in GUI program. The nametag will constantly change its text based on the data. If the user change his/her name data, then he/she will see the change in nametag. For this task, my code looks like this: Thread thread = new Thread(new Ruable(){ @Override public void run() { while (true){ String name = data.getName(); nametag.setText(name); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } } }); Since th...
ادامه مطلبVote count: 0 I want that my pop up menu appear next to the clicked row. Look at the picture after I click the "..." button: http://postimg.org/image/s35znsaq3/ This is my code for the Pop Up Menu: private void showPopUpMenu(final User user) { View menuItemView = findViewById(R.id.moreActions); PopupMenu popUpMenu = new PopupMenu(ContactsListActivity.this, menuItemView); popUpMenu.getMenuInflater().inflate(R.menu.pop_up_menu, popUpMenu.getMenu()); // Hide buttons for missing user's information M...
ادامه مطلبVote count: 0 I have a list like this: l = ['b', '7', 'a', 'e', 'a', '6', 'a', '7', '9', 'c', '7', 'b', '6', '9', '9', 'd', '7', '5', '2', '4', 'c', '7', '8', 'b', '3', 'f', 'f', '7', 'b', '9', '4', '4'] and I want to make a string from it like this: 7bea6a7ac9b796d957427cb8f37f9b44 I did: l = (zip(l[1:], l)[::2]) s = [] for ll in l: s += ll print ''.join(s) But is there any simpler way? May be, in one line? asked 1 min agopushpen.paul Let's block ads!...
ادامه مطلبVote count: 0 The function derivative computes the derivative of a polynomial; the degree of each entry needs to be reduced by one, each entry must be multiplied by the previous degree, and the term at degree[0] needs to be removed. This code lst = [1,2,3] """This list represents the polynomial 3x^2+2x+1""" """This function moves each entry one index down and removes the last entry""" def move(lst): copy = list(lst) for i in range(len(lst)): lst[i-1] = copy[i] del lst[-1] print lst move(lst) pro...
ادامه مطلبVote count: -2 enter image description here how can I solve this problem? asked 4 mins agoDaulet Ilakhunov Let's block ads!...
ادامه مطلبVote count: 1 Python 3 can easily handle printing a lot of text: text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae odio quis felis consectetur blandit. Etiam mattis vehicula ex id sodales. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris fermentum semper nisi vel aliquam. Ut nec facilisis lectus. Maecenas auctor blandit condimentum. Donec finibus orci ac imperdiet congue. Pellentesque sem leo, commodo non metus ac, posuere maximus lorem. Class aptent ...
ادامه مطلبVote count: 0 I am trying to use list comprehension to filter this list: inp = [['Fire 46.0.1', 'vlc 2.2.3','opt 0.9.9.10'], ['opt 0.9.9.11', 'notepad 6.9', 'adobe. 6.9', 'vlc 2.3.3']] into: out = [['Fire 46.0.1', 'vlc 2.2.3',], ['notepad 6.9', 'adobe. 6.9', 'vlc 2.3.3']] i.e. removing all the strings that start with opt. I am trying something like that: [soft for ls in inp if soft not soft.startswith('opt')] but something is wrong with the sintax.Any help? asked 2 mins agodiegus Let's block ads...
ادامه مطلبVote count: 0 I am new to Python and I just discovered the properties. It works just fine when I try it on a simple variable but I caot make it work on a list. When executing the code below it will call two times the getter and not the setter. I know that in my example the property has no added value but it is to simplify. class C: def __init__(self): self._x=[1,2,3] @property def x(self): print("getter") retu self._x @x.setter def x(self,value): print("setter") self._x=value c = C() c.x[1]=4 pr...
ادامه مطلبVote count: 0 I've made a class, and after the program has finished ruing, I want to list all the variables I have kinda like so var1: val var2: val etc my class looks like this class character: name = 'Player1' level = 1 str = 100 con = 80 sta = 150 critchance = 0.1 critdmg = 0.5 # for battle hp = con * con thoughness = math.sqrt(sta) asked 2 mins agoPetter Petter Let's block ads!...
ادامه مطلب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!...
ادامه مطلب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...
ادامه مطلب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...
ادامه مطلب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...
ادامه مطلب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!...
ادامه مطلب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-...
ادامه مطلب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!...
ادامه مطلب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...
ادامه مطلب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...
ادامه مطلب