3,386 Posted Topics

Member Avatar for Petee.bill

[CODE]>>> list(eval('(239..247),(467..765)'.replace('..', ','))) [(239, 247), (467, 765)] [/CODE]

Member Avatar for TrustyTony
0
128
Member Avatar for Sprewell184

what is this line with parent class of the Store class? [CODE]if Phone not in self.phones: self.phones.append(Phone)[/CODE]

Member Avatar for TrustyTony
0
132
Member Avatar for cocobun31

put only lowercase to dictiomaries and access normally with [] What is char? Why time? How are you splitting morse words/characters?

Member Avatar for TrustyTony
0
457
Member Avatar for monica23
Member Avatar for Lukester3

That is at least from my side quite intentional, as I want to pass Pythonic (and often pyTonyc) ways, as purpose is understanding the language and getting most of it. As we do not like to give direct solutions, at least I try to give in some sense better solution …

Member Avatar for Ezzaral
0
196
Member Avatar for eagles39

2 ^ 3 ^ 4 becomes 2 3 4 ^ ^ because of right to left associativity of exponentiation.

Member Avatar for TrustyTony
0
160
Member Avatar for hencre
Member Avatar for chet6

Daniweb sticky threads plus lot of practice of using. From online books Dive into Python seems to be of high quality.

Member Avatar for Ismatus3
0
160
Member Avatar for ThemattyC
Member Avatar for Luis Ventura

Sounds good project, good luck. If you get stuck, you can post your effort, and regulars can help you point out where to look for solution. When posting, notice that pushing the (CODE) gets you tags to post code nicely with indention by pasting between them.

Member Avatar for Luis Ventura
0
544
Member Avatar for sofia85

It depends what you want the file. Generally the way to work with large file is split and merge or you maybe do not need split if you work with generator expressions not loading all data in memory at once. So could you specify the processing you are doing to …

Member Avatar for sofia85
0
148
Member Avatar for jemz

Maybe you like to check [url]http://www.csis.ul.ie/cobol/examples/default.htm[/url]

Member Avatar for TrustyTony
0
132
Member Avatar for techguy2012

Use print statements to track what happens [CODE]def main(): input= 'the money is in the bag. however you dont want it.' words = input.split('.') capitalized_words = [] for word in words: word=word.strip() print(words[0]) title_case_word = words[0].upper() capitalized_words.append(title_case_word) print(capitalized_words) output = '.'.join(capitalized_words) print(output) main() [/CODE] Output: [CODE]the money is in the …

Member Avatar for TrustyTony
0
281
Member Avatar for Catchamouse

Normally raw_input (Python 2) or input (Python 3) is enough. If you want to get fancy and have anyway in your module library my[URL="http://www.daniweb.com/software-development/python/code/360113"] Tkinter getkey[/URL], you can utilize it also (for me input has been enough) You may want to make simple base class for it though as the …

Member Avatar for Catchamouse
0
5K
Member Avatar for jacob501

Does not make any sense for me, importing modules never used, defining variable immediately overwritten (line 32 and 33) loop of one iteration...

Member Avatar for jacob501
0
4K
Member Avatar for Tcll

[QUOTE=Tcll;1301167]overlooked this last time... you mean: h *= (1/256)[/QUOTE] [ICODE]h = 0[/ICODE] would be more concise in Python 2. Or do you mean [iCODE]h /= 256.0[/iCODE] ? Or are you making something, which should use divmod?

Member Avatar for Tcll
0
2K
Member Avatar for MazzGonzo

[CODE]print(sum(obs1.getResponse(cont) == 'yes' for cont in numpy.linspace(0.0, 1.0, 10)))[/CODE]

Member Avatar for TrustyTony
0
118
Member Avatar for eceisl

First solve base case of empty list and find minimum if you would know minimum of list except first one.

Member Avatar for TrustyTony
0
108
Member Avatar for Lemony Lime
Member Avatar for gorbulas
0
226
Member Avatar for vegaseat

