614 Posted Topics

Member Avatar for Stefano Mtangoo

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.

Member Avatar for Stefano Mtangoo
0
114
Member Avatar for RRamya

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.

Member Avatar for RRamya
0
96
Member Avatar for smtareq

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.

Member Avatar for Stefano Mtangoo
0
224
Member Avatar for planetPlosion

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 …

Member Avatar for planetPlosion
0
477
Member Avatar for artemis_f

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 …

Member Avatar for Stefano Mtangoo
0
163
Member Avatar for lllllIllIlllI

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 …

Member Avatar for Ene Uran
0
131
Member Avatar for Ghostenshell

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'

Member Avatar for oldSoftDev
0
128
Member Avatar for Ghostenshell

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 …

Member Avatar for Ghostenshell
0
143
Member Avatar for chebude

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 …

Member Avatar for chebude
0
173
Member Avatar for SoulMazer

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.

Member Avatar for SoulMazer
0
240
Member Avatar for mruane
Member Avatar for mruane
0
148
Member Avatar for darkfury18

[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 …

Member Avatar for scru
0
4K
Member Avatar for eyewirejets

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 …

Member Avatar for jrcagle
0
325
Member Avatar for ryn670489

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: …

Member Avatar for ryn670489
0
321
Member Avatar for nclouse

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]

Member Avatar for nclouse
0
78
Member Avatar for shadows09

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]

Member Avatar for shadows09
0
115
Member Avatar for darcee
Member Avatar for leegeorg07

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.

Member Avatar for leegeorg07
0
389
Member Avatar for mruane

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() …

Member Avatar for mruane
0
297
Member Avatar for lllllIllIlllI

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. …

Member Avatar for lllllIllIlllI
0
83
Member Avatar for harrykokil

Can you explain what is wrong with the speed of the car? It seems fine to me.

Member Avatar for Stefano Mtangoo
0
97
Member Avatar for scru

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 …

Member Avatar for Stefano Mtangoo
0
100
Member Avatar for Stefano Mtangoo

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.

Member Avatar for Ene Uran
0
532
Member Avatar for starzstar

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.

Member Avatar for lllllIllIlllI
0
54
Member Avatar for lllllIllIlllI

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 …

Member Avatar for lllllIllIlllI
0
143
Member Avatar for whiteflags
Member Avatar for madurai07

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 …

Member Avatar for madurai07
0
136
Member Avatar for gabec94

add [code=python] global p1move1 global p2move1 [/code] to the start of your program, that may help.

Member Avatar for lllllIllIlllI
0
138
Member Avatar for mmxbass

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.

Member Avatar for mmxbass
0
112
Member Avatar for wotthe2000

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 …

Member Avatar for Ghostenshell
0
153
Member Avatar for revenge2

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 …

Member Avatar for Ene Uran
0
106
Member Avatar for mrpoate

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

Member Avatar for mrpoate
0
2K
Member Avatar for jworld2

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. …

Member Avatar for lllllIllIlllI
0
164
Member Avatar for Aue

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 …

Member Avatar for leegeorg07
0
84
Member Avatar for bharatvamsi

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.

Member Avatar for lllllIllIlllI
0
58
Member Avatar for lllllIllIlllI

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 …

Member Avatar for lllllIllIlllI
0
96
Member Avatar for revenge2

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.

Member Avatar for Ene Uran
0
91
Member Avatar for tzushky

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] …

Member Avatar for Gribouillis
0
227
Member Avatar for codedhands

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 …

Member Avatar for lllllIllIlllI
0
99
Member Avatar for lllllIllIlllI

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 …

Member Avatar for stephen84s
0
90
Member Avatar for lllllIllIlllI

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 …

Member Avatar for stephen84s
0
139
Member Avatar for gsingh2011

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]

Member Avatar for BearofNH
0
469
Member Avatar for acoxia

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 …

Member Avatar for ashutosa
0
171
Member Avatar for revenge2

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 …

Member Avatar for mn_kthompson
0
363
Member Avatar for kiddo39

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

Member Avatar for kiddo39
0
343
Member Avatar for lllllIllIlllI

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, …

Member Avatar for lllllIllIlllI
0
127
Member Avatar for nitu_thakkar
Member Avatar for Stefano Mtangoo
-1
355
Member Avatar for revenge2

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 …

Member Avatar for Stefano Mtangoo
0
468
Member Avatar for revenge2

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]

Member Avatar for sneekula
0
126
Member Avatar for lllllIllIlllI

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 …

Member Avatar for Stefano Mtangoo
0
117

The End.