614 Posted Topics

Member Avatar for dinilkarun

So i take it your making you own module and importing it right? Well if you import a module you can access its variables by going [code=python] module.variable [/code] If you have imported the module then the module is global and therefore there is global access to the variable. If …

Member Avatar for Stefano Mtangoo
0
91
Member Avatar for MaxVK
Member Avatar for tomtetlaw

In your code you go: [code=python] Monster.getAttributesInfo() #and weapon.getAttributesInfo() [/code] The problem with this is that you are not instanciating your class. First creat an instance of the class and then you can call methods then. Otherwise you will keep getting this error.

Member Avatar for tomtetlaw
0
251
Member Avatar for dinesh5

You would use a GUI module such as wxPython to do it. As to not just give you the answer but to point you in the right direction here is a basic frame with one button on it. [code=python] import wx app = wx.App(redirect=False) frame = wx.Frame(None, wx.ID_ANY,title = "Example") …

Member Avatar for lllllIllIlllI
0
88
Member Avatar for bvrclvr1

Try editing it in IDLE, you are probably getting an Error/Exception. If you double click it to start your python script then if there is an error it will not tell you what it is, the window and program will just close. If you run it from IDLE (F5) then …

Member Avatar for lllllIllIlllI
0
192
Member Avatar for lllllIllIlllI

Well daniweb is a pretty vast community right? People here live all around the world. Well with the whole thing about fuel being hugely expensive all around the world i thought it would be good to see the price of fuel all around the world. So just post your location …

Member Avatar for vmanes
0
194
Member Avatar for OutOfReach

