15,181 Topics
| |
OK, this may be a dumb question but I'll ask anyway. I am starting to see the benefits of using classes. Most notably code reuse, inheritance and overloading. Shoud I still be writing fuctions in my scripts or do classes make them obsolete? Is there a rule of thumb that … | |
I'm making a text game and im making a save() and load() function i'v got the save function to work but i dont know how to change varyables in the program depending on the varyables in the text files. heres the code for the functions: [code=python] def save(): openfile = … | |
Hello! I'm trying to execute a simple script in the command line, and for some reason, it's not working. Shouldn't it be as simple as this? [code]python myscript.py[/code] And yet when I try that, I get "Syntax Error: invalid syntax" I've googled around, read through the docs--I have a feeling … | |
Hy all. I'm beginner in Python ( started to learn it before a week and a half), but since I already know MSWLogo, python is easy. So, I created a fighting-text game called: PythonFight. Features: -10 fights -4 normal kicks and 1 special -rage -bonuses after round. Please download and … | |
hi! i have a program which makes use of threads(threading module) it runs fine when i run it using python(2.6).. however when i create an exe of the file(using py2exe) and then run it, the following error occurs.. [code]Unhandled exception in thread started by error in sys.excepthook: original exception was: … | |
hi everyone, can you please help me out. what i want is to have a server that listens to a single port for clients to connect using tcp. this is located in a thread. if one client connects, it would relocate this connection to another thread so that the first … | |
Does anyone know how to convert an instance to unicode? I understand how to convert a string into unicode format u=unicode(s, 'ASCII', ignore), however this assumes that s is already a string and converting s by the str(s) method will kick back an error if s contains unicode unfriendly. The … | |
Ok I will post all of the code at the bottom, first thing however is the loop below starts at 0, then increments to 1, but never increments any further. [code=python] for counter1 in range(fieldlength): if self.__fields[counter1] == field: for counter2 in range(rowlength): #print self.__rows[counter2][counter1] if self.__rows[counter2][counter1] == value: return1 … | |
As simple as question is; What GUI toolkit do you use and why? Why didn't you used the rest? Here are GUIs I know of: [LIST=1] [*]TkInter [*]PyQT [*]PyGTK [*]Wxpython [/LIST] You can Add If you have one that isn't Listed | |
I am trying to create an authentication script. I am trying to use the PASSWORD function within Mysql but it wont work. Any ideas [CODE] #!/usr/bin/python # e begoli, python connector for mysql # import MySQL module import MySQLdb import cgi print "Content-type: text/html\n" # connection db = MySQLdb.connect(host = … | |
So here's my question. I'm new to python and am near lost. I've been through a few tutorials and still don't feel confident. Sure I can do whatever the tutorials say, but it's a different story when I do the whole thing myself. Here's what I would like to do … | |
| hi again i have two questions: firstly do you know if win32 and other add-ons for python are released for python 2.6? secondly my whole computer is messed up and i want to create a program that will search through a selected folder or folders and will move any items … |
I have code but when I want to gather my widgets under same wx.StaticBox I fail. I wonder what is wrong! Please someone to corrrect me! [CODE=python] #Add static box to hold related widgets--- it otherwise does nothing holder1 = wx.StaticBox(mpanel, -1, label="Transactions", pos = (10, 10), size = (300,300)) … | |
I'm trying to get to grips with using files, particurlarly saving a set of inputs from the user into a file and then load it all back up again. I have a program which, through a little object oriented interactivity, allows the user to pair up names and numbers in … | |
Its about the pay system of a shop. The user enters a product ID,the interpreter gets the details from the file and appends it to a list and continues till the products are over. If the user can't enter the ID he can add the product name directly which will … | |
I only made an on and addition button with actual functions[ICODE] #!/usr/bin/python # gridsizer.py import wx app = wx.App() class GridSizer(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(300, 250)) def On(self, event): x=input("") def add(self,event): return x y=input("") print x + y menubar = wx.MenuBar() file = … | |
I am learning to create a database with python. I am using this line of code to populate my table T.insert(2, 'Jones', 'Jack', 15, False, 0.0) And the table is created as follow: T = SDBTable('id=ui', 'last', 'first', 'age=i', 'married=b', 'salary=f') I have a class SDBTable and in it there … | |
Hello, I'm using Java and Python together with Jython and I'm having trouble with some python syntax. I have a custom listener that I want to add to an object. Usually I'd do it like this: class ballCollisionListener(animation.CollisionListener): def collisionDetected(self,event): if event.getSource()==boundary: if ball.getX()<=0 or ball.getX()+ball.getWidth()>=boundary.getWidth(): ball.setXSpeed(-ball.getXSpeed()) elif ball.getY()<=0 or … | |
I was trying to write the output of a loop on a file. The problem is the writing repeats for each loop. [ICODE]prev_line = "" while line: Total = 0 fields = line.split() N = len(fields) name = fields[0] #sum each 5 fields over the raw: for step in range … | |
Hello I am quite new programming in Jython, I am working with DB. I a send SQL Statements, but I want to handle the zero rows in Resulset. rs = dataSource.performQuery(sqlstatement) rs.moveFirst() I dont know which condition has to be set when the Resulset doesnt has any row. When I … | |
I've gotten a little bit furter in understanding the general workings of python, and currently I'm fidgeting with classes and objects. I was thinking of the possibilities of having a program with a whole bunch of user defined classes that the user can use (hey, almost a repetitive aliteration there...) … | |
Hello!! I desperately need help on event triggering across panels in wxPython! :( I have 2 classes that inherit wx.Panel: Leftpanel & Rightpanel Leftpanel consists of several buttons. Rightpanel consists of a graph (i.e. using matplotlib). I want to make the program so that pressing the button on Leftpanel will … | |
Hello All, Greetings!! I was thinking of making MP3 Encoder. This is because I cannot find Exact encoder so I was finding some bindings for Lame Mp3 encoder and CD extractor/any cd to wav Library Thanks all Steve | |
First of all, I'm a total beginner which is the reason that probably my code contains a few simple and dumb mistakes...but how you see I'm working on it ;) My task is to write a program that contains a queue which will be returned in reversed order. But my … | |
Hi, I have set up a basic HTTP server, using code similar to that on [url]http://fragments.turtlemeat.com/pythonwebserver.php[/url]. I have created a BaseHTTPRequestHandler, and modified the do_GET function. This server is linked to a FLEX GUI, which requires a crossdomain.xml file in order to get data from another domain. If the server … | |
I want to subclass a python dictionary to create a new class with dynamic keys. In other words the key value is 'property(fset, fget, fdel, doc)'. For some reason the when I get the d['b'] key, a property object is return instead of the function get_b. d['b'] should return the … | |
Hi there. Iv been searching (this forum and Google) for examples using the StyledTextCtrl, so that I can see how the thing actually works, but with no real joy. Iv found a couple of very basic examples but nothing that really shows the workings of the control. Iv seen the … | |
I have this assignment where I write certain lines from an input file. These lines I'm looking for in this case is only identified by its following line ("EOL"). It goes like (shortened): [CODE]while True: line = infile.readlines() if not line: break linesplit = line.split(",") line = line[:-1] if line … | |
hi all, glad I found this site. I hope you all can help me out with this little problem. First, my environment: Mac OSX 10.5.5 Python 2.6 (compiled from source, not using macports) basedir: /usr/local/bin/python; /usr/local/lib/python2.6 Following the proper directions on how to install setuptools (from here [url]http://pypi.python.org/pypi/setuptools#cygwin-mac-os-x-linux-other[/url]) [code] bash-3.2# … | |
Here I am again with new problem. I want to do some calculation on each field row after row. The for loop which I tried is not giving me what I expected [ICODE]#sum each 5 fields over the raw: for step in range (6, N, 5): for i in range … |
The End.