3,386 Posted Topics
Re: 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 … | |
![]() | Re: 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] |
Re: 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 … | |
Re: Here is attached my test. I did not find any problem. | |
Re: 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, … | |
Re: 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. | |
Re: 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 … | |
Re: 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] | |
Re: 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', … | |
Re: 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 … | |
Re: In which case you need to brake? That is infinite loop. I would do server.quit() in sendIP(), I quess. | |
Re: 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 … | |
![]() | Re: \ 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] |
Re: Any help from [url]http://snippets.dzone.com/posts/show/1643?[/url] | |
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 … | |
Re: 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] … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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() … | |
Re: 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 … | |
Re: 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, … | |
I used this pattern few times to answer a thread and thought to post it as snippet. | |
Re: [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: " + … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: Letters have different frequencys and the list is built from input source to reprecent the frequency by multiplication. | |
Re: 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. | |
Re: 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 … | |
Re: 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 … | |
Re: 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] | |
Re: 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] | |
Re: [CODE]x= [[8, 9, 7], [1, 2, 3], [5, 4, 3], [4, 5, 6]] x.sort(key=lambda x: x[0]) print x [/CODE] | |
Re: 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 … | |
Re: 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) | |
Re: General way to open associated program, but unfortunately only for Windows is to use [ICODE]os.startfile()[/ICODE] | |
Re: 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. | |
![]() | Re: How about main routine catching the exceptions. Or do you need to catch them if you anyway want program to crash with trace? |
Re: 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 … | |
Re: elif can follow only if or other elif on same indention level | |
Re: 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 … | |
Re: 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(";") … | |
Re: self name for the first parameter is just convention, but mostly it is sensible to use that name for that for clarity. | |
Re: [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 … | |
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) … | |
Re: 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 … | |
Re: 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. |
The End.