3,386 Posted Topics

Member Avatar for xheavenlyx

How about using [url]http://docs.python.org/library/msvcrt.html[/url] Keyboard reading and console printing functions. Or maybe it is possible to use curses or readline routines? Also if user has input things in keyboard they are in keyboard history and user can return to them by arrow keys and correct them.

Member Avatar for xheavenlyx
0
116
Member Avatar for gabyallheart

Don't forget code tags please (now the # sign in tool bar) [QUOTE=gabyallheart;1216941]I have this program, is working good but i got error when the rows are full because stop and not keep going...can some one help me please..:) [CODE]import random class Rack(object): def __init__(self, cols, rows): self.rows = rows …

Member Avatar for TrustyTony
0
89
Member Avatar for voolvif

How about doing 1) statistics run with that normal inmemory set and then taking the found starting numbers in memory to sort with repeated read of file for each starting number. Or you could write each ip xx.yy.zz.aa to file ipsxx.txt, where xx,yy,zz,aa are two number hex representations of ip …

Member Avatar for TrustyTony
0
2K
Member Avatar for sob_andizzle
Member Avatar for TrustyTony
0
106
Member Avatar for jpl1993

Here is how: [CODE] >>> import random,string >>> t=[] >>> for i in range(20): s='' for j in range(random.randint(3,10)): s=s+random.choice(string.ascii_lowercase) print s t.append(s) ktpwmhc oottmafdv mlalyaig redmmtv bmoflbd gsagulicx qzfvmdz lsviy bdffmd bdmk dtqjnwhla lufobzcqk lfnnf ppv tghkzqxtja bouvqq dbccxvuke vvmmvxl saelhkhgya knwjvdsv >>> s 'knwjvdsv' >>> t ['ktpwmhc', 'oottmafdv', …

Member Avatar for lllllIllIlllI
0
141
Member Avatar for ktsangop

How about this: [CODE]>>> import sys >>> for i in r"\x03\xa2": sys.stdout.write(i[:1]) \x03\xa2 >>> [/CODE]

Member Avatar for ktsangop
0
268
Member Avatar for dbphydb

Maybe you could adapt my strategy in [url]http://www.daniweb.com/forums/post1210294.html#post1210294[/url] ??

Member Avatar for dbphydb
0
117
Member Avatar for TrustyTony

I started to think how to create up and down style loop, and what I ended up was this. Wanted to do it little unconventional way though to demonstrate the property of range as list.[code]for n in range(8): for i in range(n)+range(n-2,-1,-1): print i, print """ Output: 0 0 1 …

Member Avatar for TrustyTony
-1
484
Member Avatar for jpl1993

(code) button must be used to paste program in understandable and original form. So you are not allowed to use built in sort or what? You did not give explanation of your title nor what is your request. Also why you are redefining the `__init__` instead of using object defined?

Member Avatar for griswolf
0
123
Member Avatar for bbman

Maybe you could use the properties of set objects: [CODE] >>> a=set(['1','a','b',2]) >>> '1' in a True >>> 1 in a False >>> 'c' in a False >>> [/CODE] You can also check this my code snipet for ideas: [url]http://www.daniweb.com/code/snippet282009.html[/url]

Member Avatar for Ene Uran
-1
117
Member Avatar for dreadyteddy

Edit: [/code] without / [QUOTE=dreadyteddy;1213706]I am TRYING to write a program that finds restriction sites in a DNA file and returns a picture and information box of the enzyme which cuts it. My problems are; a) I have no idea if my program works past opening the file directory. b) …

Member Avatar for dreadyteddy
0
854
Member Avatar for eric_arambula

> Ok. I added a menu now. Everything working however, I want for it to ask me Want to continue adding (y) or (n). If no go to main menu. What do you think ? import time ## why this? menu = """ Choose the operation to do (1-2): 1) …

Member Avatar for eric_arambula
0
105
Member Avatar for ArtemisFowl
Member Avatar for asthaynian

You forgot code tags! [QUOTE=asthaynian;1214064]I'm trying to make quiz GUI. The GUI has one button and an entry box. The user presses the button and it asks a random question from using the world database. After 10 questions, it tells you the number correct and incorrect. I'm having a lot …

