3,386 Posted Topics

Member Avatar for kpxny2sk

6th item of the list is item number 5, so you must reduce factorA to accomodate this 0-based indexing. __init__ should have same indentation as other def's, probably cut-and-paste error. [CODE] def __init__(self, indata): self.data = indata self.total = len(self.data) def getTtestFactorA(self, factorA): ListFactorA = [] for factorA in self.data: …

Member Avatar for richieking
0
196
Member Avatar for Blackberryy

I do not know what you want to accomplish, but this code does at least something: [CODE]from graphics import * def main(): x = 0 y = 0 while not(3<=x<=9): x = int(raw_input("Enter The Width Of Your Patch: ")) while not(3<=y<=9): y = int(raw_input("Enter The Height Of Your Patch: ")) …

Member Avatar for Blackberryy
0
121
Member Avatar for Xeex
Member Avatar for efregoso
Member Avatar for TrustyTony
0
152
Member Avatar for Simplified

Make sure you understand [B]import this[/B] The philosophy of Python reminder for your contemplation [B]Duck typing[/B] Invest time for testing and designing use cases instead of catching mistakes of users before hand, instead: [B]“it's easier to ask forgiveness than permission” [/B]try..except..else is your thing not hasattr (except from basestring type …

Member Avatar for Simplified
0
107
Member Avatar for kaykay07
Member Avatar for joejoe92

You are not getting to out the lines that are after the tagged lines. Add to line the next one stripping the new line: [CODE]input1 = open("in.txt") output1 = open("outp.txt","w") with input1 as f: out = ''.join('%s %s' % (line.rstrip(),next(f)) for line in f if line.startswith(('a)','b)','c)','d)'))) # startswith works with …

Member Avatar for joejoe92
0
136
Member Avatar for xcstormerlife

def guessing(self): tite = self.character_ent.get() tite = tite.lower() if tite in self.getName(): newer = "" for i in range(len(self.getName())): if tite == self.getName(): newer += tite else: newer += self.so_far[i] newer.replace(i,tite) self.so_far = newer self.movie_name_txt.delete(0.0,END) self.movie_name_txt.insert(0.0, self.so_far) Push (code) button for correct tags. This is completely ununderstandable anyway, need real …

Member Avatar for TrustyTony
-1
96
Member Avatar for kk12345
Member Avatar for Peter_TARAS

I am not any special re optimizer, but wouldn't one use something similar to this? [CODE]import re myteststr='x = 78.36734693877551, z = 11.428571428571429 -> amplitude: 8.62847057093655E-6 | phase -1.5707968246742405\n' rs=re.compile('(-*\d+.\d+E*-*\d*)') print map(float, rs.findall(myteststr)) [/CODE]

Member Avatar for Gribouillis
0
179
Member Avatar for Zohaq

Maybe you could find any inspiration from my boggle code: [URL="http://www.daniweb.com/code/snippet299470.html"]Yet another boggle word game [/URL] For enterless input see: [url]http://snippets.dzone.com/posts/show/915[/url]

Member Avatar for woooee
0
177
Member Avatar for coco08

What is purpose of 20 and 21 and why function at 44-47 after main code? And if by miracle the while would be entered which miracle would give value for [B]used[/B] ;)

Member Avatar for dekalbxxx
0
556
Member Avatar for furret

Something like this situation? [CODE]try: from pretty import ppr as pprint # my pretty printer, see snippet archive except: from pprint import pprint # standard fallback def outten(a): for i in range(1, 1+10): yield float(a) / i def outone(x): yield x / 2.0 values = (1, 2, 3, 4, 21, …

Member Avatar for Gribouillis
0
137
Member Avatar for newbieha

You are not calling that function, how do you know it does not work? Looks like you have linked low level data structure. Can you tell if all code is yours and if not what you have added and how have you tested it?

Member Avatar for TrustyTony
-1
114
Member Avatar for rx21825

Here is my start also, but it sorts the lines by alphabetic order input files are supposed to start with same letters (here 'file0') and end with '.txt'. [CODE]import os import itertools ids = [] lines = [] for fn in (f for f in os.listdir(os.curdir) if f.startswith('file0') and f.endswith('.txt')): …