@niff Sorry but I can not understand what you are talking about: [CODE]>>> from collections import namedtuple >>> Storage = namedtuple('Storage', 'db, schemas, tables, columns, funs') >>> root = Storage(db='myDb', schemas=[], tables=[], columns=[], funs=[]) >>> print root Storage(db='myDb', schemas=[], tables=[], columns=[], funs=[]) >>> print root.db myDb >>> print root[0] myDb …

Member Avatar for Gribouillis
0
4K
Member Avatar for rollingapes

import sys import random as r from graphics import * from Button import * class ThreeDoor: def __init__ (self): self._createWindow() self.stayWin = 0 def _createWindow(self): self.win = GraphWin("ThreeDoor", 800, 800) self.playerWtext = Text(Point(500, 500), " ") self.playerWtext.draw(self.win) self.playerLtext = Text(Point(500, 600), " ") self.playerLtext.draw(self.win) self.playerStext = Text(Point(500, 700), " ") …

Member Avatar for rollingapes
0
185
Member Avatar for carmstr4

@bawakrbs: your checking is quite nice, but it shows two 'a' in wrong place if word is 'passi' and guess is 'allas' and not s in wrong place for 'saisi'. Of course your printing should be without newlines (, in Python2, end='' in Python3) [CODE]p a s s i [ …

Member Avatar for TrustyTony
0
187
Member Avatar for python123456

You do not need createList, use Python naming convention: lower case with _ connected words for variables, UpperCasedWords for classes. check about divmod function and pass integer number in your function. Forget float numbers at least first for simplicity: [CODE]def get_number(prompt): while True: try: number = int(raw_input(prompt)) except ValueError as …

Member Avatar for TrustyTony
0
2K
Member Avatar for pointers10

You should have for loop over the file's lines instead of single if, alternating between product and price. You could also read all lines in one go and do every second slice [::2] to separate the products and prices. The lower method of strings could be also usefull to fix …

Member Avatar for woooee
0
86
Member Avatar for sofia85
Member Avatar for junoh1991
Member Avatar for asong
Member Avatar for next_tech

Your code is not robbust, what if user inputted letter like 'lO'. For Gui, I think you only need to do initialization and replace the get_ functions with binding to input events. As for Python3 vs Pyhon2, I thin 0ython3 implementation much better as it uses new style classes. The …

Member Avatar for TrustyTony
0
712
Member Avatar for peterson624

gif is one of the few supported image types supported by tkinter. So you do not need to code yourself for that or use third party modules.

Member Avatar for peterson624
0
215
Member Avatar for kalookakoo
Member Avatar for TrustyTony
0
196
Member Avatar for pelin
Member Avatar for Suzan Al-amassy

if you are using Python2, you should use floating point in division:[CODE]+1./n[/CODE](do not use formated text in code block!)

Member Avatar for TrustyTony
0
156
Member Avatar for darkwarrior86

Give the code you are using and let's check it up. Are you using random.choice?

Member Avatar for TrustyTony
0
58
Member Avatar for mattgwilson

Character must be in quotes to make string (in Python characters are just short strings) [CODE] if '⌂' in extractb #if the EOL character is in the string [/CODE] Better even to use the hex value of the ascii with \x prefix.

Member Avatar for TrustyTony
0
351
Member Avatar for AdampskiB

replace [CODE]if width & height > 8 and width & height < 2:[/CODE] with [CODE]if 8 < width < 2 and 8 < height < 2:[/CODE] But do not expect it to become True before hell freezes over ;) Do you want to say: [CODE]if 2 < width < 8 …

Member Avatar for woooee
0
156
Member Avatar for Kitson

Concratulations, clean up of code is one thing we are glad to advice. unfortunately I can not test this now but here is edit, which mayby need some corrections. [CODE]# Extracts data from a files and saves it in a summary file data_lines = [] start = float('inf') with open("file1.txt") …

Member Avatar for TrustyTony
0
174
Member Avatar for mattgwilson

