constructors in python
i need help in writing code for a constructor that takes the parameters x, y and angle. can anyone show me how to write it. ...
i need help in writing code for a constructor that takes the parameters x, y and angle. can anyone show me how to write it. ...
So, within a webapp.RequestHandler subclass I would use self.request.uri to get the request URI. But, I can't access this outside of a RequestHandler and so no go. Any ideas? I'm running Python and I'm new at it as well as GAE. ...
Is there a Pythonic way to check if a list (a nested list with elements & lists) is essentially empty? What I mean by empty here is that the list might have elements, but those are also empty lists. The Pythonic way to check an empty list works only on a flat list: alist = [] if not alist: print("Empty list!") For example, all th...
I have several little functions f1, f2, f3 and a function f. I want f to be a "container" to f1, f2, f3: to do the some of operations f1, f2, f3, depending on the program configuration (for example f1 and f2 or f1 and f3 or all the three) and nothing more. I see two simple solutions: first to add some if's in the function f: if config...
I have a file opened in 'ab+' mode. What I need to do is replacing some bytes in the file with another string's bytes such that: FILE: thisissomethingasperfectlygood. string: 01234 So, for example, I seek for the position (4, 0) and I want to write 01234 in the place of "issom" in the file. Last appearance would be: this01234eth...
just wanted to know how to write the getpos() command which must return an (x,y) tuple of the current position. does it start like this: def getpos(x 100, y 100) not sure need help ...
Example: class Class1: def __init__(self): self.x = Class2('Woo!') class Class2: def __init__(self, word): print word meow = Class1() How do I derive the class name that created the self.x instance? In other words, if I was given the instance self.x, how do I get the name 'Class1'? Using self.x.__class__.__na...
wanted to know how to write a forward and back command in a superclass not sure but i gave it a try dont know if its right or wrong some help plz def forward(self): return (self.100) def back(self): return (self.50) ...
Some of you that are more experienced using Twisted will probably judge me about using it together with threads - but I did it :). And now I am in somehow of a trouble - I am having an application server that listens for client requests and each time a new client connects it spawns another thread that I probably forget to properly close,...
Hello All, I have to write an xml file using python standard modules (not using elementtree, lxml etc) The metadata is a SAML identity provider metadata and is of the form - <?xml version="1.0"?> <EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:ds="http://w...
how do you write a command that turn left or right at an angle in a superclass is it like this: def left(self): self.position += self.angle return (self.position) is it the same as the forward and back command ...
I am using PIL 1.1.6, python 2.5 on windows platform. In my program I am performing point operation (changing the pixel values) and then saving the new image. When I am loading the new and old image, they are not in the same extent. How to impose the extent of old image to the new image? RE edited question: My code is: img = Image.o...
Hi all, In Django 1.1 admin, when I go to add or change an object, my objects are displayed as: Select host to change * Add host Host object Host object Host object Host object Host object This happens for all models in my site, not just Hosts. Rather than display the same name for each object, I would like ...
I am trying to use ReportLab with Unicode characters, but it is not working. I tried tracing through the code till I reached the following line: class TTFont: # ... def splitString(self, text, doc, encoding='utf-8'): # ... cur.append(n & 0xFF) # <-- here is the problem! # ... (This code can be found in ...
I need to implement a listbox for a mobile. The only relevant controls are up and down arrow keys. The listbox should display as many rows of items from a list as will fit on the screen (screen_rows), one row should be highighted (sel_row) and the display should wrap if the user hits up arrow when the first item is highlighted or down ...
I have a python program that does something like this: Read a row from a csv file. Do some transformations on it. Break it up into the actual rows as they would be written to the database. Write those rows to individual csv files. Go back to step 1 unless the file has been totally read. Run SQL*Loader and load those files into the data...
i need to write code for two "robots" that will chase each other around the screen ive managed to do most of it but what i need help with is the getName() command which returns the name of the robot (as a string) which will be overridden in the subclass. can anyone help as im new to python and havnt done this before ...
How could I make my setup.py pre-delete and post-delete the build directory? ...
How do I make setup.py include a file that isn't part of the code? (Specifically, it's a license file, but it could be any other thing.) ...
x = 4.2 - 0.1 vb.net gives 4.1000000000000005 python gives 4.1000000000000005 Excel gives 4.1 Google calc gives 4.1 What is the reason this happens? ...