Member Avatar for TrustyTony
0
2K
Member Avatar for keltik

Reconsider about dynamic typing, read this for fun: [url]http://en.wikipedia.org/wiki/Duck_typing[/url] Otherwise maybe you should start coding in Ada, where you can really 'enjoy' strong typing.:icon_twisted: Also this thread should then be 'typed' as solved thread, so can you mark it so :)

Member Avatar for TrustyTony
0
153
Member Avatar for dmurder

Simpler to write instead of lines 6 and 7[CODE]totalScores += number * score [/CODE] What you are trying to do?

Member Avatar for richieking
0
150
Member Avatar for novice20
Member Avatar for Swedenrock

Example of input (instance of the class) and expected output would help. I get error: [CODE]Traceback (most recent call last): File "J:/Python26/kort.py", line 13, in <module> kort = Kortlek() File "J:/Python26/kort.py", line 10, in __init__ tmp= Kort(color, form, number, grade) NameError: global name 'Kort' is not defined >>> [/CODE]

Member Avatar for TrustyTony
0
121
Member Avatar for dmurder
Re: help

Would be maybe cleaner not to use function names min and max, even it is this local scope as keyword parameters. Matter of style only, has points of easy to remember keyword name. Here little modified version: [CODE]def get_user_value(start=None, end=None, message=None, converter=float): if (start is not None) and (end is …

Member Avatar for TrustyTony
0
88
Member Avatar for 1989sam

[CODE]products = ["YELLOW,SMALL,STRETCH,ADULT,T21fdsfdsfs", "YELLOW,SMALL,STRETCH,ADULT,Tdsfs", "YELLOW,SMALL,STRETCH,ADULT,TD"] products = [this.rsplit(',',1)[0] for this in products ] print products [/CODE]

Member Avatar for seanbp
0
107
Member Avatar for xtra333

This is how I would do, maybe you can use it to debug your solution: [CODE]def list_str(lst, per_line): # given a list of items, # return per_line items per line. start = '[' while len(lst) > per_line: start += str(lst[:per_line])[1:-1]+',' yield start start ='' lst =lst[per_line:] yield start + str(lst[:per_line])[1:-1]+']' …

Member Avatar for richieking
0
149
Member Avatar for Gribouillis

On the other hand useful fact is also to remember that [QUOTE] >>> print(Fraction.from_float(pi).limit_denominator(10000)) 355/113 >>> 355/113.0 3.1415929203539825 >>> 355/113.0-pi 2.667641894049666e-07 >>> [/QUOTE]

Member Avatar for Gribouillis
1
1K
Member Avatar for fyodord

And the connection with Python language? [url]http://filext.com/file-extension/T[/url] [url]http://www.freedownloadscenter.com/Business/Document_Management_Tools/Paradox_viewer.html[/url]

Member Avatar for fyodord
0
134
Member Avatar for hbluthi

You are giving suit as Jordan and you are not using the return value from validSuit (which you should name valid_suit).

Member Avatar for hbluthi
0
660
Member Avatar for Oldguy1
Member Avatar for robm612

I can not see that you changed the function, you are putting value to first fitting slot from beginning, not say find combinations closest to container size. To inputs look ugly, you can use [iCODE]while itemweight:[/iCODE] and read the values to list from input inside the while. Put some print …

Member Avatar for TrustyTony
0
147
Member Avatar for jozz3

In python there is not main program, but the code in highest indention level is executed when code is loaded. To stop modules main code to run you can put [ICODE]if __name__ == 'main':[/ICODE] in beginning of that code. For object oriented program main program would generally be used to …

Member Avatar for taskkiller
0
124
Member Avatar for polanski

test.txt is not good variable name you should probably have 'test.txt', loriginal will contain fist line of file, line is not defined, split is splitting (you should use rstrip), newline is by the way '\n'... Your code is junk. Start over, if you need to cheat, check my answer in …

Member Avatar for richieking
0
161
Member Avatar for convoluted
Member Avatar for Naynah
Member Avatar for longlongsilver
Member Avatar for richieking
0
309
Member Avatar for HoneyBadger

[CODE]from itertools import islice f = open('11.txt') # alice in wonderland guttenberg print ''.join(islice(f, 100, 110)) """Output: Presently she began again. 'I wonder if I shall fall right THROUGH the earth! How funny it'll seem to come out among the people that walk with their heads downward! The Antipathies, I …

Member Avatar for TrustyTony
0
110
Member Avatar for testie

[CODE]with open(filenm) as infile: lines = tuple(line.rstrip() for line in infile) with open(filenm,'w') as outfile: outfile.write('\n'.join(lines)) [/CODE]

Member Avatar for richieking
0
106
Member Avatar for Thropian

Here is my menu system, maybe you could adapt it? [CODE]from Tkinter import * import Tkinter as tk def create_header(t,top): ## Creates the Headings frame1 = Frame(top, relief=GROOVE, borderwidth=2) label1 = Label(frame1, text=t, font=('Arial', sqsize/2), fg="red") label1.pack() top.create_window(middle, sqsize, window=frame1, anchor=N) top.pack(fill='both', expand='yes') def create_buttons(t,place,c, top): ## Creates the Buttons …

Member Avatar for Thropian
0
202
Member Avatar for Binika

Playing little with [URL="http://www.daniweb.com/code/snippet316585.html"]my code snippet[/URL] could give some ideas how to proceed (but you need not open the files like I did to find the text in them)

Member Avatar for TrustyTony
0
217
Member Avatar for evertron

Your design is ununderstandable, but I did something to get it print the content of given filename as it's str or ask user the filename as input: [CODE] # Lexicon Class read and write a file """This is the Lexicon Class""" class Lexicon: def __init__(self, filename=None): self.file = None while …

Member Avatar for evertron
0
235
Member Avatar for tk-421

You could write down some amounts from your head and the amount of change the program should suggest to return. (One your shopping receipts plus some imaginary payments for each amount in it, for example) Put those as test function unittest and run that with your function for change to …

Member Avatar for TrustyTony
0
13K
Member Avatar for Thropian
Member Avatar for sandesh56
Member Avatar for yellowkaiq

endswith accepts tuple argument. What happens if there is y inside word ending with 'y'? Why you do not use slicing and join method?

Member Avatar for yellowkaiq
0
187
Member Avatar for michaeljfox
Member Avatar for Harris00

It is more accurant to say: 'I have found tonyjv's post with this code for consentric circles in Daniweb'. Somebody could think that you wrote those lines yourselves. Also it is considered necessary to show some own effort. And use the (CODE) button before pasting, putting a link to the …

Member Avatar for richieking
0
1K
Member Avatar for bretthay93

global scope lines are top-level lines outside the functions without indentation like line 6 in your code.

Member Avatar for WildBamaBoy
0
149
Member Avatar for longlongsilver
Re: help

You have still things left to fix Wildbamaboy only gave you start. One thing I for example do not understand is your docstring. Make some test cases for your code.

Member Avatar for TrustyTony
0
218
Member Avatar for danholding

I would suggest to change the file name repr to something else as it is one basic Python function and using it as variable is confusing.

Member Avatar for TrustyTony
0
240
Member Avatar for imanewbie015
Member Avatar for richieking
0
177
Member Avatar for jrp370

Here is advanced version, try to understand the logic and do regular loop of it if generator is too unfamiliar: [CODE]my_list=[1,2,3,4,5] print my_list.index(3) print next(index for index, value in enumerate(my_list) if value==3) [/CODE]

Member Avatar for TrustyTony
0
108
Member Avatar for cwarn23

Your formula in text gives me strange maximum: negative value. Brute force is very fast, I do not know why you need to optimize. If I only know that the number is maximum same bit length as maximum of b and c, which is known. [CODE]from __future__ import print_function import …

Member Avatar for TrustyTony
0
219
Member Avatar for c_shaft05
Member Avatar for Duskic
0
434

The End.