3,386 Posted Topics
Re: I second about looking our discussion on comparing floating point numbers for equality. I got different understanding of the task than vegaseat: I understood that you need to find any x so that sin(x)==cos(a*x) for some a,x Vegaseat wrote code for: not to find sin(y) for y in [0.1,180], where … | |
Re: code-tags, please. > (This is a really long code so im just going to put the traceback part in and where I think the problem is) > > (Can anyone help me) def directions(): enter=0 nwscreen() Font1 = pygame.font.SysFont('ActionIsShaded', 25) d1 = basicFont.render('Directions',False,WHITE,BLACK) d2 = Font1.render('Directions',False,WHITE,BLACK) d3 = Font1.render('ALL ANSWERS … | |
Re: better to replace then line 5 with [CODE] md, inc =line.rsplit(" ",1)[/CODE] To only separate the wanted last number from the end. Then you can do for datalines: [CODE]md='sdfa asdfas fwer\t2334.34234\t\t342.453\t\t34234.3242\t\t42472.234543' sep='\t\t' if sep in md: firstcol, _, rest = md.partition(sep) _, firstcol = firstcol.rsplit('\t',1) secondcol, _ , rest = … | |
Re: What happened with [url]http://www.depython.com/[/url] ? | |
Re: See: [url]http://www.delphibasics.co.uk/RTL.asp?Name=LowerCase[/url] | |
Re: I would use the Track object as type of trackTitles in MainWindow. My opinion, take what it is worth: You are mixing "procedural style of input (not event driven style) with function return values and print", with object style "set the objects variables" style. I hope it is only for … | |
Re: No it should find the first error, if you want multiple error lines printed take out break. You would probably like to implement printing the line number for those lines also with using enumerate: [CODE]from sys import argv as argv openfile = open(argv[0], 'r') for ln,line in enumerate(openfile): if "error" … | |
Re: Seems to work until 20, then does not count dash in numbers like twenty-one, over 99 does not work. Here my test and suggestion if you need number as string using more conventinal base than 36 (16) [CODE]from __future__ import print_function ## let's practice Python 3 printing import sys sys.path.append('D:\test') … | |
Re: Here is document in internet: [url]http://www.pygame.org/docs/ref/font.html#pygame.font.Font[/url] SysFont looks like for system fonts, not for file: [url]http://www.pygame.org/docs/ref/font.html#pygame.font.SysFont[/url] Also SysFont returns font, does not set it, if I understand correctly. In this game it is used with render method of the font returned: [url]http://www.gamedev.net/community/forums/topic.asp?topic_id=444490[/url] [CODE] def __init__(self): pygame.sprite.Sprite.__init__(self) self.font = pygame.font.SysFont("None", 30) … | |
Re: You have timing data? Which operating system? Also lines 6 and 7 are never reached. Use multiline string. | |
Re: You did not get rid of those un-Pythonic getters and setters. | |
Re: I found some links were out of date. This looks promising instead: [url]http://www.microfocus.com/products/micro-focus-developer/extend/ACUCOBOLGT.aspx[/url] | |
Here is my try of changing integers to English written numbers. Here corrected version 3 check: [CODE]from __future__ import print_function import random,sys if sys.version_info[0]==3: raw_input=input to_19 = ["zero", "one","two","three","four","five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" ] tens = ["","","twenty", "thirty", "forty", "fifty", … | |
Re: [QUOTE=Missnat71;1272731]Hello, I have an assignment due tomorrow and getting help by bugging you guys is my last resort... I have tried everything else. I'm extremely new at programming and taking my first course in Pascal Delphi. I'm using Delphi 6 and my assignment consists of using data within a .txt … | |
Re: There is also nice web site called DaniWeb which has lot of nice code snippets. Wellcome to Python forum for example. Also look the final solutions given to some solved threads. It is even could to understand the bugs that others have made and how they can be fixed. Learn … | |
Re: Maybe however you look some of my comments of "security" of XOR encryption. Just encrypt the file with XOR encryption to see what I mean. [url]http://www.daniweb.com/forums/post1253810.html#post1253810[/url] Also at end of thread same page there is attack when you have copy of any original file in your disposal. | |
Re: You could check up this code if it gives you any inspiration how to do ssh in Python. It is from old thread: [URL="http://www.daniweb.com/forums/post623589.html#post623589"]Connecting to a Linux Machine via SSH[/URL] but has no code tags so here it is with those: [CODE]# Login to ABC Machine via SSH child = … | |
Re: It is good to lower the user input, however the last solution does not exit the loop in case of y answer. My running code (normal print, imports, accepts yeah and nope): [CODE]import os print(''' WIP will create Backup, Resized and Watermarked folders to store the original, resized and watermarked … | |
Re: Start with: [CODE]year= input("Enter the year you want to add up the total revenue: ") sum=0.0 [/CODE] Then loop over all lines which start with right year, change the amount part to float and add to sum. You can use normal split() instead of csv in this simple case, if … | |
Re: Also you can do: [CODE] help() ### you get help prompt you input: modules[/CODE] You get quite list of modules available in your Python installation. Luckily x is at the end and you find the modules last column in the end if you installed them well. | |
Re: See the code in the XOR encryption thread. My fastest solution does this to password. | |
Re: [QUOTE=Beat_Slayer;1272557]I'm sorry if you take it personnaly vegaseat, I really didn't mean it. I just see lost of my posts harshly commented, and decided to let it out, only that. Congrats[/QUOTE] I know I posted 'against' your MasterMind solution but that was because it was buggy. If your solution works … | |
Re: First answer is not to reinvent the wheel: use os.makedirs(): [CODE]>>> import os >>> os.chdir('d:\\tony') >>> os.makedirs(os.path.join('create','all','these','dirs')) >>> os.system('ls -R create && pause') [/CODE] [CODE]create: all create/all: these create/all/these: dirs create/all/these/dirs: [/CODE] If you want to implement it as practise, use normal pathname, split it from the path separators to … | |
Re: On second run of program I get error: [CODE]Traceback (most recent call last): File "D:\test\stamper.py", line 9, in <module> os.mkdir ( 'Backup' ) WindowsError: [Error 183] Tiedostoa ei voi luoda. Tiedosto on jo olemassa: 'Backup'[/CODE] Second error I got after choosing one of my jpg files for stamp: [CODE]raceback (most … | |
Re: Are these two files in exactly same directory or different subdirectories? Have you tried to put the library to site-packages directory. Is there setup.py file and have you read any included readme or instalk files? | |
Re: languagelist = open('languages/country.lang').read().split() gets you words of file language as which you access by index 0 for first until length of list-1. So for example languagelist[2] would be third one spain. | |
Re: Ability to click a button to download code tagged part from message. Some newbie messages to help posting right place, mark threads with lapse in activity solved, dealing with outdated code snippets, ui for small screens.. | |
As I was student, the bracketed plurals were absolute 'NO, NO'. With this simple function you can cleanly avoid putting bracket plural(s) after your numbers. If the number deciding singular/plural should not be automatically included, you can make version with [icode]str(n)+' '+[/icode] eliminated. If you want to put automatically space … | |
Re: For simple idea how to deal with singular plural after you have them by program or by literals see my snippet: [URL="http://www.daniweb.com/code/snippet277468.html"]Kbyte(s) eliminator[/URL] | |
Re: I started to play little with Python and think and my thinking is this: In array of n elements there exist one node which has None (say -1) as next, if all nodes are visited therefore all next fields have different value which is in range(len(array)) Therefore my algorithm Python … | |
Re: And one not about long ago adding error checking to binary GCD algorithm in ARM assembler: one interesting feature of 2's complement is that there is that smallest negative number, whose ABSolute value is not in the INTegers. So it is actually possible to have overflow error of taking ABS … | |
Re: If I understand you find out the insertion points line_numberin line 87, but never use it for anything: [CODE]line_number = len( self.control.GetRange( 0, self.control.GetInsertionPoint() ).split("\n") ) print line_number [/CODE] I added print and it printed 1 to console. | |
Re: Something like: [CODE]open("file.txt","w").write(b[texto:])[/CODE] | |
Re: Only by putting whole while inside other loop, for example another while, I think. Maybe you would like to show some of your code, where you have problem and tell what is the purpose of this code. Remember to push code-tags before pasting. | |
Re: Did you check my code which did the job? [url]http://www.daniweb.com/forums/post1270109.html#post1270109[/url] Could you express in words or flow chart the logic of program and find anything missing. HINT: How are you counting the number of different values and sum of the values for every key separately from each other? | |
Re: You are trying to use string as file. If that is your purpose use the cStringIO module. | |
Re: With list as I posted earlier: [CODE]def test(n_input): for x in range(2**n_input): f=str(bin(x))[2:].zfill(n_input) # x is type int, f is type str print list(f) test(3)[/CODE] | |
For our long discussion: [url]http://www.daniweb.com/code/snippet216632.html[/url] Both jumping to first unread and going to last message by poster's name does not work. Also jumping to specific post does not work: [url]http://www.daniweb.com/forums/post1253810.html#post1253810[/url] | |
I have couple of posts which seems to get positive feedback from the helped member, but the reputation is even, not positive. Somebody immediately down voting the rep given to me or what is happening? Here two still visible cases: This has only 1 rep: [url]http://www.daniweb.com/forums/post1270304.html#post1270304[/url] This has reputation comments … | |
Re: You should use datetime module, I think. Maybe this can help you: [URL="http://www.daniweb.com/forums/post1249093.html#post1249093"]Re: Managing Date and Time change in text adventure[/URL] | |
Re: strip out == do not write back again, when you write changed file with old name (maybe destroying the content in case of program bug) or new name with [iCODE]open('myoutfile.txt','w').write(my_changed_text)[/iCODE] | |
Re: You could compare your solution with my code snippet: [URL="http://www.daniweb.com/code/snippet282009.html"]Watch for change of files in directories[/URL] | |
Re: Code which is not tested to function Ok belongs to discussion thread. Just that you know next time. | |
Re: Except if the word is word. , "word or Word. I mean that punctuation or case can be problem if input is unprepared text and you want to count the words. That is not case here but I want to remind not to oversimplify. Remember Python-do axiom 'strong testing instead … | |
Re: I ran the code without error with your input, but output : [CODE]{}[/CODE] | |
Re: What have you tried until now? itertools.permutations could be handy. | |
Re: griswolf put few bugs there for you to debug. Hint how quotes are used in Python? | |
Re: Maybe append mode 'a' would be more appropriate than starting with empty file? Generally easier approach would be to read in all passwords, create new file in except clause if it is first user. Put used usernames in set and check from that if user name is available. After succesfull … | |
Re: I played with your code, but did not know what exactly you want to accomplish: [CODE]import wx class Example(wx.Frame): def __init__(self,parent,id): wx.Frame.__init__(self,parent,id,'Example', size=(312,170)) self.panel=wx.Panel(self) ntext=wx.StaticText(self.panel, -1, "Name: ", pos=(3,6)) self.name=wx.TextCtrl(self.panel, -1, "Your name", size=(220, -1), pos=(60,2)) self.name.SetInsertionPoint(0) Namo=wx.Button(self.panel, -1, "Namo", pos=(150,50), size=(60,30)) self.Bind(wx.EVT_BUTTON, self.GetName, Namo) Quit=wx.Button(self.panel, -1, "Quit", pos=(50,50), size=(60,30)) … | |
Re: I do not know it is done in QT, but in button handling method disable the button and start QT timer, which has handling function that enables the button again. |
The End.