Member Avatar for TrustyTony
0
1K
Member Avatar for morteza_ipo

Not ideal for that but for example there is pypy (see [url]http://pypy.org[/url]) python just-in-time compiler (not many modules included), which is quite heavy class of programming. If you want exe to speed up your program check that (I found however that file operations are quite slow in Windows with that) …

Member Avatar for Ene Uran
0
103
Member Avatar for aint

Or maybe more Pythonicaly and not so difficultly (look it up, and see which one you prefer) [CODE] # multiple searches of a string for a substring # using s.find(sub[ ,start[, end]]) def multis(search,text,start=0): while start>-1: f=text.find(search,start) start=f if start>-1: yield f start+=1 print("tonyjv: pythonic generator") print(" from vegaseat's code") …

Member Avatar for TrustyTony
0
601
Member Avatar for saba_newbie
Member Avatar for TrustyTony

Here is some saved interaction in command prompt. [CODE]>>> type((1,2)) <type 'tuple'> >>> (3*x for x in (4,4)) <generator object <genexpr> at 0x00E73EB8> >>> tuple(x**2 for x in range(10)) (0, 1, 4, 9, 16, 25, 36, 49, 64, 81) >>> set(x for x in range(10)) set([0, 1, 2, 3, 4, …

Member Avatar for TrustyTony
-3
714
Member Avatar for elvis1

Sorry, but because nobody has given yet answer let me offer the Pythonic version in my 'magic separator check' approach [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\:[0-9]{1,5} I do have some basics on regurlar expressions, though they come in some variations. I interpret that proxy is something in form 0+.0+.0+:9+ where 0+ is min 1, max …

Member Avatar for elvis1
0
192
Member Avatar for eleonora

You need to click that code button before pasting the code, otherwise the white space is messed up!

Member Avatar for TrustyTony
0
3K
Member Avatar for TrustyTony

This problem came up in one thread and here is my finalised version to follow changes of files in list of paths given.

0
718
Member Avatar for shyami

The point really is not to use len(a) but len(a)-1 as maximum. This also helps to understand why range(5) gives numbers 0 until 4. [CODE]>>> a=['a','b','c'] >>> print a[len(a)] Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> print a[len(a)] IndexError: list index out of range >>> for …

Member Avatar for TrustyTony
0
88
Member Avatar for lorna2010

Think progress of one game, what user sees, what he inputs, what computer shows/asks, how the game finishes. Find different objects and actions from the story and start coding. Post the results when you have created main logic and/or first part of the solution. By the way to get fixed …

Member Avatar for happy123
0
147
Member Avatar for alabandit

Does this help you? Pretty is my module which I posted you can replace it with normal prints and use your paths of course. [CODE]import os import pretty path_to_watch = [] path_to_watch.append("/Tony/Tests") path_to_watch.append("/Python Projects/") path_to_watch.append("/Python26/Lib/site-packages") before = [],[] for item, folder in enumerate(path_to_watch): ## print "i am here", item, " …

Member Avatar for TrustyTony
0
247
Member Avatar for gorbulas

Mayby your algorithm performance slows down like n**2 or n!. (O(n**2) or O(n!)) Or the memory is tight. Maybe you could put somewhere for .... in open(..) instead of string to compare? Could you post the hardest working function and maybe time the performance of with different. Also you could …

Member Avatar for TrustyTony
0
6K
Member Avatar for ChargrO

I would call assigning None over given parameter to function very bad style, sorry to say so. I also do not like local variables never used after assignment like this parameter master.

Member Avatar for TrustyTony
0
472
Member Avatar for jonb7

If you disregard the tag info, including the qroups, which in example have different sets of user (you must split from <group to deal them separately): [CODE] oldfile = 'user.txt' filename = 'userchanged.txt' f1 = [line.strip() for line in open(oldfile, 'r') if line.startswith('<name>')] ## generator changed to list f2 = …

Member Avatar for TrustyTony
0
1K
Member Avatar for afireinside

That code is fundamentally wrong, I do not understand your post. It is impossible to run that code. For example you have defs without ':' [CODE] IDLE 2.6.4 >>> def askopenfilename(self) filename = tkFileDialog.askopenfilename(**self.options) print filename return filename SyntaxError: invalid syntax >>> Class App: SyntaxError: invalid syntax >>> [/CODE] You …

Member Avatar for TrustyTony
0
278
Member Avatar for jonb7

If you could narrow down still more, include real error message, put as attachment any needed external files, could be possible to give ideas. As is only the top gurus can read this code without live run debugging. Could you put some prints just before error point or give super …

Member Avatar for jonb7
0
267
Member Avatar for pythonNerd159

I do not get any errors when running the code, could you include erron messages, input then, expected output and what you did to spot the problem (printing to spot the place of problem)

Member Avatar for vegaseat
0
123
Member Avatar for Alq Veers

You mean like this: [CODE] # # File: gui_secondGen_v0.02.pyw # Programmer: A. Smith # Created: 20100323 # Edited: 20100504 # Time: 10:01 # Notes: # 1) Working way down page. Class menu, screen, controls. # try: # Python2.x from Tkinter import * except ImportError: # Python3.x import tkinter as tk …

Member Avatar for Alq Veers
0
155
Member Avatar for tyuo9980

Please use elif instead of if, except for the first condition, your function looks strange, those condiitions are mutually exclusive! better still prepare dict with the keys and do [icode]if event.Ascii in key_dict: buffer+=key_dict[event.Ascii][/icode] Maybe there is Keycode event for individual key detection in the module which you are using?

Member Avatar for tyuo9980
0
152
Member Avatar for cahram

I think from previous thread that only knowing existence of element is not enough in this case. here is some searching example in 2d: [CODE] yList = [['dog', 'cat']] myList.append( ['lizard', 'sheep', 'pig']) print myList for i,li in enumerate(myList): if 'sheep' in li: print 'sheep list is list %i:'%i,li print …

Member Avatar for TrustyTony
0
202
Member Avatar for linuxoidoz

[CODE] for property in self.lstProperty: if property.attrib["name"] == strProperty: #do something else: #do something else if did not break out of loop[/CODE] [CODE] >>> x=2 >>> for i in range(1,x): if x>3: break else: print 'Hello else' Hello else >>> x=4 >>> for i in range(1,x): if x>3: break else: …

Member Avatar for linuxoidoz
0
31K
Member Avatar for awn
Member Avatar for valorien

This code was part of one post earlier in DaniWeb, I did not have energy now to pin point the post so I include it here (it was about polish characters I think) This code seems to have difficulty in doing ls or (dir) in root directory in WindowsXP at …

Member Avatar for d5e5
0
3K
Member Avatar for prashanth s j

This works directly as you wrote, if the length of tupple is 1 and contains only 1 two-tupple with same 0-elment [CODE] >>> if [('WER', 100)] < [('WER', 700)] : print "values for 2 is greater" #statements follow values for 2 is greater >>> [/CODE]

Member Avatar for TrustyTony
0
111
Member Avatar for bpinheiro0186

[QUOTE=bpinheiro0186;1207734]Hey folks, I am new on the forum and new to Python. I am making a news site and using python/django. My site will get all the news from the DB and fill up the template. As there is about 10 lines for the news and at some moment i …

Member Avatar for TrustyTony
0
121
Member Avatar for giri.pankaj

I have done full anagram program with weeks of performance testing about which I did one post to this forum. These both programs look overly complicated. I will publish one word version based on my algorithm shortly as code snipet together with speed comparision to these posted versions.

Member Avatar for TrustyTony
0
4K
Member Avatar for mehdi0016

One Laptop per Child project based mostly on Python uses library called Pango to support special 3rd world country languages (maybe I saw even Farsi mentioned). Maybe you could check it out. [url]http://wiki.laptop.org/go/Farsi[/url] [url]http://www.google.fi/url?sa=t&source=web&ct=res&cd=2&ved=0CA8QFjAB&url=http%3A%2F%2Fwiki.laptop.org%2Fgo%2FTestimonials&ei=HCbgS--FLqecOKW2sa4I&usg=AFQjCNE5KWrg4xBqrV34hqnqieiQDIX99Q&sig2=xCQwP_r9WeIcfGWb7at2aw[/url]

Member Avatar for TrustyTony
0
95
Member Avatar for mysticstylez

Or do without re: [CODE]## tennumber filter without re test="""4616186224 3501292628 2698109000 4398248508 8462632398 5414846117 9167449701 5097458418 4F882945714 456729994744 4563249 """ def tennumbers(a): sep=[x for x in a if not x.isdigit()] if sep<>[] : return "" ## not numbers elif len(a) == 10: ## ten numbers and newline return a+'\n' …

Member Avatar for TrustyTony
0
7K
Member Avatar for pythonNerd159
Re: tk()

Check out this code which does 8 buttons and handles them in one function. Any help? [CODE] #!/usr/local/bin/Python import Tkinter def doButton(buttonName): global but print buttonName class SimpleCallback: def __init__(self, callback, *firstArgs): self.__callback = callback self.__firstArgs = firstArgs def __call__(self, *args): return self.__callback (*(self.__firstArgs + args)) if __name__=="__main__": root = …

Member Avatar for pythonNerd159
0
170
Member Avatar for dbphydb

Maybe good to copy link one time instead of download in the manual download and save the link to file, and post the file? Maybe repeat x times (maybe close browser in between) to see if clients_test# changes? Do search through links ignoring obviously wrong for final pattern in the …

Member Avatar for Udai02
0
5K
Member Avatar for naktos

This should tell you the reason [CODE]>>> x= 0 >>> for i in range(9): x += 0.1 print x-0.9 # print the damn thing. if x < 0.9: print 'Yes' else: print "No" -0.8 Yes -0.7 Yes -0.6 Yes -0.5 Yes -0.4 Yes -0.3 Yes -0.2 Yes -0.1 Yes -1.11022302463e-16 …

Member Avatar for TrustyTony
0
115
Member Avatar for bharatk

I would do it like this with list comprehension Little funny sequence as it includes only one element from a in formula. [CODE] >>> b[:2] [2, 10] >>> c=[a[0]+b[0]] >>> c.extend([sum(b[:x]) for x in range(2,len(b)+1)]) >>> c [2, 12, 18, 21] >>>[/CODE]

Member Avatar for bharatk
0
109
Member Avatar for sabiut

If you want function instead of changing the order of sequence itself use sorted function. If you want in opposite order you can give reversed=True parameter: [CODE]>>> a=[4,2,6,0,7,3,9,21,15,12,17,1,0] >>> print sorted(a) [0, 0, 1, 2, 3, 4, 6, 7, 9, 12, 15, 17, 21] >>> print a [4, 2, 6, …

Member Avatar for sabiut
0
194
Member Avatar for Tech B

Here one suggestion [CODE]import random noun = ['school', 'yard', 'house', 'ball', 'shoes', 'shirt', 'fan', 'purse', 'bag', 'pants', 'toaster', 'lamp', 'floor', 'door', 'table', 'bread', 'dresser', 'cup', 'salt', 'pepper', 'plate', 'dog', 'cat', 'wood', 'stool', 'suitcase', 'plane', 'bus', 'car', 'bike', 'phone', 'pillow', 'wall', 'window', 'bed', 'blanket', 'hand', 'head', 'bra', 'eyes', 'sock', 'plastic', 'card …

Member Avatar for snippsat
0
199
Member Avatar for albertkao

By my thinking you are Ok to rename the files and directories can be renamed when the directory walking goes in one higher level go depth first in directories. So you can rename the files and do recursive renaming in subdirectories. Then last you can rename directories themselves.

Member Avatar for griswolf
0
2K
Member Avatar for TrustyTony

This function I did to improve calculator program by eliminating problems with Pythons problem of dividing integer with integer and giving integer division result.

Member Avatar for TrustyTony
0
405
Member Avatar for TrustyTony

I tried this super simple class example from net. (Yes I am a beginner in implementation of object oriented features in Python) UPDATE: Now from fresh start of IDLE it did not crash, but did not quit properly still. Hmm. TaskManager any (or dozen) python zombies hanging around?? No only …

Member Avatar for vegaseat
0
594

The End.