3,386 Posted Topics
Re: Maybe this is too much help, but here anyway. You could retype the keys instead of selecting from list, but it is good practice to avoid stupid typing mistakes to assure same spelling: [CODE]from pprint import pprint students = ['Joe', 'Jenny', 'Tom'] courses = ['MATH101', 'COMP202', 'BIO101'] students_courses = {students[0]: … | |
Re: This is how it works for me: [CODE]#include <stdio.h> #include <stdlib.h> int main(){ int *n, m = 2; *n = 5; printf("Numbers *n: %i m: %i", *n, m); n = &m; printf("\nNumbers *n: %i m: %i", *n, m); return EXIT_SUCCESS; } [/CODE] | |
Re: I think there is nothing you can learn better in DOS (Dirty Operating System, wasn't it :icon_twisted:) environment than Windows. I would suggest you partition your hard disk and run Linux for alternative environment for nice way to do things. DOS has so little support for youtr programs that you … | |
Re: You must give write string argument. [CODE]print "creating a text file" # 'w' mode creates new file with open("write_it.txt", "w") as text_file: score = 5 name = raw_input("What's your name?: ") text_file.write("%s, %s" % (score, name)) [/CODE] | |
Re: Maybe you named some of your scripts same as one system module? | |
Re: ', '.join(Interface.result) | |
Re: Exclude -Wno-longHdouble should mean that you should [b]not[/b] have it and you have not. Are you sure that the makefile does not work as is? Maybe you have ready binary compiled with other flags (including the flag). | |
Re: I would say that biggest possible factor is third or 7th of the non-prime odd number not ending with 5. | |
Again "pseudo-code" for [URL="http://www.daniweb.com/software-development/cpp/threads/379255/1632559#post1632559"]C++ program[/URL]. Quite primitive and simple, but I post it anyway. Generalized to take even even number as parameter. | |
Re: Difficult to understand your goal, but here is something running end result of playing with it: [CODE]#! /usr/bin/python from Tkinter import * from functools import partial def p(lol): buttons[lol]["text"] = 'Hi from %i!' % lol def plade(root): for n in range(0,4): buttons[n] = Button(root, text= 'Button%i' % n, command=partial(p, n)) … | |
Re: [CODE]deck= [(value, suit) for value in values for suit in suits)] random.shuffle(deck) [/CODE] dictionary is not appropriate, use list. | |
Re: [url]http://www.daniweb.com/software-development/python/threads/128350[/url] | |
Re: For example [CODE]z = [item for item in x if item not in y][/CODE] should work if you do not want sets. If you want set difference this should work (can not test in my mobile) [CODE]z = set(x)- set(y)[/CODE] | |
Re: Sum of logarithms looks more attractive, but to 10**9 takes still time. I did timed loop in my favorite language and it took 7.198 s to calculate value 65657060 for 10**7 and that is still two decades down. Result was accurate at least for 10**5 (456574), which is OK to … | |
Re: In stackoverflow there was code on how to use complex numbers for rotation of polygon: [url]http://stackoverflow.com/questions/6481170/trying-to-rotate-a-triangle-with-complex-numbers-in-tkinter-python[/url] And ActiveState explains how to change oval to polygon for rotation: [url]http://code.activestate.com/lists/python-list/161757/[/url] You might be better off using for example pygame: [url]http://pygame.org/docs/ref/transform.html[/url] | |
Re: Audacity does support: [CODE]Sun Au / NeXT This is the default audio format on Sun and NeXT computers, and usually u-law compressed, so it is not a very high quality format. U-law compression is a very simple, fast but low quality way to reduce the size of the audio by … | |
Re: [LIST=1] [*] read files in loop [*] for each file split lines containing ' - ': [/LIST] [LIST] [*]use first value for key to dictionary [*]split and convert second value as list of floats (maybe you should consider numpy array, makes sum easier) [ if key is in dictionary add … | |
Re: I get error from import workerpool. Looks like not standard library. Installed it with pip, and changed little code to see what happens, looks like it does a lot at least, when moving shutdown after collecting workers. [CODE]import os import urllib from datetime import datetime import workerpool class DownloadJob(workerpool.Job): def … | |
Re: You do not do looping but let numpy to do matrix operations, when using numpy. I think nums should contain numbers instead of strings and that you should not add [] to it for anums but keep same dimensions as nums. [CODE]import numpy a = [1, 2, 34, 54] mean … | |
Re: 1 has not prime factor 2,3 or 5. If you had all numbers less than n satisfying the condition available, could you use those numbers to produce numbers which also satisfy the condition and are bigger than or equal to n? Don't you know which numbers less than 6 satisfy … | |
Re: Does not make sense for me, maybe with some kind of design diagram I could find sane implementation. But from your verbal explanations I could not make it, maybe some native English speaker is able to. Here is result of trying to catch the meaning of code and commenting out … | |
Re: Just paste your code after pushing the (code) button, include full erroo mesages and explain what you tried to fix it. | |
Re: I have no problem with your sample info with simple Python way without unnecessary complications: [CODE]data = """ 1302971105851,Sat Apr 16 17:25:05 2011,3318,Call received,XXXXXXXX 1302991884760,Sat Apr 16 23:11:24 2011,3319,Call received,XXXXXXX 1303018741819,Sun Apr 17 06:39:01 2011,3320,Call made,XXXXXXXX 1104770564325,Mon Jan 3 16:42:44 2005,1,Text received,From3 1104770734612,Mon Jan 3 16:45:34 2005,2,Draft text,None 1312544050806,Fri Aug … ![]() | |
Here is simple math program to list number whose all factors are in given set of factors. I have included my timing decorator, which uses my timestring function, so I included that and imports for decorator in the decorator function, bit against the rules. Of course I could have used … | |
Re: I would do something like: [CODE]class Switch(object): def __init__(self, on=True): self.on = on self.off_word = 'off' def turn_off(self, key): self.on = key!=self.off_word def __str__(self): return "Switch(on=%s)" % self.on myswitch = Switch() while myswitch.on: myswitch.turn_off(input('Enter a word: ')) print(myswitch) [/CODE] ![]() | |
Re: I copy pasted your code in empty project in Lazarus and it run without error: [CODE]program Project1; {$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} Classes { you can add units after this }; {$R *.res} var arr : array of integer; begin WriteLn('Hi!'); Readln; end.[/CODE] Also I run as … | |
Re: Just put else branch and put line 9 etc inside the else. | |
Re: Something like: [CODE]class Processor(object): def __init__(self): self.byte0 = 0 processor_count = 4 processors = [Processor() for count in range(processor_count)] for j in range(4): print processors[j].byte0 [/CODE] or [CODE]class Processor(object): def __init__(self): self.byte0 = 0 def __str__(self): return '%r, byte0 = %i' % (self, self.byte0) processor_count = 4 processors = [Processor() … | |
Re: No you haven't got it yet: [CODE]>>> f = FrequencyList() >>> f [] >>> f.add('a',3) Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> f.add('a',3) File "K:/Tony/shannon_game.py", line 48, in add self.head = Node(Frequency(letter, 1)) NameError: global name 'Node' is not defined >>> [/CODE] I fixed it but … | |
Re: Usually you must limit operations very much, to simlify things. see: [url]http://www.genetic-programming.com/gppreparatory.html[/url] | |
Re: You must use locale and cmp parameter for sorting: [CODE]# -*- coding: cp1254 -*- import locale print locale.getlocale() locale.setlocale(locale.LC_ALL, locale='Turkish_Turkey') print locale.getlocale() names = 'Mary, Adam, Jane, Sall, Istar, Omar, Paul, Ulla, Zackarias, Örnek, Şelale , İstanbul, Ürgüp'.split(', ') print ','.join(sorted(names)) print ','.join(sorted(names, cmp=locale.strcoll)) [/CODE] | |
Re: This worked for me as I put some excel files with three colummns of numbers starting at row 21 in sheet 'RawTrackingData': [CODE]import xlrd import os path = 'data' with open('Trying_excel.csv', 'w') as f: column_values=['', '', ''] for filename in os.listdir(path): fullname = os.path.join(path, filename) if fullname.endswith('.xls'): print('Handling %s' % … | |
Re: file has wrong extension and is not in excel format, I guess, but is plain text file. | |
Re: Divide by 8 and reverse the remainders. Don't steal other's thread, please but start new one of your own! | |
Re: [QUOTE=Narue;1628631]No, that's a positive number. Don't confuse bit shifting with multiplication, especially when it comes to negative quantities. That depends on whether the left hand side of the expression is signed or unsigned. If it's signed, the vacated bits are filled with the sign bit. Otherwise, they're filled with 0.[/QUOTE] … | |
Re: I can not reproduce your problem: [CODE]try: from tkinter import * except ImportError: from Tkinter import * root = Tk() frame = Frame(root, width=640, height=480) frame.pack() #now to change the frame size frame.configure(width=200) mainloop() [/CODE] | |
Re: My idea: Avoid tricks with dlls and use [URL="http://ironpython.codeplex.com/"]IronPython[/URL] | |
Re: Clean up your code, if you want response, by using sensible variable names, not using meaningless functions like [CODE]def Initialize(v): return v [/CODE] which is equivalent of simple v and does not create Initialize object like name suggest. Also please put first imports, global constants, then function definitions and at … | |
Re: I think the example result is wrong as you do not want to stay at year 1885 with 0 gram plutonium, but to come home without jury rigging a steam train! Your problem is that you take year from listo, but instead of using it and keeping track which you … | |
Re: Only strange thing I see is print line in exist case, which has twice % instead of tuple: [CODE] print( '"%s" exists in the list at index "%s"' % (f_exists, f_in)) [/CODE] Just enable the while loop, fix exit, fix little output format and you are done. | |
Re: That's what Daniweb is about, even I do not know matlab, it is likely that somebody will, just post your code and describe your problem in detail. Also be carefull to give impression of effort you have given to solve the problem yourself, then you are more likely to get … | |
Re: @pyguy62: unfortunately you had much to correct here my fast work over of your code, basically you are continueing to change the classes instead of having instances. Also you mix too much your output inside the program logic. [CODE]from __future__ import print_function import random try: input = raw_input print('Welcome Python2 … | |
Re: There could be usefull and easier stop condition based on num considering line: [CODE]num=num/10;[/CODE] for loop and the i variable are not good fit for the purpose. I suggest while instead. | |
Re: You could do worse than use Python ([url]www.python.org[/url]), but many languages would work. But you have to get mind set of programming and logical thinking first. | |
Re: if the result off query would be independant of the one asking I would produce web page of results and give that to others requesting the information other either with password or checking for trusted domain (could be faked but sequrity was not so big concern). It is also possible … | |
Re: Some definitions of best combo could be: [LIST=1] [*]Does not crash too often. [*]Is not insufferable slow doing things (like compiling for many minutes or running your program many minutes) [*]You agree with the philosophy of the system/language. [*]You get other users/companion developers to use (usually biggest hurdle). [/LIST] | |
Re: It is of course heavy operation, but I think that would basically mean producing new string with two letters added instead of one letter for replacement. In this case, for my opinion, clearest is to use copy anyway. You could copy whole string segment in one memcopy type operation by … | |
Re: You might like to look into OpenBOOT which provides facility for FORTH programming at BIOS BOOT level. [url]http://www.openfirmware.info/Open_Firmware[/url] | |
Re: data is different variable than __data. [CODE]class Test(): __data = 1 def output(self): print self.__data def set_data(self, value): self.__data = value # set public class variable for class Test Test.data = 3 my_test = Test() my_test.data = 2 print 'Class data changed for instance my_test', my_test.data my_test.output() my_test.set_data(5) my_test.output() your_test … |
The End.