614 Posted Topics
Re: I think i solved this problem once by just going [icode]str(stringvar)[/icode]. Im not quite sure if it definitley works.. it might have been something else. | |
Re: We need more infomation, are you making a webpage using python? What is it you really need solved, where are you redirecting from. If you take a minute or two more writing down your problem people will find it a lot easier to answer any questions that arise. | |
Re: A statement in python is something that is already set as what is does, if is a statement, break is another, print is a statement. An expression is something that evaluates to something. Such as adding numbers or strings together evaluates to something. | |
Re: Well what i would do is make a hell of a lot of buttons.. well only 32, then i would use a loop to make a list of all of them something like: [code=python] for f in range(64): buttons.append(wx.Button(self, wx.ID_ANY, label = str(f))) [/code] That takes care of making the … | |
Re: I rekon you could do something simillar in python, of course it would take a lot of time and care but to do such a thing you need a GUI as you said and there are really only 3 main ones used (4 if you count qt). That is Tkinter … | |
Well this is probably a really stupid question but i was doing pygame tutorial and i dont know what a vector is and they keep talking about them, there were special vector classes and things like that, im rather confused, so if someone could teach me what a vector is … | |
Re: Whats wrong, are you getting errors? Or do you just want to make it look cleaner? Oh and for the spaces, try using something like print ' '*whatever number, print 'Craps' | |
Re: Try this: All i did was put a random number at the start of main and when they guess the correct number [code=python] import random def main(): answer = 'y' number = random.randint(1, 1000) while answer == 'y' or answer == 'Y': print 'I have a number between 1 and … | |
Re: This code will let you open ALL files that start with pcp and then have a for loop that lets you do whatever you want with the files. [code=python] import os fileNames = [] for f in os.listdir(os.getcwd()): if f.startswith('pcp'): filesNames.append(f) for fileName in fileNames: f = open(fileName) #do what … | |
Re: Here is an easy way! [code=python] import random d = {}#put your dic here for f in random.shuffle(d.keys()): print d[f], f [/code] That shuffles the keys up and then you just access the values from the dictionary with the keys. | |
Re: EDIT: Woops, accidentaly just posted basically the same as the above. Sorry | |
Re: [QUOTE=scru;798874] The print statement in python (except python 3) automatically adds a newline at the end.[/QUOTE] Wait, i think that in python 3 there is an automatic \n at the end of lines. Here are the default args for print() print - sep = ' ', end = '\n', file … | |
Re: Yet on that note, if you want to import something it is usually a lot better to have a main() function as then you can go: [code=python] if __name__ == '__main__': main() [/code] And i find that a lot more readable then [code=python] if __name__ == '__main__': #every part of … | |
Re: Here we go: [code=python] def main(): books = getBooks points = getPoints printPoints def getBooks(): books = input("enter the books purchased") return books def getPoints(books): if books <= 0: points = 0 elif books <= 1: points = 5 elif books <= 2: points = 15 elif books <= 3: … | |
Re: For that you could also go: [code=python] notList = ["list vars here"] if False not in [not var for var in notList]: #do stuff [/code] | |
Re: Functions are vital to programming, be sure to learn them. Here is a page on them: [url]http://www.penzilla.net/tutorials/python/functions/[/url] | |
| |
![]() | Re: Just a tip, but for trailing '\n' characters in files, you can just use line.strip() function: [code=python] f = open('file.txt') l = [] for line in file: l.append(line.strip()) [/code] Hope that helps you out later. ![]() |
Re: Well using pickle is quite easy in some respects. Its a great tool. Here is an example of code using it: [code=python] #This saves a copy of the class Player. import pickle class Player(): def __init__(self): self.last_location = (0,0) def setLocation(self,pos): self.last_location = pos #and so on p = Player() … | |
Hi For one of my programs i want to be able to graph the performance of things in a graph. The thing is that this graph constantly made a little bit longer with every second that passes. So i was wondering what paintDC to use. And how to use it. … | |
Re: Can you explain what is wrong with the speed of the car? It seems fine to me. | |
Re: Well i would take a look at wx.ButtonPanel, it does the things you want, it can act like an awesome toolbar as well as having an image/gradient as the background. I would love to attach some code as an example but my computer has decided it really dosent want to … | |
Re: If you are wanting video as well then you can use GUI toolkits such as wxPython. This has a wx.MediaCtrl that does the kind of thing you are talking about. | |
Re: Well first, what have you done so far? How good are you at programming? Do you want the backup to be in a zip file or anything special like that? Is there any other information we would need to know about? Adding information really helps questions get answered. | |
Hey i was wondering if there was any way to convert a 24 bit Bitmap into a 256 colour bitmap using PIL or something simillar. I found something like: [code=python] image = image.convert("P",color = Image.ADAPTIVE) [/code] But i couldn't work out how to make that work. So yeah any way … | |
Re: Well using python 2.5 it runs without a hitch. | |
Re: From what i can see your code is not indented properly, so that could be because you are not using code tags when posting which means that indentation is normally lost. CODE HERE tags (without the space after the end one) They mean that it is a lot easier to … | |
Re: add [code=python] global p1move1 global p2move1 [/code] to the start of your program, that may help. | |
Re: I know this may not help.. but when i move something around i just move the rect that it has. So [code=python] rect = rect.move((newpos)) [/code] im not that good at pygame so im not positive that that will help, but anyway. | |
Re: You could easily make a class called Book and have a list of that. It could go: [code=python] class Book(object): def __init__(self): self.Title = name self.Author = author self.ISBN = ISBN def getAuthor(self,author): if author == self.Author: return self #you could have other such methods for ISBN and Title books … | |
Re: 1. [url]http://www.zopelabs.com/cookbook/991178206[/url], thats a tutorial/code snippet 2. i use wxPython, that is great and easy to use once you get used to it... [url]http://zetcode.com/wxpython/[/url] 3. For this i use os.walk and look for filenames that are simillar to my query 4.mySQL is popular SQL Lite is packaged with python 5.THis … | |
Re: Just a though, but couldn't you make it a pyw file? That way there would be no python.exe window and the program wouldnt have to constantly minimise itself over and over. I dont know if i understand the problem correctly, if so then never mind me :P | |
Re: Im thinking that you might be stuck, they would only have a few letter codes if they only supported a few. I couldn't find a way around it. And for the system question, i generally use startfile but i think its much of a muchness as to which is faster. … | |
Re: This smells a bit like homework. But in general, just usl Urllib to get the text from the webpage and then just use the string.count() function to get what you want. When you ask questions like this its good to show people where you are up to in the code … ![]() | |
Re: Please do not double post, the thread is already in the forum and only a couple of posts down, if someone knows then they can help you on the issue. | |
Hi In one of my programs i use a wx.ToolBar, and this toolbar is meant to show a range of picutes that help the user with doing things quickly and easily. But the thing with mine is that i am using 64x64 images for the toolbar, yet when i set … | |
Re: I would reccomend using Wind IDE 101. Its free and great, i recently upgraded to the Personal version (about $50 AUS) and that is exellent, it has a great debugger as well as having so many customisable features. | |
Re: There is no problem with python. What it does is that it prints the first two, tries to add to the i.third and finds it cant. Then it goes to the except: statement and that prints out, in exception Oh and to get the reason i think it is; [code=python] … | |
Re: To delete from a file i just open the file, load it all into one string, and then delete what i wanted, and then save it back into the text file again. Its not that easy at all to just edit stuff halfway through a file without knowing Exactly what … | |
Hi I have been using java.swing for my GUI programs so far and i kinda hit a brick wall, and i think its a stupid one on my account, i cant find a way for something to load a html file to the screen using a java.swing control. This is … | |
Hi When using java, for almost all the time i just use java.swing for my applications that i make, yet when using other programming languages i often find that the GUI toolkit that comes bundled with the download of the Development Kit, is not quite as good as some third … | |
Re: You can do a thing inside the program where you can append arguments. It goes something like: [code=python] import sys sys.argv.append("ooh look an argument") #now there is an argument! [/code] | |
Re: Just a thought but i think the reason nothing happens in your program is the fact that you ask nothing to happen, you make functions but you never call them, to make this work you need something to either call a function that will start it running or at least … | |
Re: Q1 - Whatever you put in the inputs brackets are made into the prompt given to the user when it asks for the input. Q2 - For a while loop, the loop goes while the value given is true, so run is equal to True so therefore it will run … | |
Re: I know that to get a list of all the pixels in the image i used image.getdata. This gave me an object and i could iterate over it, so i could go: [code=python] import Image i = Image.open('stuff.bmp') for pixel in i.getdata(): print pixel [/code] Hope that helps | |
Hi From using java and BlueJ i have found it quite easy to make your own api using inbuilt things in BlueJ. So i was wondering if there was anything in python that would take a python program and find all of the definitions and make an API from that, … | |
Re: [url]http://letmegooglethatforyou.com/?q=python[/url] | |
Re: What the asterix does is that is distinguishes the non-keyword arguments and the keyword arguments. So for your function there you have one value, initial, that is set and will always be in your function, you need it to be there for the function to run. Now, when you go … | |
Re: I know this is not that new but i think it goes through things Very well. [url]http://hetland.org/writing/instant-hacking.html[/url] | |
Hi everyone Well, python 3.0 came out just about a week and a bit ago and i though, now people have had a chance to download it and play around with it a bit, what do you think of it? Is it better? What's the best new feature? Stuff like … |
The End.