Do [CODE]print('\n'.join(passed for passed in chunk.split('£') if 'PASSED' in passed))[/CODE] (text is assumed to be in variable chunk, hope not passed lines have FAILED not NOT PASSED)

Member Avatar for mattgwilson
0
157
Member Avatar for carmstr4
Member Avatar for carmstr4
0
2K
Member Avatar for pelin

Next time do some effort to debug basic things that interpreter complains about. Here quick clean up: [CODE]from random import randint class StandardCards: def __init__(self,c,n): self.color = c self.number = n def __str__(self): return self.color + " " + str(self.number) __repr__ = __str__ class WildCard: def __init__(self): self.is_draw_4 = False …

Member Avatar for pelin
0
6K
Member Avatar for bigredaltoid

Maybe simplest to beginner to use normal loop with modulo 6 based append of parts. Last one must be added after loop. [CODE]>>> data = '''Joe Body 10429114 IT 30 90 Sue Noone 12345678 ENG 45 103''' >>>> students = [] >>> for count, item in enumerate(data.splitlines()): if not count …

Member Avatar for bigredaltoid
0
158
Member Avatar for Stefano Mtangoo

[CODE] "copyright", "credits" or "license()" for more information. >>> data = """2 $5$233$ check big cat if it have not eaten all the meat 3 $5$233$ check big cat if it have not eaten all the meat <a href=""http://example.com"">An Example duh! </a> <a href=""http://example.com"">An Example duh! </a> 2 $5$233$ check …

Member Avatar for Stefano Mtangoo
0
215
Member Avatar for mkbear

Why completely different return statement? You should push CODE before pasting code, if you like others to read your code and understand it.

Member Avatar for inuasha
0
222
Member Avatar for arindam31

I put (after removing the module for email check I do not have and putting constant value at line 84) [CODE] def Process(self, event): mail1 = self.txt_Username.GetValue() pwd1 = self.txt_Password.GetValue() self.Mail(event,mail1,pwd1) if self.cb_Timer.GetValue(): self.timer.Start(1000) def OnTimer(self,event): print"So we are inside" if not self.cb_Timer.GetValue(): self.timer.Stop() [/CODE]

Member Avatar for arindam31
0
283
Member Avatar for Ice_Occultism

Names starting with single underscore are for modules internal use and should not be imported. You are also talking about functions, but names starting with capital letter should belong to class, not function, by PEP8 style guide.

Member Avatar for Ice_Occultism
0
143
Member Avatar for vaucro

I think set intersection is insufficient to give hints properly for misplaced letters. You should also know what you want to say if user inputs one letter in wrong place and there is such letter in two other places. List representation is not needed but we can use string directly …

Member Avatar for vaucro
0
697
Member Avatar for tjy92
Member Avatar for TrustyTony
0
3K
Member Avatar for Accendo

My take: [CODE]# pyTonyc version from pprint import pprint import string def az_ord(): return range(ord('A'), ord('Z')+1) codes = dict(('%c%c%c' % (a,b,c), (a<<16) + (b<<8) + c) for a in az_ord() for b in az_ord() for c in az_ord()) # make only once the two letter pairs codes.update(dict(('%c%c' % (a,b), ((a<<8) …

Member Avatar for TrustyTony
0
251
Member Avatar for hovestar

I do not see the connection of you algorithm with being prime, could you write the algorithm you are implementing in pseudo code and mathematical formulas? You are also importing sqrt but not using it (like normally used in primality test).

Member Avatar for TrustyTony
0
168
Member Avatar for mkmk123

I have no idea what you are talking about. [CODE]>>> list_of_things = ['kittens', 'mittens', 'flowers'] >>> list_of_things.append('strawberies') >>> list_of_things ['kittens', 'mittens', 'flowers', 'strawberies'] >>> [/CODE]

Member Avatar for mkmk123
0
274
Member Avatar for TechSupportGeek
Member Avatar for Rashakil Fol
0
127

The End.