3,386 Posted Topics

Member Avatar for tubby123

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.

Member Avatar for Momerath
0
177
Member Avatar for Gribouillis

[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 …

Member Avatar for Gribouillis
1
300
Member Avatar for M.S.

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') >>> …

Member Avatar for M.S.
0
165
Member Avatar for tubby123

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.

Member Avatar for mrnutty
0
106
Member Avatar for Archenemie
Member Avatar for Tech B
0
278
Member Avatar for TrustyTony

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 …

Member Avatar for TrustyTony
0
2K
Member Avatar for bharatk

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]

Member Avatar for bharatk
0
2K
Member Avatar for TrustyTony

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 …

Member Avatar for tigerbright
0
233
Member Avatar for sdwinanta

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]

Member Avatar for TrustyTony
0
156
Member Avatar for Charly-Garcia

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 | …

Member Avatar for Gribouillis
0
158
Member Avatar for liran

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]

Member Avatar for liran
0
163
Member Avatar for NewbieinC

"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?

Member Avatar for sfuo
0
99
Member Avatar for emcyroyale

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]

Member Avatar for emcyroyale
0
158
Member Avatar for sherinpoulose
Member Avatar for Simplicity.
Member Avatar for TrustyTony
0
79
Member Avatar for vincenzorm117

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.

Member Avatar for vincenzorm117
0
1K
Member Avatar for theharshest

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.

Member Avatar for griswolf
0
310
Member Avatar for Pprog

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]

Member Avatar for Gribouillis
0
2K
Member Avatar for M.S.

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)

Member Avatar for M.S.
0
109
Member Avatar for debasishgang7

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 …

Member Avatar for abhimanipal
0
191
Member Avatar for KLIM8D

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 …

Member Avatar for TrustyTony
0
1K
Member Avatar for TrustyTony

This does not look very efficient with transponation, sort and transponation back, so I am happy to hear about better alternatives.

Member Avatar for TrustyTony
0
333
Member Avatar for terious

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]

Member Avatar for TrustyTony
0
117
Member Avatar for TrustyTony

Another task from C++ forum is trivial in Python even taking handicap of not using Counter.

0
524
Member Avatar for Sonia11

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 …

Member Avatar for TrustyTony
0
127
Member Avatar for lewashby
Member Avatar for TrustyTony

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).

0
826
Member Avatar for duffsil

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 …

Member Avatar for duffsil
0
166
Member Avatar for jingda

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 …

Member Avatar for TrustyTony
1
491
Member Avatar for angelsakura

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).

Member Avatar for WaltP
0
2K
Member Avatar for bsh6wc

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: …

Member Avatar for TrustyTony
0
262
Member Avatar for Boubakr

[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 …

Member Avatar for TrustyTony
0
143
Member Avatar for ineedsomehelp:3

You could use up counting for to increment the stop condition of inner loop and manage with two nested fors.

Member Avatar for Arbus
0
215
Member Avatar for kamragunjan

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]

Member Avatar for TrustyTony
0
67
Member Avatar for Smed

[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]

Member Avatar for TrustyTony
0
140
Member Avatar for kharlie
Member Avatar for flebber

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]

Member Avatar for TrustyTony
0
301
Member Avatar for dilequeno

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?

Member Avatar for TrustyTony
0
325
Member Avatar for adrianandreev

Maybe this could help you [url]http://stackoverflow.com/questions/4273252/detect-inserted-usb-on-windows[/url]

Member Avatar for TrustyTony
0
11K
Member Avatar for debasishgang7

Here is document describing calculation of checksum: [url]http://www.faqs.org/rfcs/rfc1071.html[/url]

Member Avatar for debasishgang7
0
99
Member Avatar for debasishgang7

And your code and reference for the sources of information you are supporting it? And what is your problem with it?

Member Avatar for debasishgang7
0
450
Member Avatar for TrustyTony

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 …

Member Avatar for bumsfeld
1
501
Member Avatar for sneekula

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 …

Member Avatar for halamas
0
20K
Member Avatar for pro_learner
Member Avatar for pro_learner
0
265
Member Avatar for vegaseat

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 …

Member Avatar for bumsfeld
6
768
Member Avatar for magnetic rifle
Member Avatar for user45949219

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 …

Member Avatar for TrustyTony
0
155
Member Avatar for danswater

-?location(california, X) Your output looks not possible as you have no tany stamp in your DB.

Member Avatar for TrustyTony
0
225
Member Avatar for deb0and

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?

Member Avatar for deb0and
0
878
Member Avatar for zidaine

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[:] >>> …

Member Avatar for TrustyTony
0
138

The End.