3,386 Posted Topics

Member Avatar for Tahir007

Go ahead, nice project. You do not consider wide availability of Python to many different architectures. You should put mention like [B]"currently working with Intel x86 based processors"[/B] to your project page. I would love to put some of my old Acorn Archimedes ARM2 code to test by module like …

Member Avatar for Beat_Slayer
1
140
Member Avatar for masterofpuppets

Then there is connected discussion aboult long binary numbers for your information in this thread (link directly to my solution) [url]http://www.daniweb.com/forums/post1219556.html#post1219556[/url]

Member Avatar for TrustyTony
0
798
Member Avatar for aframe

I do not know re so well, but I prefer partition for this kind of things. I use _ as variable name for the things I do not care about: [CODE]#!/usr/bin/env python import time import os myfile = """<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head> <meta http-equiv="refresh" Content="60;url=/stlui/user/allowance_request.html"> <title>Download …

Member Avatar for Tech B
0
627
Member Avatar for G_S
Member Avatar for sabashtin25

How about running the code with print in loop and after it. Gives me best insight. Second answer looks right, you work from inside the loop outwords. Here is my test in Python my favourite language: [CODE=PYTHON]## coding the loop in python and adding prints """for(i=1, i<=n, i++) for(int j=1, …

Member Avatar for AuburnMathTutor
0
65
Member Avatar for Duki

Generally I would like to group new thread with the quick reply area. What disturbs me more is the page browser being in bottom, not top of page. End key would be useful, but there is too many things after reply space, so must scroll back up after End.

Member Avatar for happygeek
2
214
Member Avatar for vegaseat

Nice concept but fails in execution: [CODE]# Roman Numerals # 2010-06-15, Eljakim Schrijvers # bug testing, translation of variables and reformating # Tony Veijalainen 2010-06-16 mapping = [ ('cd','cccc'), ('xl','xxxx'), ('iv','iiii'), ('d','ccccc'), ('l','xxxxx'), ('v','iiiii'), ('cm','ccccccccc'), ('xc','xxxxxxxxx'), ('ix','iiiiiiiii')] mapping.reverse() bignums = [ ('m',1000), ('c',100), ('x', 10), ('i',1) ] def fromroman(x): for …

Member Avatar for eljakim
0
3K
Member Avatar for kelokely

Something like this, can not test without those files: [CODE]import os ## assumes curdir is directory with the text files to process if not os.path.isdir(os.path.join(os.curdir,'joined')): os.mkdir(os.path.join(os.curdir,'joined')) for textfile in (fn for fn in os.listdir(os.curdir) if fn.endswith('.txt') and fn[4]=='_'): begin,_,end = textfile.partition('_') open( os.path.join(os.curdir, 'joined', begin+'.txt'), 'a').write(open(textfile).read()) [/CODE]

Member Avatar for TrustyTony
0
95
Member Avatar for aint

And there is the dict counting as comes from string and sorting the found letters in end: [CODE]text = 'ARARAKHTLROGKFMBLFKKGOHMFDGRKLRNGROGINFBLMNFBAEKJGFGOQEITHRGLFDKBN' letterc={} for i in text: if i in letterc: letterc[i]+=1 else: letterc[i]=1 for i in sorted(letterc.keys()): print(i,letterc[i]) """('A', 4) ('B', 4) ('D', 2) ('E', 2) ('F', 7) ('G', 8) ('H', …

Member Avatar for TrustyTony
0
107
Member Avatar for Duki

I suggested this in other. There could even be thread style list of day/time or how long ago and name of poster, like last post is now shown and maybe time based browsing back in time. Maybe too radical change though. I have tried the reverse time order for thread …

Member Avatar for TrustyTony
0
138
Member Avatar for hust921

In which case you need to brake? That is infinite loop. I would do server.quit() in sendIP(), I quess.

Member Avatar for hust921
1
99
Member Avatar for Narue

I think suggestion was only to mark the button INLINE, not to change the tag itself. By the way the button has not reappeared. When sending private mail to other, by the way, [CODE] by itself does not work, I have to edit and put [CODE=PYTHON], at least based on …

Member Avatar for TrustyTony
0
152
Member Avatar for ChargrO

\ is escape character for example '\n' is newline character at end of line. You can double it, as \\. Also you can use / in path instead of \ unix style. Mayby cleanest alternative however is to use r before quotes (raw string): [CODE]file=r"H:\SDD12\Images\roses.gif"[/CODE]

Member Avatar for TrustyTony
0
332
Member Avatar for MrAlshahawy
Member Avatar for MrAlshahawy
0
206
Member Avatar for TrustyTony

Here is solution number one for one word anagrams, I gave in discussion thread, response time in my humble Athlon PC under 70 ms. List of words is from original posting of the discussion thread. [url]http://www.daniweb.com/forums/post1206616.html#post1206616[/url] This version does not give we'd for input dew. Next time I give final …

Member Avatar for TrustyTony
0
1K
Member Avatar for Joslup

Open alternative to Flash, ming, has some python support, looks like: [url]http://pyswftools.sourceforge.net/howto.html[/url] [QUOTE]Flash Tools based on Ming (ming.sourceforge.net) implemented in Python. Aim to provide a library of code between the ming library and a Flash GUI (which does not yet exist!). Features include SVG conversation and following specified paths. [/QUOTE] …

Member Avatar for Joslup
0
314
Member Avatar for lewashby

From the way the code use int(input()) it looks that it is meant to use Python 3 where input is acting as raw_input in Python 2. Yes, probably it is good idea to do some try..except with input here to not let the code stop with crash. See for example …

Member Avatar for lewashby
0
109
Member Avatar for Syphilis

I installed your program and easygui, but your program just seems to hang up without any gui comming up. Seems to hang up with line 8: [CODE]Bound Entering loop[/CODE] [CODE]#!/usr/bin/python import socket from easygui import * server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.bind(("0.0.0.0", 5000)) print('Bound') server_socket.listen(5) print('Entering loop') while 1: client_socket, address …

Member Avatar for TrustyTony
0
93
Member Avatar for G_S

The installation of that requires perl to run the make file. Maybe works with Tkinter from python or not, I do not know, it is not written in python but tcl/tk. Here is one python solution I googled, maybe there is others. [url]http://tkinter.unpythonic.net/wiki/A_Text_Widget_with_Line_Numbers[/url] [CODE]"""A wrapper to show line numbers for …

