3,386 Posted Topics
Re: [CODE]>>> list(eval('(239..247),(467..765)'.replace('..', ','))) [(239, 247), (467, 765)] [/CODE] | |
Re: what is this line with parent class of the Store class? [CODE]if Phone not in self.phones: self.phones.append(Phone)[/CODE] | |
Re: put only lowercase to dictiomaries and access normally with [] What is char? Why time? How are you splitting morse words/characters? | |
Re: Your indention is completely off. | |
Re: 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 … | |
Re: 2 ^ 3 ^ 4 becomes 2 3 4 ^ ^ because of right to left associativity of exponentiation. | |
Re: And the same command from xterm in the script directory works? | |
Re: Daniweb sticky threads plus lot of practice of using. From online books Dive into Python seems to be of high quality. | |
Re: You have at least unbalanced () at line 59. | |
Re: 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. | |
Re: 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 … | |
Re: Maybe you like to check [url]http://www.csis.ul.ie/cobol/examples/default.htm[/url] | |
Re: 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 … | |
Re: 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 … | |
Re: Does not make any sense for me, importing modules never used, defining variable immediately overwritten (line 32 and 33) loop of one iteration... | |
Re: [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? | |
Re: [CODE]print(sum(obs1.getResponse(cont) == 'yes' for cont in numpy.linspace(0.0, 1.0, 10)))[/CODE] | |
Re: First solve base case of empty list and find minimum if you would know minimum of list except first one. | |
Re: There is several ways to write multiple lines to file, for example you can start with | |
Re: @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 … | |
Re: 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), " ") … | |
Re: @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 [ … | |
Re: 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 … | |
Re: 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 … | |
Re: That is not list of elements any type I know. | |
Re: That is not recursive function | |
Re: 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 … | |
Re: 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. | |
Re: You are running the program from command line or double click the file, don't you? | |
Re: You need to make loop again for output. | |
Re: if you are using Python2, you should use floating point in division:[CODE]+1./n[/CODE](do not use formated text in code block!) | |
Re: Give the code you are using and let's check it up. Are you using random.choice? | |
Re: 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. | |
Re: 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 … | |
Re: 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") … | |
Re: 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) | |
Re: [url]http://www.daniweb.com/software-development/python/threads/397328[/url] | |
Re: 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 … | |
Re: 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 … | |
Re: [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 … | |
Re: Why completely different return statement? You should push CODE before pasting code, if you like others to read your code and understand it. | |
Re: 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] | |
Re: 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. | |
Re: 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 … | |
Re: We wait to see your efforts (inside CODE tags) and point you to right direction. | |
Re: 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) … | |
Re: 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). | |
Re: 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] | |
Re: Maybe [url]http://liogo.sourceforge.net/[/url] could do, even it seems to be abandoned. |
The End.