3,386 Posted Topics
Re: Dynamic programming worked for me in Python, I am not sure how efficient you can make your recursive algorithm, probably need memoized function to approach dynamic programming approach. Looks like you want to find the length of the common sequence only. | |
Re: [QUOTE]This is useful for example when a program needs to pass a new filename to a function which does not accept a file object argument. [/QUOTE] You can also pass .name of the file object but then you should close the file by hand before function reopens it from the … | |
Re: You are having unnecessary closing of quotes and plusses: [CODE]import urllib City="%D9%85%D9%87%D8%B1%D8%A7%D9%86" Province="%D8%A7%DB%8C%D9%84%D8%A7%D9%85" myurl = 'http://www.owghat.com/owghat.png.aspx?Province=%s&City=%s'%(Province, City) #the real address is:http://www.owghat.com/owghat.png.aspx?Province=%D8%A7%DB%8C%D9%84%D8%A7%D9%85&City=%D9%85%D9%87%D8%B1%D8%A7%D9%86 a="e:\\img.png" urllib.urlretrieve(myurl,a) [/CODE] Your string seems not valid for utf-8: [CODE]>>> u'مهران'.encode('utf-8') Unsupported characters in input [/CODE] Otherwise you could do like this: [CODE]>>> c = u'Hölmö hämäläinen'.encode('utf-8') >>> … | |
Re: You mean letter of highest frequency? I think sorting by counting and finding the maximum is equivalent problem if you are not dealing with unicode. | |
Re: At least type import lower case as python is case sensitive. | |
Here is Mandelbrot set viewer in Tkinter and modules for shedskining (included compiled modules for windows in the zip file): [CODE]# mandelsh.py def mandel(real, imag, max_iterations=20): '''determines if a point is in the Mandelbrot set based on deciding if, after a maximum allowed number of iterations, the absolute value of … | |
Re: You can not find corresponding element from other list by min2. Use this corresponding relation: [CODE]corresponding(A, B, [A|_], [B|_]). corresponding(A, B, [_|C], [_|D]) :- corresponding(A, B, C, D). [/CODE] [CODE]| ?- corresponding(X, 3, [a, b, c], [5, 3, 6]). X = b ? a no | ?- [/CODE] | |
We have here at our home my wife's work computer. While not today's hottest iron, it is still Centrino Duo machine, runningn WinXP Professional with 1 GB RAM. Our home machine is aged AMD Semptron 3100+ (1.81 GHz) and has 2 GB RAM running WindowsXP Home. While running my Mandelbrot … | |
Re: Have you listened of site called Google. I usually find it very usefull, for example from simple quary, I got this: [url]http://arstechnica.com/open-source/guides/2010/04/tutorial-use-twitters-new-real-time-stream-api-in-python.ars[/url] | |
Re: Use code tags for fixed format text [CODE=text] 012345678901234567890123456789012345678901234567890 abcdefgh: 1234 5678 45 45 45 45 abcdefgh: 1234 45 45 45 abcdefgh: 1234 45 45 45 abcdefgh: 1234 5678 45 45 45 abcdefgh: 1234 5678 45 45 45 into 012345678901234567890123456789012345678901234567890 |abcdefgh:| 1234| 5678 | 45 | 45 | 45 | … | |
Re: You would need to install chilkat module [url]http://www.chilkatsoft.com/python.asp[/url] for your python version and use the code: [url]http://www.example-code.com/python/zip_AppendRenamed.asp[/url] | |
Re: "Begiining is good place to start" [url]http://www.cplusplus.com/doc/tutorial/program_structure/[/url] Compare the structure of the example and yours. Can you find any difference? | |
Re: OpenCV could be nice place to start, as I understand it has webcam support and supports various programming languages and operating system. [url]http://opencv.willowgarage.com/wiki/[/url] | |
Re: Use C# forum for C# questions. | |
Re: This might be good place to start: [url]http://wiki.python.org/moin/ParallelProcessing[/url] | |
Re: How about simple "qwerty.txt", without path, shouldn't it mean the same? What error message are you getting? You should check the return value in variable userfile for the error. | |
Re: For me [URL="http://www.cherrypy.org/"]cherrypy [/URL]looks most nice to program with, of course there is plenty of alternatives and Django is quite popular like also Pylons and Turbogears. | |
Re: Are you following the forum? I just posted yesterday one counter program without using modules: [url]http://www.daniweb.com/software-development/python/code/373760[/url] | |
Re: Do not reinvent the wheel, use codecs module: [url]http://www.doughellmann.com/PyMOTW/codecs/[/url] (non-unicode stuff is at the end part of the post) | |
Re: You have doubled lines 3 and 4. There is max 8 characters read from file with no null termination, then you try to pass it as char parameter to function exe (which should not work), to try to print the letter. I do not get it. You are not trying … | |
Re: timer_update -> if Paused do nothing else put to label current_time - paused_time - start_time Pause pushed -> if in Paused state add current_time - pause_start_time to paused_time else save current_time to pause_start_time. Why you are used capitalized object names (like Reset) for methods? If you have not any super … | |
This does not look very efficient with transponation, sort and transponation back, so I am happy to hear about better alternatives. | |
Re: I posted code snippet for sorting data by header row: [URL="http://www.daniweb.com/software-development/python/code/373798"]Code Snippet: Sorting columns of data by header name[/URL] | |
Another task from C++ forum is trivial in Python even taking handicap of not using Counter. | |
Re: With such restrictions given and with speed of current computers as it is, I would say that you just do it simply, primitively and fast enough (I do know more C than C++): [LIST=1] [*]Do struct with 3 letter id and count for enough numbers [*]From first number step forward … | |
My not OO version of timer for work and pause time (but it does use attributes for functions, which are objects, to avoid global declarations in functions). | |
Re: You have much dublication of code, which makes your code difficult to maintain. Please refactor. Your choice of user interface is also not to my liking, I would prefer interface with add and modify buttons and grid in ranking order for any number of girls with their own names instead … | |
Re: The thread is marked solved, but as I have something of value, I still bump this one. If post is good intending thanks, delete post and send standard response PM advicing about giving rep to good answers. Close old threads, but add in end message to possible late answers suggestion … | |
Re: Do not use goto and functions like part2, mathematics is never called and you have repeated same lines instead of using a function (refactor to function). | |
Re: Drop extra lines from beginning and use my code snippet: [url]http://www.daniweb.com/software-development/python/code/293490[/url] [CODE]# text based data input with data accessible # with named fields or indexing from __future__ import print_function ## Python 3 style printing from collections import namedtuple import string filein = open("sample.dat") datadict = {} for line in filein: … | |
Re: [CODE]>>> lst = ['10:User1', '80:User2', '100:User3', '00:User4', '75:User4', '45:User5'] >>> print(sorted(lst, key=lambda x: int(x.split(':',1)[0]))) ['00:User4', '10:User1', '45:User5', '75:User4', '80:User2', '100:User3'] >>> print(sorted(lst, key=lambda x: int(x.split(':',1)[0]), reverse=True)) ['100:User3', '80:User2', '75:User4', '45:User5', '10:User1', '00:User4'] >>> [/CODE] key parameter defines sorting order, in this case we take first part before ':' and make … | |
Re: You could use up counting for to increment the stop condition of inner loop and manage with two nested fors. | |
Re: You read this sticky of this forum, didn't you? [URL="http://www.daniweb.com/software-development/computer-science/threads/324685"] A brief introduction to Big-O Notation (The Big-Oh! Notation)[/URL] And wikipedia article: [url]http://en.wikipedia.org/wiki/Big_O_notation[/url] | |
Re: [CODE] import re text = 'Reference [14] and Reference [17] are References.' print re.sub('Reference \[','Ref. [',text) print 'Without re' print text.replace('Reference [','Ref. [') [/CODE] | |
Re: Just post your code and your error log with code-tags. | |
Re: What is wrong with set, if order need not be preserved: [CODE]>>> x = [2,3,1,3,5,4,5] >>> print([2*a for a in set(x)]) [2, 4, 6, 8, 10] >>> [/CODE] | |
Re: numpy histogram function looks close to your needs, it is designed for using with Python language though, probably written with C though and source code is open source. [url]http://amusecode.org/doc/examples/simple/salpeter.html[/url] Maybe worth to hunt through C++ libraries for histogramming? | |
Re: Maybe this could help you [url]http://stackoverflow.com/questions/4273252/detect-inserted-usb-on-windows[/url] | |
Re: Here is document describing calculation of checksum: [url]http://www.faqs.org/rfcs/rfc1071.html[/url] | |
Re: And your code and reference for the sources of information you are supporting it? And what is your problem with it? | |
Breakin news item from [url]http://python.org/download/releases/3.2.1/[/url] (hope the input from command line will also be fixed) Python 3.2 is a continuation of the efforts to improve and stabilize the Python 3.x line. Since the final release of Python 2.7, the 2.x line will only receive bugfixes, and new features are developed … | |
Re: Something like this (did not read the original code of this thread though, next time start your own thread and include link to old thread if you like)? [CODE]input_text = """this is a fat cat that is a large pan that is a thick slice of bread""" targets, new, output … | |
Re: [url]http://forums.oracle.com/forums/thread.jspa?threadID=897559[/url] | |
Re: Yes Tiger Goddess Narue can write (text sometimes as well as C/C++ which seems to be her mother tongue ;) ) The discription of [CODE] button could be updated. My preference is to push the button right before pasting so you can avoid tedious and error prone painting the region … | |
| |
![]() | Re: Also it is generally better idea to keep information together. So you would have one info list with [[name, age], [othername, otherage] ....] Your reading file by bytekinds is un-ideomatic, as I understand you have fixed lenght line of 20 for name and 2 for age. I would say like … |
Re: -?location(california, X) Your output looks not possible as you have no tany stamp in your DB. | |
Re: Line 40 has no purpose. You are replacing the function find_session_id with slice at line 41, what is purpose of that? You have read [url]http://docs.python.org/library/email-examples.html[/url], haven't you? | |
Re: To retain the value you should prepare copy of the list, if deep copy is not needed, you can do it with slicing (otherwise use copy module) [CODE]>>> a=[{'a':1,},{'b':2,}] >>> b = a >>> b.pop(0) {'a': 1} >>> a [{'b': 2}] >>> b [{'b': 2}] >>> a=[{'a':1,},{'b':2,}] >>> b=a[:] >>> … |
The End.