You have no choice when it comes to ordering dictionaries. If you want it to print nicely then you CAN order [icode]gameTable.keys()[/icode]. Here is how i would do it: [code=python] gameTable = {(-5,10):0,(-4,10):0,(-3,10):0,(-2,10):0,(-1,10):0,(0,10):0, (1,10):0, (2,10):0, (3,10):0, (4,10):0, (5,10):0, (-5,9):0, (-4,9):0, (-3,9):0, (-2,9):0, (-1,9):0, (0,9):0, (1,9):0, (2,9):0, (3,9):0, (4,9):0, (5,9):0, (-5,8):0, …

Member Avatar for Ene Uran
0
208
Member Avatar for chebude

Well the problem is that in your text file you may have an empty line and therefore splitting it will give you a list with nothing in it and therefore if you try and acces the variable at location 0 there is nothing there. A list index out of range …

Member Avatar for jlm699
0
110
Member Avatar for lllllIllIlllI

Hi everyone, I have been fiddling around with a speech recognition program for a while now and i always had something that bothered me. Here is my code i have been using. It is the example code from code.activestate.com [code=python] from win32com.client import constants import win32com.client import pythoncom """Sample code …

Member Avatar for lllllIllIlllI
0
773
Member Avatar for ihatehippies

Well i can just say that it is not the code's fault. It runs of windows XP fine so i would have to say that the problem most likely lies in the installation of something or your operating system.

Member Avatar for Stefano Mtangoo
0
155
Member Avatar for drjekil

Is this what your talking about? [code=python] import random count = input("How long shall the sequence be?") seq = ''.join([random.choice('AGTC') for x in range(count)]) print "Length:",count print ">",seq [/code]

Member Avatar for drjekil
0
160
Member Avatar for sandmonkey

Try putting an r before the string to make it a raw text and therefore you wont get suff ups due to escaped characters: [code=python] elif choice == 5: h = open(r"C:/Users/Dhylan/Documents/"+raw_input()+".txt") [/code] Hope that helps, if not the please help us help you by posting the exact error you …

Member Avatar for sandmonkey
0
120
Member Avatar for BmeEng

There are a few different sort methods you could use. One of which you can find here: [url]http://www.daniweb.com/forums/thread153427.html[/url] This uses insertion sorting to sort a list of numbers. It should work for this as well.

Member Avatar for lllllIllIlllI
0
99
Member Avatar for Stefano Mtangoo

Have a look at vega's code snippet on this: [url]http://www.daniweb.com/code/snippet393.html[/url] I think it is what you want. Otherwise just explain exactly what you mean by storing it in a .py file.

Member Avatar for Stefano Mtangoo
0
93
Member Avatar for sneekula

Yeah i'm fed up with the bush administration and im really glad its going. I spent today watching the election and from here in Australia you get the general feel that people here would rather Obama in. Here we have Kevin Rudd in and he is a pretty young guy …

Member Avatar for lllllIllIlllI
0
332
Member Avatar for kempablavitt
Member Avatar for lllllIllIlllI
0
180
Member Avatar for iamoldest

Yeah you cant assign values to a string. Thats what your program is trying to do. Well i would advise using a dictionary for this one: [code=python] d1 = {} d2 = {} for swipeload in range (0, 15, 1): d1["E"+str(swipeload)+"_Path"] = os.path.join("data","E"+str(swipeload)+".gif") d2["E"+str(swipeload)] = pygame.image.load("E"+str(swipeload)+"_Path") [/code] This now has …

Member Avatar for tomtetlaw
0
175
Member Avatar for Stefano Mtangoo

What happens now when you hit return? Oh and for the algin left and right just bind something to this code: [code=python] #to align left self.textarea.ApplyAlignmentToSelection(rt.TEXT_ALIGNMENT_LEFT) #to align right self.textarea.ApplyAlignmentToSelection(rt.TEXT_ALIGNMENT_RIGHT) [/code] Hope that helps

Member Avatar for lllllIllIlllI
0
109
Member Avatar for lllllIllIlllI

So. Today i had this though. What is one dollar times two dollars. Instantly the thought sprang to mind that it would be two dollars right? Becuase 1 x 2 = 2. But then i though wait. What about the dollar sign? That means that this has become algebra! So …

Member Avatar for lllllIllIlllI
0
158
Member Avatar for lllllIllIlllI

Hi guys, I was just wondering how far peole have ever gotten in the python challenge? if you havent heard of it, it is a series of python based problems that explore many programming techniques including regex and images. If you havent tried it the link to it is: [url]http://www.pythonchallenge.com[/url] …

0
51
Member Avatar for lllllIllIlllI

Hi Guys, I was wondering if there was any way in which you can change the opacity of a window in wxPython. I would like to create a window that is mostly see through but so far i have found no way to do that. My program is a simple …

Member Avatar for lllllIllIlllI
0
94
Member Avatar for Bouzy210

Okay, what it your whole program try and do? I'm not quite sure with the information given.

Member Avatar for Stefano Mtangoo
0
126
Member Avatar for lllllIllIlllI

Hi guys, I was looking at some of the commercial IDE's today. Most notably being wingware's python IDE personal edition. I was wondering wether people thought wether the $30 you need to pay for it is worth it or is it not that great when it comes to it. Any …

Member Avatar for Stefano Mtangoo
0
62
Member Avatar for Stefano Mtangoo

I really enjoy pyScripter on windows, it lets you debug as well as run the script. Syntax highlighting, automatic indentation. Its a great piece of software.

Member Avatar for mathijs
0
240
Member Avatar for pyth0n

I used to do this is i wanted to restart the file: [code=python] exec file("File Name Here") [/code] That will re-open your python program again.

Member Avatar for pyth0n
0
106
Member Avatar for massivefermion

If your using a GUI you may want to take a look at this piece of code: [url]http://www.daniweb.com/forums/post623822-10.html[/url]

Member Avatar for lllllIllIlllI
0
101
Member Avatar for leegeorg07

This is a sorting function. It grabs a number from the list, that is now the key. Then in the while loop it moves the values to the right if they are more then the key, so essentially, it gets a number from a list. It then compares it with …

Member Avatar for ZZucker
0
295
Member Avatar for ganil123

You can also get it by using the class.__dict__ method. [code=python] >>> class tester(object): def f1(self): print '1' def f2(self): print '2' def HELLO(self): print 'Hello' >>> print tester.__dict__ {'f1': <function f1 at 0x00BB8AF0>, '__module__': '__main__', 'f2': <function f2 at 0x00BB8B30>, '__doc__': None, '__dict__': <attribute '__dict__' of 'tester' objects>, '__weakref__': …

Member Avatar for lllllIllIlllI
0
228
Member Avatar for malcolm4458

If you want help for syntax. There is an easy way to do it. you go something like this for your example: [code=python] # just type each line in the interpreter >>> import os >>>help(os.execv) #displays info [/code] in your case it shows this: [code=python] Help on built-in function execv …

Member Avatar for jlm699
0
3K
Member Avatar for dinilkarun

Well there might be a better way but you could go something like: [code=python] # lets assubme variable self.frame is your frame class Frame(wx.Frame) def __init__(self) wx.Frame.__init__(self,None,pos = (100,100)) self.Show() self.Dialog() def Dialog() d = wx.Dialo("arguments here") d.Position = (self.frame.Position[0]+(self.frame.Size[0]/2,self.frame.Position[1]+(self.frame.Size[1]/2 d.ShowModal() [/code] I think that should work. It takes the …

Member Avatar for jlm699
0
976
Member Avatar for mruane

okay, i know this is not exactly what you asked but in your code i noticed a lot of: [code=python] print "" [/code] You dont need to do that as just going [code=python] print [/code] Without the "" marks will do the exact same thing. Or you could use [code=python]print …

Member Avatar for mruane
0
300
Member Avatar for lllllIllIlllI

Hi I have been mucking around with VPython for a bit now and i can use it for basic 3D Python but i have not yet worked out how to do things that arent the usual, add square, add arrow, add sphere. So i was wondering if it was even …

Member Avatar for ZZucker
0
527
Member Avatar for jcafaro10

just wanted to say that i found that that [url]www.diveintopython.org[/url] was not down so you can use that if you want.

Member Avatar for ZZucker
0
124
Member Avatar for dinilkarun

Have you had a look at the wx.ProgressBar? Becuase in the Docs and Demos they show a way to do just that. You might have to decipher the un-needed code though.

Member Avatar for dinilkarun
0
146
Member Avatar for Devlan

when you go. [code=python] if word in tuplelist: #do stuff [/code] That is a problem. The reason is your comparing something that looks like this: [code=python] "Hello" [/code] To something that looks like this [code=python] [("hello","something you say as a greeting")] [/code] Now those dont look quite the same right? …

Member Avatar for Devlan
0
142
Member Avatar for sneekula
Member Avatar for leegeorg07

I cant get the link to work. It says this: [quote] You have attempted to access code for an article that does not exist. Create this article first. If the article used to exist, it may have been deleted. [/quote] Am i the only one getting this problem?

Member Avatar for shadwickman
0
104
Member Avatar for The Dude

Really? This a parody, it sounds exactly like judge judy on a completly normal day! Ha ha ha, very good. :)

Member Avatar for lllllIllIlllI
0
46
Member Avatar for lllllIllIlllI

Hi Im pretty new to the whole C++ programming language but after learning python and java i decided to give it a go. I have been using tutorials at [url]www.cplusplus.com[/url] and that has been working fine but i came across a bit of code today i couldn't understand. It went …

Member Avatar for lllllIllIlllI
0
145
Member Avatar for massivefermion
Member Avatar for Gribouillis
0
160
Member Avatar for dinesh5

I think the best thing you can do for the first question is just ask us becuase i really dont think there is any IDE in python that will do that.

Member Avatar for jlm699
0
57
Member Avatar for jworld2

another way to do it is to Destroy the image every time so the code would look like this: [code=python] if self.image: self.image.Destroy() self.image = wx.StaticBitmap(image, etc. etc.) [/code]

Member Avatar for jworld2
0
74
Member Avatar for dinilkarun

couldnt you just import mod1 into your mod2? That way you could then access all methods.

Member Avatar for dinilkarun
0
252
Member Avatar for jcafaro10

the asterix means a parameter that will catch all parameters that arent used in the first ones (if there are any) and all the left over parameters that are given to the method are then made into a list. For a reference see here: [url]http://www.pasteur.fr/recherche/unites/sis/formation/python/ch06s06.html[/url]

Member Avatar for lllllIllIlllI
0
99
Member Avatar for SoulMazer

The problem is that loop1 exists in two places. In the global scope and in the function scope. This means that the loop1 in the function is different to the loop1 in the main body. To get around this you can add [icode]global loop1[/icode] to your program.

Member Avatar for SoulMazer
0
158
Member Avatar for vmars

that just makes sure the program knows where to look to find the variables. So if more than one thing was in the formatted string you would use a tuple.

Member Avatar for bvdet
0
113
Member Avatar for dr_hamburger

This is a direct quote from [url]http://en.wikibooks.org/wiki/Python_Programming/Exceptions[/url] [quote] Custom Exceptions Code similar to that seen above can be used to create custom exceptions and pass information along with them. This can be extremely useful when trying to debug complicated projects. Here is how that code would look; first creating the …

Member Avatar for Stefano Mtangoo
0
117
Member Avatar for dr_hamburger
Member Avatar for Kezoor
Member Avatar for Kezoor
0
182
Member Avatar for dinilkarun

Are you using wxPython? In that case the event you are looking for is: [icode]wx.EVT_LEFT_DOWN[/icode]

Member Avatar for dinilkarun
0
129

The End.