614 Posted Topics
Re: Try noughts and crosses, that a pretty easy one.. Until you try and add an AI :P Try and make your AI as good as possible without making it impossible to win! | |
Re: I thought this might interest people, i got my hands on a pre-release of windows 7 through the DET NSW giving all the students laptops, the students dont have the laptops yet, but the teachers do, so i got to fiddle around on one. Personally i really dont like the … | |
Re: Basically its a fault with IDLE, i get this problem a lot, so what i do is i write my code in IDLE and then i run it through the command line. Because as much as you can try there isnt a way around this. I searched for ages, on … | |
Re: [QUOTE=scru;922364]I for one can say that post count says absolutely nothing either.[/QUOTE] Yep, it just tells you how long they have been here, not how good they are :P | |
Re: You can replace object with other classes, this is called inheritance. For example, we have a class called Shape, We know that: -All shapes have a name so lets write that code [code=python] class Shape(object): def __init__(self,name): self.name = name circle = Shape("circle") [/code] But what if we wanted a … | |
Re: I think you should just make a reset heath function [code=python] while True: print \ """ Welcome to NorbertQuest! Type: - [battle] to hunt monsters - [shop] to buy weapons - [exit] to quit the game. """ mode = raw_input("What do you want to do?: ") if mode == "shop": … | |
I have been using daniweb for about a year and a half now, starting out asking the questions on the Python forum, now i usually answer them. But i really just wanted to say thanks, i feel this is a really strong community and the moderation team does a great … | |
Re: Yeah i rekon it will be a bit of fun, something to play with. I doubt the functionality will surpass windows/linux distros so i think your probably going to only see the die-hard fans of Google doing this. Personally im really not that fussed about google knowing what i do, … | |
Re: Your code has a couple of issues, if i am not wrong it will not actually start using threading with your code as it is. You need to add a couple of lines [code=python] class Thread ( threading . Thread ): def __init__(self): threading.Thread.__init__(self) def run ( Self ): subprocess … | |
Re: Ah the life of a mod sounds like so much fun :P if all you do is delete bad posts! Im sure there is more to it then just that | |
Re: works with me as well... something must be up on him machine. :S | |
Re: Yeah, i dont know if you may have checked this. But i know i stuffed this up one time, but are you sure its .jpeg not .jpg or .JPG or something like that? :P | |
Re: [url]http://lmgtfy.com/?q=the+pros+and+cons+of+python[/url] See? Its really not that hard. | |
Re: Well you can write a tab by using the escape character and t. So if you were writing a tab to a file you would go something like this: [code=python] f = open("File.txt",'w') f.write("\t This will be indented one tab space!") f.close() [/code] So the \t is the escape sequence … | |
![]() | Re: [code=python] def eliminate( grid, square, value ): row = square[ 0 ] col = square[ 1 ] poss = grid[ row ][ col ] if len( poss ) > 1: poss.remove( value ) grid[ row ][ col ] = poss # if len( poss ) == 1: # fixValue( grid, … ![]() |
Re: what i would do is read the whole file into one list, then you can do something like: [code=python] #open it, it is automatically in read mode f = open("dnalookingfile.txt") #get a list with all the lines lines = f.readlines() #iterate through the lines for line in lines: if "rs" … | |
![]() | Re: Yeah i did this just a little while ago myself. Here is the tutorial i used for it: [url]http://kutuma.blogspot.com/2007/08/sending-emails-via-gmail-with-python.html[/url] That will work with gmail :) |
Re: what have you tried already? [url]http://www.daniweb.com/forums/announcement114-2.html[/url] | |
Re: [code=python] self.Bind(wx.EVT_MENU, self.Close(), id=ID_FILE_QUIT) [/code] Theres ya problem! You dont need to put the brackets after self.Close, the brackets are only used if you actually want to call the function, so take out those brackets and try again. That hopefully should fix your dilemma. :) | |
Re: It is used when using formatted strings. I could try explain, but a great book has been written and has a bit about it :) [url]http://diveintopython.org/getting_to_know_python/formatting_strings.html[/url] Read and enjoy the best free book on python imho hope that helps | |
Re: I always use the wxPython api when i want to find something out, its a very very useful skill to be able to do that, because of the lack of documentation you really have to try and use what you do have. I once wrote a small explanation on wxTextCtrl, … | |
Re: Well to start off with, it sounds pretty simple what you are doing, so just read this tutorial. It is a comprehensive way to start with python. [url]http://docs.python.org/tutorial/[/url] Once you finish that you will be able to do everything but printing, that is a rather advanced thing to do with … | |
Re: [code=python] self.Bind(wx.EVT_BUTTON, self.UpdateNebula(), self.Update_Nebula) [/code] This will not work, you are actually calling the fucntion self.UpdateNebula when you put the parentheses there, so if you get rid of them you will be fine :) Another way i do it a lot is just to bind them to the objects themselves: … | |
Re: if you have a list its as simple as calling the sort() method [code=python] li = ['a','h','w','j','s','r','y'] li.sort() print li [/code] | |
Re: Learn python [url]http://docs.python.org/tutorial/[/url] Come back when you can do all that and ask a much more specific question | |
Re: Ha ha ha, i just finished my science assignment on Energy Drinks and their effect on the body. Most energy drinks only have about 80mg/250mL of caffeine. But in Australia there have been about 20 deaths a year occur from people getting all caffeined up and dying. | |
Re: Actually guys i made a programming script that does time travel! :P Its called changing the system clock! And i think that thats the best your going to do for the meantime. | |
![]() | Re: Hahaha, for things like this, i always try and do list comprehensions and get it down to one line, that is not including any of the import statements. I got this [code=python] import random values = 'abcdefghjklmnopqrstuvwxyz!@#$%^&*' print ''.join([random.choice(value) for g in range(8)]) [/code] So what that does is it … |
Re: Yeah i used to go a flash game site but then they got ads that just constantly talked. And it was annoying to turn off my whole sound just to play something. So eventually i just stopped going there. Im pretty against anything i dont like having access to my … | |
Re: Yeah, there is another way [code=python] def exit(self): if self.tries == 0: condition = 'false' print 'GAME OVER-' return False remaining_tries = self.tries return remaining_tries [/code] Then just put this at the end of the Main function [code=python] if output_exit == False: return [/code] That way, when it returns false … | |
Re: [QUOTE=Aestter;863549]oh ok my bad but i still cant get it to work[/QUOTE] Well show us your changed code so we can have a look at it then. ![]() | |
![]() | Re: Just a quick note. The above code will work if you change all of the instances of "sys" to "os" SO it will look like [code=python] import os os.system("shutdown -s") [/code] Hope that helps :) |
Re: I dont know if its just me, but that dosent quite make that much sense. Just spend a little more time outlining exactly what you actually want, what your problem is. What you have already tried. Then we will be much better at helping :) | |
Re: Also, when i import things i get a syntax error if i have brackets in my import. So that might be it, seeing as it looks like its trying to import NumberStimuliGenerator(revised). Personally i would change the file's name to something without brackets. Seeing as in python, they usually mean … | |
Re: Okay, thats simple enough. What you would be looking at is using wx.StaticText for all of your displaying text needs. [url]http://www.wxpython.org/docs/api/wx.StaticText-class.html[/url] This you can update with the SetValue("Value") function. If you ever need user input you can use wx.Button [url]http://www.wxpython.org/docs/api/wx.Button-class.html[/url] Or a wx.TextCtrl, this is basically like an input box. … | |
Re: Showing images is easy with wx.StaticBitmap. [url]http://www.wxpython.org/docs/api/wx.StaticBitmap-class.html[/url] NOTE:This code is borrowed from the sticky [code=python] # show .jpg .png .bmp or .gif image on wx.Panel import wx class ImagePanel(wx.Panel): """ create the panel and put image on it """ def __init__(self, parent, id): # create the panel, this will be … | |
Re: Yeah its not too hard to find the size.. There isnt a function but when you open an image it stores it in the size variable. So [code=python] from PIL import Image f = Image.open("10x.png") print f.size [/code] Hope that helps | |
Re: Then you will probably use something called recursion. That is when a function calls itself. It is used in these kind of situations. [code=python] def recurse(num,count): if count == 10: return else: print num/2 recurse(num/2, count+1) recurse(100.0,1) [/code] See, the recursive function has something called a base case. That is … | |
![]() | Re: So do you want something like this? [code=python] password = open('passwords.txt') #each line in passwords.txt will have another passwords password_list = password.readlines() guess = raw_input("Enter the password: ") if guess in password_list: #print short story else: print "wrong password, program exiting" raw_input() #raw_input is there so the user can see … ![]() |
Re: Well here is some code that will raise that error [code=python] >>> l = None >>> l[0] Traceback (most recent call last): File "<pyshell#7>", line 1, in <module> l[0] TypeError: 'NoneType' object is unsubscriptable >>> [/code] Now what that error means is that you have something of NoneType, literally it … | |
Re: The second one is a simple funciton [code=python] #our list l = ['Hello','world','from','python'] #use the join() function to join the words together with spaces string_list = ' '.join(l) print string_list #prints #Hello world from python [/code] Im pretty sure that changed for python 30. Im not how you do it … | |
I was just wanting to tell you (cscgal) that i was unable to access the site for about 3 hours last night (Australian Time). I kept getting a database error, it asked me to refresh or email you guys. I couldn't get to any part of the site at all, … | |
Re: [QUOTE=dinilkarun;866461]Hi All, I have created a grid and want to implement the following idea: The user should be able to enter only numeric values in any of the cells in that grid. I could not get any property of the cell which can check for the entered data. Please guide … | |
Re: [QUOTE=jlm699;864499]So what are the chances of starting a pyQT or pyGTK thread like the wxPython thread we have... sticky and all! I'd love to see some examples of either pyQT or pyGTK as I've no experience with either... Thoughts?[/QUOTE] Yeah i would like to see that as well. And if … | |
Re: To get the average i usually make a function [code=python] import random def averageList(l): total = 0 for item in l: total += item return total/len(l) #then i make my list l = [random.rangrange(0,100) for f in range(100)] print averageList(l) [/code] Functions are a great way to reuse your code … | |
Re: Okay, start simple and understand what raw_input and input actually do: [quote=http://docs.python.org/library/functions.html] raw_input([prompt])ΒΆ If the prompt argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that. When … | |
Re: Really i think naming your son/daughter something like adolf or the like is more then child abuse. Its stuck with them their whole life (unless they change it) so its kinda whole life abuse, not just child abuse :P | |
Re: Yeah i got a Dell inspron mini 9. One of the netbooks and it runs linux so well. I spent ages getting confused about how to install applications until about a week later i found the add/remove programs item. Woops! But i love its speed and its community. Hope you … |
The End.