Member Avatar for G_S
0
2K
Member Avatar for Sagar14

Your makematrix has inconsistent number of result two tuple or None. It gives only None result and the error comes. Either put the result first in single variable and only if it is not None, extract the parts of answer or change the definition: [CODE]def makematrix(allw,articlew): wordvec=[] for w,c in …

Member Avatar for Sagar14
0
147
Member Avatar for lstensland

You forgot to push the (CODE) button. I can not answer your question as the code does not run, but some things I have commented here. import twill, string, os ## not used import csv ## not used import urllib2 ## not used from twill import get_browser b = get_browser() …

Member Avatar for TrustyTony
0
361
Member Avatar for Muhammad Anas

import is taking files usually from the same directory as the script you write without problem, you only make sure that '.' is in your systems path or define another path variable PYTHONPATH with value D:\Python Practice\ or other locations of your own modules/books modules will be saved. Also it …

Member Avatar for snippsat
0
437
Member Avatar for lewashby

Use Python docs ( http://docs.python.org/library/sqlite3.html or for example IDLE F1): > Connection.row_factory > You can change this attribute to a callable that accepts the cursor and the original row as a tuple and will return the real result row. This way, you can implement more advanced ways of returning results, …

Member Avatar for lewashby
0
138
Member Avatar for TrustyTony
Member Avatar for TrustyTony
1
2K
Member Avatar for ppp88
Member Avatar for lewashby

[CODE]def find_details(id2find): surfers_f = open("surfing_data.csv") for eash_line in surfers_f: s = {} (s["id"], s["name"],s["country"], s["average"], s["board"], s["age"]) = eash_line.split(";") ## name field if id2find == int(s["id"]): surfers_f.close() return(s) return({}) lookup_id = int(input("Enter the id of the surfer: ")) surfer = find_details(lookup_id) if surfer: print("ID: " + surfer["id"]) print("Name: " + …

Member Avatar for TrustyTony
1
250
Member Avatar for alphaOri

This looks totally crazy spaghetti for me, but I tried to decipher what you are trying to do. [CODE]class parent: array = [1] ## class variable str = "person" def __init__(self, var): choose(var) ## choose(2), value never used, only side effect to array class child1(parent): def __init__(self, var): self.array.append(var) self.str …

Member Avatar for alphaOri
0
151
Member Avatar for prashanth s j

Closing tag is > Hi thanks for the reply. > Based on your reply I wrote a script that contains the calling of the command "random" within the script itself. And it worked. What I did next was in place of the command "random" I gave ftp script as the …

Member Avatar for prashanth s j
0
207
Member Avatar for kelokely

csv files are text, so maybe the b for binary operation is overkill. But example input was plain text. It would be good though that output files would not become inputs if program is run again. I usually create output folder to put the results. If you like to do …

Member Avatar for baki100
0
118
Member Avatar for vlady

Letters have different frequencys and the list is built from input source to reprecent the frequency by multiplication.

Member Avatar for TrustyTony
0
161
Member Avatar for kurtiskain

Usually you read in all file do change in memory and write back whole file. Or you have field in line (say first letter) that can be written one value to mark the record deleted (say D or #). The reading routine then ignores those lines.

Member Avatar for griswolf
0
139
Member Avatar for ihatehippies

Maybe you could use this function I wrote adapted from my scrambled word solver solution: [CODE]def insequence(k,s): """ goes through the letters of first word (k) and returns the letters which are in same order in both words """ i = 0 result = '' for c in k: i …

Member Avatar for TrustyTony
0
2K
Member Avatar for i-teq

you are defining currency the way that has little added value. Your init looks fine in style. Consider though that i have not much OOP experience myself. Here my 5c anyway. I would define currency converter which would have base currency. The rates would be fed in that currency. Stock …

Member Avatar for i-teq
0
4K
Member Avatar for photoyid

Windows: [url]http://docs.python.org/faq/windows.html#how-do-i-check-for-a-keypress-without-blocking[/url] Linux etc: [url]http://docs.python.org/library/curses.html[/url]

Member Avatar for TrustyTony
0
869
Member Avatar for lstensland

To take only links which contain products from your (not CSV) data: [CODE]for x in open('linklist.txt').readlines(): _,_,link=x.partition(' ==> ') if 'products' in link: print link[/CODE]

Member Avatar for lstensland
0
444
Member Avatar for Pineapplesf

[CODE]x= [[8, 9, 7], [1, 2, 3], [5, 4, 3], [4, 5, 6]] x.sort(key=lambda x: x[0]) print x [/CODE]

Member Avatar for vegaseat
0
13K
Member Avatar for tzushky

I do not recommend to continue to use this kind of style in Python. Could you dig up some real use case with input data and sample output (preferably one function only), so we can suggest how you should adapt your style. Anyway, in Python function is not separate from …

Member Avatar for tzushky
0
276
Member Avatar for Chupakun

Consider your level of experience you might find my example code snippet: [url]http://www.daniweb.com/code/snippet283859.html[/url] Or some other posts of Tkinter code of mine useful. (click user name -> Find all posts by.. , to find all posts of a user)

Member Avatar for Chupakun
0
1K
Member Avatar for G_S

General way to open associated program, but unfortunately only for Windows is to use [ICODE]os.startfile()[/ICODE]

Member Avatar for G_S
0
4K
Member Avatar for ic_m

I have posted one example of my coding here: [url]http://www.daniweb.com/forums/post1188875.html#post1188875[/url] You can make simpler version of this based on your input, this code is for more complicated case of number values from string. [CODE]if x in 'abc':[/CODE] or [CODE]if x not in 'abc':[/CODE] Might be handy for validating letters.

Member Avatar for baki100
0
186
Member Avatar for cyon

How about main routine catching the exceptions. Or do you need to catch them if you anyway want program to crash with trace?

Member Avatar for TrustyTony
0
379
Member Avatar for radioflyer1

Maybe this could help you to start, change your betting according to new data structure of dictionary instead of simple scalar variables: [CODE]print ("It's a beautiful day out here folks. A fine day for a horse race. Grab your mint julips, extravagant hats, and head over to the betting booths …

Member Avatar for radioflyer1
0
197
Member Avatar for G_S
Member Avatar for lewashby

The code is nice style, but it has one problem of generality: it uses string comparison for numbers from line split which are not necessary in same length of numbers. reverse= True, gives value True to parameter reverse. By giving name of parameter you can not mix up the parameters …

Member Avatar for vegaseat
0
98
Member Avatar for lewashby

It does show ID for me: [CODE]Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> line = "101;johnny 'wave-boy' Jones;USA;8.32;Fish;21" >>> >>> s = {} >>> >>> (s['id'], s['name'], s['country'], s['average'], s['board'], s['age']) = line.split(";") …

Member Avatar for snippsat
0
159
Member Avatar for pyprog

self name for the first parameter is just convention, but mostly it is sensible to use that name for that for clarity.

Member Avatar for pyprog
0
108
Member Avatar for miac09

[QUOTE=miac09;1239987]Hi, I have the following files and can match but, am having trouble with getting the output to write correctly to a data matrix format that I need and would appreciate any help with getting the code right- File 1 has a list of numbers and Files 2, 3 and …

Member Avatar for woooee
0
198
Member Avatar for TrustyTony

I have been thinking about order operations and generalized * in Python recently. I want to share some of my thinking here, even the topic is quite theoretical, considering the beauty and orthogonality of the language. [B]Point one[/B] You can do comparison with tuples of numbers in Python [CODE]>>> (0,0)<(1,1)<(2,2) …

Member Avatar for TrustyTony
0
338
Member Avatar for Tommymac501

Give exact format of input you should use. Looks like it is only matter of simple string.split() function from open(file) to parse it. Could you post also your quick sort function and expected output of all. If you also include the input data fro Advanced Editor -> Manage Attachments, it …

Member Avatar for TrustyTony
0
94
Member Avatar for vlady

You have not [CODE]import string[/CODE] at least. Also process_line is not defined (there is one function named process_line1 though) Finally you are not calling any functions only loading two files.

Member Avatar for woooee
0
1K

The End.