3,386 Posted Topics
Re: I did recursive Python code for this, which might give you idea. It is not that simple to recode to Prolog, though. http://www.daniweb.com/software-development/python/code/478650/spiral-numbers | |
I [saw interesting problem](http://www.daniweb.com/software-development/legacy-languages/threads/478323/prolog) of generating spiral of numbers and realized I could reuse [my code for rotation](http://www.daniweb.com/software-development/python/code/371536/rotate-sequences-left-or-right) I posted earlier. | |
Re: You pass in `write_csv` an `url`, but I do not understand where those other variables like `final_model_num` are coming. | |
Re: Use variable to remember how many different numbers have been selected and increase that every time new is selected. Store current count of unique numbers with the current counter to dictionary. count_store[this_random_int] = current_count What exactly you want as result, I do not know without example. | |
Re: Any sample of input/expected output? | |
Re: I do not really understand what exactly you are after, but for example in this snippet I save a graphics file and load it as BMP file. http://www.daniweb.com/software-development/python/code/371844/mandelbrot-with-tkinter-and-shedskin | |
Re: You just start deploy it. http://www.djangobook.com/en/2.0/chapter12.html | |
Re: Of course you had not previously installed pygame or followed instrunctions:[QUOTE]You may need to uninstall old versions of pygame first. NOTE: if you had pygame 1.7.1 installed already, please uninstall it first. Either using the uninstall feature - or remove the files: c:\python25\lib\site-packages\pygame . We changed the type of installer, … | |
Re: https://docs.python.org/2/tutorial/modules.html | |
Re: Hint: >>> transform = dict((a.strip() for a in pair.split('to')) for pair in 'Therapist to T, Patient to P'.split(',')) >>> counts = dict((a, 0) for a in transform) >>> counts['Therapist'] += 1 >>> print transform['Therapist'] + str(counts['Therapist']) T1 >>> counts['Therapist'] += 1 >>> print transform['Therapist'] + str(counts['Therapist']) T2 | |
Re: Sound suspiciously so that you enter loop at keydown and don't exit it at keyup. | |
Re: Not most beautiful user interface, but it works for me. Of course, as I am using Python 2.7, I redefined input same as raw_input for it to work, by adding to beginning try: input = raw_input except: pass | |
Re: [Like this](http://lmgtfy.com/?q=python+address+book+tkinter) | |
Re: The editor question is very personal issue, TAB completion of commands or variable names is for me the main point of IDE. The IDE however changes the environment of running program and running time, so ultimately you must test it also from command line. I have managed quite OK with … | |
Re: I think it is too cumbersome for user to enter number of task, if you do not print the tasks with number before asking them. Do not use input in Python2 it is too dangerous, use `int(raw_input("prompt"))` | |
Re: By what software you are accessing the braille output to know it is connected well? With https://pypi.python.org/pypi/accessible_output/0.7.5#braille-outputs ?? ![]() | |
Re: 1600 entries should not be problem in PC's of today. So why actually you want to do it? Are you really getting memory error? Working in memory is simpler and faster. | |
Re: I think this is how you should have done it # include <iostream> # include <cmath> # include <string> using namespace std; void fallingDistance2(double &, double); double fallingDistance1(double); const double g = 9.8; double t; double d; int main() { cout<<"calculated by passby values.\n"; cout<<"Time \t\t Distance\n"; cout<<"-------------------\n"; for (t=1;t<=10;t++) … | |
Re: For me the only significant difference except for superficialities (put first statement of for as first inside while and third at end of while and keep the middle one) is that for parameters are optional, while parameter is not, so for( ; ; ) is correct infinite loop but while() … | |
Re: You would normally not touch the number, but only format [the way it is printed](http://docs.python.org/tutorial/inputoutput.html). | |
Re: It works for me Windows7 + Python 2.73 | |
Re: You are sorting ok, only you are sorting strings, so '10' < '2' | |
Re: Do not index string without checking that string exist i.e. if my_string: # processing string or use `try...except` block | |
Re: You can read and ignore the first line of other than the first file. I assume then form of these files is exactly same. Something similar to: def files_to_one(new_file, *files): with open(new_file, 'w') as fout: for fileno, fn in enumerate(files): with open(fn) as fin: print fileno, fn first = fin.readline() … | |
Re: I do not understand what you want to ask, your code is reasonable, except I do not recommend to repeat the field names instead of simple assignment using copy method to make fresh copy of dictionary. You may also have chicken and egg problem where to get the first file … | |
Re: `'\n'.join(str(element) for element in data)` Where data is iterable sequence you want to show one element per line. | |
Re: First thing I notice is line 9, where you write to new file for writing when file does not exist, even it is just created and can not have anything to read and secondly is opened for writing, not reading. | |
Here is simple text file example for beginners, using try..except for reading old content as it may not yet exist. | |
Re: What kind of webserver and web framework are you using? | |
Re: You first want the input as float, then int, later back to str, I think I am not quite sure what you are after. You assign variables with assignement as you have done already with your x,y and z variables. Can you give your code and error message for what … | |
| |
Re: No they are different lists with same items. If you want the items also as copies you should use deepcopy http://www.python-course.eu/deep_copy.php | |
Re: I somehow liked also the way Teemu Selänne and team handled the pronze game. Great finishing game for the most valuable player Teemu, couldn't be more proud. :-D | |
Re: Doesn't look Python code for me! [CODE]from sys import stdout def rev(a): while a: a, d = divmod(a,10) stdout.write(d) rev(int(raw_input('Give number: '))) [/CODE] | |
Re: local variables of results function are not also defined, maybe you missed parameters? | |
Re: Why to use import like this, modules are supposed to be modular? | |
Re: `**` unpacks the dictionary, so the call with `**greens` is same as writing the arguments as given to dict. Format takes keyword arguments with any names and uses them to replace them in curly brackets in the string. | |
Re: bin standard function might also be usefull as well as looking to the Code Snippets of certain active members. | |
Re: We need test cases input/correct output to help you out, if I catch your meaning, mantissa has assumed 1 as first number except when exponent is 0. What is offset of exponent. I would rewrite your nice formulas by writing one function to pop n bits out from least significant … | |
Re: Yes, considering how you initialize the circular queue, it does not agree with your definition of is_empty, for example. Nothing in your implementation looks like circular queue for me, I do not see head pointer, for example. Actually circular queue does not make much sense for me, when Python has … | |
| |
![]() | Re: 2. Finding the table 3. Copying the table exactly with open('data.txt') as data: data_parts = data.read().split("""Comparison of initial and final structures : --------------------------------------------------------------------------------""") print data_parts[1] |
Re: I see similarity to my yoyo range (downvoted even it is :( ) http://www.daniweb.com/software-development/python/threads/282438/yo-yo-for | |
Re: Why are you assigning file's read method to variable txt, that is deceptive naming? And you are not using the method anywhere. txt = open(filename).read | |
| |
Re: I did your task like this, but it can cut the file in middle of the line, and the file will not end with '\r\n'. def create_file_numbers(filename, size): with open(filename,'wb') as f: f.write('\r\n'.join(str(n) for n in range(size//2+1))[:size]) create_file_numbers('testnum.txt', 1000) Bit lazy for the needed range to get to string length … | |
Re: You do not use full path name nor the .py extension. The file must be at system search path or path pointed by PYTHONPATH environment variable. | |
Re: How this relates to C, are you hand optimicing generated code or what? | |
Re: I think, if you learn to understand what happens in my program: http://www.daniweb.com/software-development/python/code/439343/recursive-and-iterative-nuggets , you have fair chance of solving this problem. |
The End.