SQL Alchemy - How to Delete from a model instance?
Say I get a model instance like this: instance = session.query(MyModel).filter_by(id=1).first() How can I delete that row? Is there a special method to call? ...
Say I get a model instance like this: instance = session.query(MyModel).filter_by(id=1).first() How can I delete that row? Is there a special method to call? ...
I have an end tag followed by a carriage return line feed (x0Dx0A) followd by one or more tabs (x09) followed by a new start tag . Something like this: </tag1>x0Dx0Ax09x09x09<tag2> or </tag1>x0Dx0Ax09x09x09x09x09<tag2> What Python regex should I use to replace it with something like this: </tag1><tag3>content</tag3><tag2> Than...
I have two files, and I want to perform some line-wise operation across both of them. (In other words, the first lines of each file correspond, as do the second, etc.) Now, I can think of a number of slightly cumbersome ways to iterate across both files simultaneously; however, this is Python, so I imagine that there is some syntactic sh...
Hey all again. It appears to me that functions can reference variables outside of their scope but cannot set them. Is this correct? Am I understanding this right. I also included the gloals usage,. I KNOW they are bad - ju-ju and will avoid. I know how to get around this but just want to be clear. My example program: import foo # b...
Is it possible to write a program using Bonjour or a Bonjour-compatible library in a cross-platform language such as Java or Python? If so, where can I find the files needed for this? ...
Problem Summary I've got an application which combines both Java and Python, the two languages communicating across a localhost socket. (I cannot use Jython, I can't throw out Java for PyGame, and I can't throw out Python for pure Java.) The application opens the socket between Python and Java and a socket from Java to a central server...
Hi, i wonder if it's possible to make a RegEx for the following data pattern: '152: Ashkenazi A, Benlifer A, Korenblit J, Silberstein SD.' string = '152: Ashkenazi A, Benlifer A, Korenblit J, Silberstein SD.' I am using this Regular Expression (Using Python's re module) to extract these names: re.findall(r'(\d+): (.+), (.+), (.+), (...
I'm creating a DOT graph visualization from a tree-like data structure but am having difficulties setting fixed level depths based upon data type. For example, if I had 4 nodes in a tree and A denotes a specific data type and B represents another it would like Graph_1: ROOT ...
Like everyone else, I can say "I've tried everything!" I kind of did. I looked all over StackOverflow, and tried all the answers, but got nothing. Anyways, I am jetting to at least get some code printed by Python before I get even further in developing this. I want to receive UDP packets from my Garry's Mod server (logaddress_add MyIP:7...
I have this tail recursive function here: def fib(n, sum): if n < 1: return sum else: return fib(n-1, sum+n) c = 998 print(fib(c, 0)) It works up to n=997, then it just breaks and spits a "maximum recursion depth exceeded in comparison" RuntimeError. Is this just a stack overflow? Is there a way to get around ...
I have a Django project that uses Celery for running asynchronous tasks. I'm doing my development on a Windows XP machine. Starting my Django server (python manage.py runserver 80) works fine, but attempting to start the Celery Daemon (python manage.py celeryd start) fails with the following error: ImportError: Could not import settin...
I am new to using Frameworks for web development and I have noticed that frameworks like django, turbogears etc come with auth packages which contains user models. Am I supposed to directly modify these and use them as my User models or am I supposed to associate my own user models to these and use them just for authentication? ...
Hi, I'm very new to python. two days. trying to get a plot working with matplotlib. I'm getting this error: cannot perform reduce with flexible type the line with the error is: ax.scatter(x,y,z,marker='o') Variables: ax is defined as: ax = Axes3D(fig) fig is defined as: fig = plt.figure() x, y, z are lists Any python expert...
My use case is I want to initialize some functions in a file and then start up ipython with those functions defined. Is there any way to do something like ipython --run_script=myscript.py? ...
Possible Duplicate: join list of lists in python Is there in Python a built-in or a particular syntax to accomplish the following on the fly? def merge(listOfLists): result = [] for l in listOfLists: result.extend(l) return result print merge( [[1,2,3,4], [5,6], [7,8,9]] ) # [1, 2, 3, 4, 5, 6, 7, 8, 9] ...
I am using this code: def req(url, postfields): proxy_support = urllib2.ProxyHandler({"http" : "127.0.0.1:8118"}) opener = urllib2.build_opener(proxy_support) opener.addheaders = [('User-agent', 'Mozilla/5.0')] return opener.open(url).read() To make a simple http get request (using tor as proxy). Now I would like to ...
Hi, I'll soon (in an year) be graduating with an undergraduate master's (four years) in computer related field. At my university campus placements will start the coming semester. This will be the last semester on campus as we would be going off campus for industry internships in the final semester. Generally the Placement Division gets ...
I have the following models: class Indicator(models.Model): name = models.CharField(max_length=200) category = models.ForeignKey(IndicatorCategory) weight = models.IntegerField() industry = models.ForeignKey(Industry) def __unicode__(self): return self.name class Meta: ordering = ('name',) clas...
Hi all, In Python, a dictionary can be constructed from an iterable collection of tuples: >>> listOfTuples = zip(range(10), [-x for x in range(10)]) >>> listOfTuples [(0, 0), (1, -1), (2, -2), (3, -3), (4, -4), (5, -5), (6, -6), (7, -7), (8, -8), (9, -9)] >>> theDict = dict(listOfTuples) >>> theDict {0: 0, 1: -1, 2: -2, 3: -3, 4: -4, 5...
Can it be moved by Window Title as well as exe name? Other info on moving it in another language could be helpful. Update: some Perl sample can be found in Win32::GuiTest but there seems to be no resize or move functions. ...