3,386 Posted Topics

Member Avatar for linuxoidoz

I do not know other things than that property is one builtin class dealing with decorators.

Member Avatar for jcao219
0
134
Member Avatar for bchin

Here is my going around and finally I got there, but not maybe most elegant way as Python did not allow me to take ord from the individual bytes making utf8 letter. So I ended up manipulating the repr of that letter by string manipulation. [CODE]a=unichr(0x3001) b=a.encode('utf8') print b c=repr(b) …

Member Avatar for bchin
0
3K
Member Avatar for jacob07

You have not clear how to call a function and define one. Here that point corrected version, You are also writing to file fs, which you opened for reading ('r'). [CODE]def filter(li, n): fs = open(li, "r") fd = open(n, "r") while 1: txt = fs.readline() if txt =="": break …

Member Avatar for jcao219
0
220
Member Avatar for ultimatebuster

Maybe better to use os.path.join, works also in not-Windows (or should I say Windows' complement :-) ) [CODE] import sys,os >>> sys.path.append(os.path.join('..','log')) >>> sys.path[-1] '..\\log' >>> [/CODE]

Member Avatar for TrustyTony
0
98
Member Avatar for cyon

I spotted that it has program, but I do not understand the re module enough to tell how to use it. Here is my test for others to check easier. [CODE] import re def FindName(name,list1): """ searches for a pattern in the list, returns the complete list entry. Is case …

Member Avatar for d5e5
0
161
Member Avatar for amadain
Member Avatar for TrustyTony
0
81
Member Avatar for DayneD89

List manipulation is usually done by taking out first or last element in list. As Python lists are not really not list as much as arrays in other languages, just mixed, dynamic type, Python lists can efficiently be accesses through indexing t1=L[0] as you said. If you need to reference …

Member Avatar for vegaseat
0
156
Member Avatar for camigirl4k3

Some problem with your function included down. Strange, the printed message comes only from calling the function from command line, not in loop going over range. [CODE]>>> numtoword('11') sorry that number is not in the list >>> ================================ RESTART ================================ >>> ---------- -1 nine 0 zero 1 one 2 two …

Member Avatar for TrustyTony
0
131
Member Avatar for johnnyd1986

[url]http://www.daniweb.com/forums/thread162126.html[/url] [ICODE]a=round(0.7893948, 3)[/ICODE] if you only want to print it so, you can do [ICODE]print "%.3f" % 0.7893948[/ICODE] You can use this also to prepare result as string [ICODE]s= "%.3f" % 0.7893948[/ICODE] This answers are with 0 not with . only. That you must check separately for example [CODE] >>> …

Member Avatar for snippsat
0
170
Member Avatar for HiHe

Nice piece of work, especially [icode]all(c in '+-.0123456789' for c in num_str)[/icode] if you can trust the correctness of input. Has some problems though: [CODE] >>> Enter a number: 1.234.567 Traceback (most recent call last): File "D:/Tony/input_num.py", line 45, in <module> num = input_num() File "D:/Tony/input_num.py", line 12, in input_num …

Member Avatar for TrustyTony
0
4K
Member Avatar for player1977

Regexp I do not know in python, but here one more time native python scanning with partition [CODE] MyStr = """ <tr> <td><a leave </a></td> </tr> <tr> <td><a remove </a></td> </tr> <tr> <td><a leave </a></td> </tr> <tr> <td><a remove </a></td> </tr> """ before ,found,t = MyStr.partition('<tr>') print before,found, ## leave …

Member Avatar for TrustyTony
0
87
Member Avatar for thepond

Use my piece of code in code snippet [url]http://www.daniweb.com/code/snippet277460.html[/url]

Member Avatar for TrustyTony
0
112
Member Avatar for ultimatebuster

For simple lookup I gave this solution to other thread, of course special modules are maybe more powerful, but take some time to learn. Any way here it again: [CODE]MyStr = "<test>some text here</test> <other> more text </other> <test> even more text</test>" tlist = [] _,found,t = MyStr.partition('<test>') while found: …

Member Avatar for ultimatebuster
0
197
Member Avatar for dbphydb

You said your network is inaccessible from outside your work, if I understood. Is it not better to have cron job in you machine checking for new builds and starting to do the build in your machine say every day when there is on at 5 am in your computer …

Member Avatar for TrustyTony
0
84
Member Avatar for daviddoria

I would do while loop with partition: [CODE] MyStr = "<test>some text here</test> <other> more text </other> <test> even more text</test>" tlist = [] _,found,t = MyStr.partition('<test>') while found: t,found,more = t.partition('</test>') if found: tlist.append(t) ## no assignment, just append else: raise ValueError, "Missing end tag: " + t _,found,t …

Member Avatar for daviddoria
0
15K
Member Avatar for notuserfriendly

I would start with something like this. I would same time produce simulator for the code in the end. L == LOCCTR ?? [CODE]generate=False ## code generation on? ## adr parameter is the first column value, op is the third column (list?) def start(adr,op): global generate generate=True pass def byte(adr,op): …

Member Avatar for woooee
0
509
Member Avatar for Ntsoaki

Interesting alternative to [CODE]>>> filter(lambda x:x>42,seq) != () ## any number in seq is over 42 True >>> filter(lambda x:x<11,seq) != () ## any number in seq is less than 11 False >>> filter(lambda x:x<12,seq) != () ## any number in seq is less than 12 True >>> filter(lambda x:x<12,seq) …

Member Avatar for TrustyTony
0
142
Member Avatar for Ntsoaki

Sorry amount of red, but your code has really many problems. I did take out the tabs also by untabify, width=4. My comments: Strange assignments to for loop variable containing the digits of number, which you are drawing. [CODE]n="2 12345" ## lets work out the example input first n=n.split(' ') …

Member Avatar for TrustyTony
0
298
Member Avatar for JJBallanger

Why not: [CODE] shape=[ ' ', '++++', 'xxxx', 'xxxx', 'xxxx', '----', ' '] r=0.123 print "".join(shape).count('x')*r [/CODE] Plus maybe format and connectivity checking?

Member Avatar for JJBallanger
0
630
Member Avatar for Arfarf

I think that perl expression would not catch the Failed part, even I do not know perl. I have not studied yet the python re -module for regular expressions. I have however used basic string scanning in one function converting date strings. This can be adapted to your use also. …

Member Avatar for Arfarf
0
121
Member Avatar for peppermints

Your code gives this [CODE]Traceback (most recent call last): File "C:/Documents and Settings/Veijalaiset/Omat tiedostot/Lataukset/fly.py", line 2, in <module> from livewires import games, color ImportError: No module named livewires >>> [/CODE] Need this package? [url]http://www.livewires.org.uk/_media/python/livewires-2.1-r2.zip[/url] Generates still after install: [CODE] Traceback (most recent call last): File "C:\Documents and Settings\Veijalaiset\Omat tiedostot\Lataukset\fly.py", line …

Member Avatar for vegaseat
0
1K
Member Avatar for nsutton

I do not recommend working disk file. Usually computers have enough memory to keep full copy in memory.If you need to not read all db in memory, You can use special char as first in line and by pass it in your operations. Also editing can be interpreted as adding …

Member Avatar for nsutton
0
2K
Member Avatar for leegeorg07

Doing 10/3 in 20000 decimals: [CODE] >>> base=10**20000 >>> units,decimals = divmod(10*base/3,base) ##10/3 long number >>> print str(units)+'.'+str(decimals) [/CODE] For square root you must use own function: [CODE]>>> import math >>> x=(2*base,base) >>> math.sqrt(x[0]) Traceback (most recent call last): File "<pyshell#12>", line 1, in <module> math.sqrt(x[0]) OverflowError: long int too …

Member Avatar for vegaseat
0
491
Member Avatar for SgtMe

circle of one unit is x**2+y**2=1 in normal x,y coordinates. computer graphics however have generally graphics pixels which run like text lines from up to down for y. Actually it does not matter for here as -y*-y=y*y Therefore unit circle y = (x**2-1.0)**(1.0/2) , x is between -1 and 1. …

Member Avatar for SgtMe
0
970
Member Avatar for nsutton

Why bother: [CODE] import random deck=[(x,y) for x in '23456789JQKA' for y in ['hearts','diamond','club','spade']] random.shuffle(deck) for i in deck: print i [/CODE]

Member Avatar for Hummdis
0
4K
Member Avatar for cyon

Or [CODE]>>> L = [[x*x for x in item] for item in [ [4,5,6] , [2,4,5]] ] >>> L [[16, 25, 36], [4, 16, 25]] >>> [/CODE]

Member Avatar for TrustyTony
0
180
Member Avatar for the_mia_team

don't use menu. Your assignment talks allways visible menu screen. Think of looking thsi in TV from sofa. Show the menu described and register keys mentioned for functions not mouse operated menu.

Member Avatar for the_mia_team
0
489
Member Avatar for joshua91

[QUOTE=Hummdis;1190066] I'm kind of stickler for syntax and 'pass', 'continue' and 'return' statements since emacs and other CLI editors make note of those for the auto indent features. In any case, given what's here, you should be well on your way. :)[/QUOTE] I am sorry but you lost me with …

Member Avatar for Hummdis
0
158
Member Avatar for rasizzle

[CODE] >>> ["12/1/200"+str(x) for x in range(7,11)] ['12/1/2007', '12/1/2008', '12/1/2009', '12/1/20010'] >>> [/CODE]

Member Avatar for woooee
0
370
Member Avatar for Romber

[QUOTE][CODE] for name in company: generateMainPage(company [/code] [/QUOTE] Something wrong with your code, this call has not all parameters and not closing parenthesis. Please post cleaner version of the code.

Member Avatar for Hummdis
0
640
Member Avatar for daviddoria

Strip removes all those letter which are in the argument out from the string object. Because you are only stripping '//EKTV\\\\a[B]e[/B]lmpsx' the other letters are not stripped. (\ is double, but it does not matter to strip.) [CODE]import os path='VTK/Examples/Test' ## let's use properly the directory separator from os.path pathlist=path.split(os.path.altsep) …

Member Avatar for woooee
0
155
Member Avatar for zzstore

Can you post values of parameters before call and error message and your current solution, don't forget code tags. [CODE] def myfunc(a,b,c,d): print a print b print c print d a=('here','is' ,'some', 'strings') b= " ".join(a) print b ## one list to many parameters myfunc(*a) [/CODE]

Member Avatar for Gribouillis
0
413
Member Avatar for camigirl4k3

Your error does not make sense. It is interactive shell error, not program error. What are you doing, send all data (even the myro module we have not, maybe teachers own module?) And you have not main program in your program, so it does not execute anything.

Member Avatar for jcao219
0
203
Member Avatar for nickles

I have not better alternative that only this interactive loop. Remember to mark thread solved if you think it solved. [CODE]from math import * def riemannFunc(hgLoc, a, b, intervals, func): sums = 0.0 size = float(b - a) / intervals for i in range(0, intervals): x = ((i+ hgLoc) * …

Member Avatar for TrustyTony
0
222
Member Avatar for pythonnewbie10

See how period is used and how it's use can become similar to other values in the formula. Tony

Member Avatar for TrustyTony
0
75
Member Avatar for pythonnewbie10
Member Avatar for tkpanther

[QUOTE=jcao219;1194537]In my opinion, that assignment is a terrible assignment. I would rather use magic methods to make such a set class, i.e. __iter__, __setitem__, __eq__, __add__, __getitem__[/QUOTE] Also I think using dict for such data type as set is like using lists to implement strings. I can be wrong though.

Member Avatar for TrustyTony
0
182
Member Avatar for camigirl4k3
Member Avatar for pythonnewbie10

[QUOTE=pythonnewbie10;1191381]I have this program that i have been working on which plays rock paper scissors game with the user. but i need to modify it to so it contains a "best of x" loop then for it to stop as soon as the user or the COM has won Everytime …

Member Avatar for TrustyTony
0
156
Member Avatar for capson

If you want to sort list were numbers are strings you have two ways to make it work. You can right adjust the filling with blanks (see my post on high score table) or zeros or you can transform them to integers or numbers with desimals, either before putting to …

Member Avatar for TrustyTony
0
123
Member Avatar for octopusgrabbus

First hit from google brought this code [CODE] # ftptest.py - An example application using Python's ftplib module. # Author: Matt Croydon <matt@ooiio.com>, referencing many sources, including: # Pydoc for ftplib: http://web.pydoc.org/2.2/ftplib.html # ftplib module docs: http://www.python.org/doc/current/lib/module-ftplib.html # Python Tutorial: http://www.python.org/doc/current/tut/tut.html # License: GNU GPL. The software is free, don't …

Member Avatar for TrustyTony
0
1K
Member Avatar for toll_booth

The code fails to run because you did not attach the 1.gif file. After creating one very small file from windows minesweeper screen capture. it worked rearly few times, I do not know what happened. Normally it gives this error [QUOTE] Traceback (most recent call last): File "D:\Tony\Tests\minesweeper.py", line 144, …

Member Avatar for TrustyTony
0
268
Member Avatar for joegarside90

graphics module for teaching by Zelle, I guess. [url]http://mcsp.wartburg.edu/zelle/python/python3/ppics2e_code/graphics.py[/url]

Member Avatar for vegaseat
0
414
Member Avatar for mark185

Seems like it is for remote machines connection not inside your own computer. So looks like it is ssh connection program offering secure connection to remote machines. [url]http://www.lag.net/paramiko/[/url]

Member Avatar for TrustyTony
0
51
Member Avatar for smithy40000

This code runs. You overwrote your root and you were missing mainloop in the end. [CODE]from Tkinter import * root = Tk() root.title("Checkers") top = Canvas(root,width="800", height="800") ## !!! Was overwriting the root window ## Creates the black and white square background size = 100 cols = 8 rows = …

Member Avatar for TrustyTony
0
214
Member Avatar for TrustyTony

Ordering objects is one thing that is changing as we will move to Python3 Python 2.6 gives interesting results [CODE]a=[1,'23',('a','b'),False,[[]],[],'bc',['ab','34'],45,'0',{},True] >>> sorted(a) [False, 1, True, 45, {}, [], [[]], ['ab', '34'], '0', '23', 'bc', ('a', 'b')] >>> print True==1 True >>> print False==0 True >>> print False=='' False [/CODE] Python3 …

Member Avatar for vegaseat
0
219
Member Avatar for Kruptein

Checking python docs (urllib2 HOWTO) gave this tutorial link [url]http://www.voidspace.org.uk/python/articles/authentication.shtml[/url] I have not used myself so I can not give direct example.

Member Avatar for TrustyTony
0
78
Member Avatar for goodwin912

I do not know but maybe you could show each picture before you start to process it, I do not know if the slow down is acceptable. I could not test your functions as it gave me error [CODE]>>> Traceback (most recent call last): File "D:\Tony\Tests\watermark.py", line 42, in <module> …

Member Avatar for TrustyTony
0
678
Member Avatar for vskumar19

In windows that webbrowser command openned file I put in argument in my Notepad2, configured text editor. Thanks, I was suffering for same missing as I wanted to have program to generate answers in fast speed and then open them in text editor. That is better solution than letting the …

Member Avatar for hondros
0
11K
Member Avatar for johnnyd1986

User interface suggestion. I did one high score list. I did it without yet saving to file. That is however trivial as info is kept as fixed length strings, no need eval, repr or \t. So one [icode]"\n".join(scores)[/icode] to file is enough. I would suggest this style of interaction with …

Member Avatar for Gribouillis
0
145

The End.