text
stringlengths
200
200k
source
stringclasses
2 values
# Union and Intersect in Django ## Question class Tag(models.Model): name = models.CharField(maxlength=100) class Blog(models.Model): name = models.CharField(maxlength=100) tags = models.ManyToManyField(Tag) Simple models just to ask my question. I wonder how can i query blogs using tags in two different wa...
stackoverflow-qa
# Union and Intersect in Django ## Question class Tag(models.Model): name = models.CharField(maxlength=100) class Blog(models.Model): name = models.CharField(maxlength=100) tags = models.ManyToManyField(Tag) Simple models just to ask my question. I wonder how can i query blogs using tags in two different wa...
stackoverflow-qa
# How should I best emulate and/or avoid enum's in Python? ## Question I've been using a small class to emulate Enums in some Python projects. Is there a better way or does this make the most sense for some situations? Class code here: class Enum(object): '''Simple Enum Class Example Usage: >>> codes = Enum('FOO BAR...
stackoverflow-qa
# How should I best emulate and/or avoid enum's in Python? ## Question I've been using a small class to emulate Enums in some Python projects. Is there a better way or does this make the most sense for some situations? Class code here: class Enum(object): '''Simple Enum Class Example Usage: >>> codes = Enum('FOO BAR...
stackoverflow-qa
# How should I best emulate and/or avoid enum's in Python? ## Question I've been using a small class to emulate Enums in some Python projects. Is there a better way or does this make the most sense for some situations? Class code here: class Enum(object): '''Simple Enum Class Example Usage: >>> codes = Enum('FOO BAR...
stackoverflow-qa
# How should I best emulate and/or avoid enum's in Python? ## Question I've been using a small class to emulate Enums in some Python projects. Is there a better way or does this make the most sense for some situations? Class code here: class Enum(object): '''Simple Enum Class Example Usage: >>> codes = Enum('FOO BAR...
stackoverflow-qa
# How should I best emulate and/or avoid enum's in Python? ## Question I've been using a small class to emulate Enums in some Python projects. Is there a better way or does this make the most sense for some situations? Class code here: class Enum(object): '''Simple Enum Class Example Usage: >>> codes = Enum('FOO BAR...
stackoverflow-qa
# How should I best emulate and/or avoid enum's in Python? ## Question I've been using a small class to emulate Enums in some Python projects. Is there a better way or does this make the most sense for some situations? Class code here: class Enum(object): '''Simple Enum Class Example Usage: >>> codes = Enum('FOO BAR...
stackoverflow-qa
# Topological sort, recursive, using generators ## Question Data: a dependency list, already verified to be acyclic. So here, 'a' depends on 'b','c' (c depends on d), etc... A = { 'a' : dict(b=1, c=1), 'c' : dict(d=1), 'd' : dict(e=1,f=1,g=1), 'h' : dict(j=1) } I'd like to have a top-down, recu...
stackoverflow-qa
# Topological sort, recursive, using generators ## Question Data: a dependency list, already verified to be acyclic. So here, 'a' depends on 'b','c' (c depends on d), etc... A = { 'a' : dict(b=1, c=1), 'c' : dict(d=1), 'd' : dict(e=1,f=1,g=1), 'h' : dict(j=1) } I'd like to have a top-down, recu...
stackoverflow-qa
# Delete all data for a kind in Google App Engine ## Question I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. ## Answer Presumably your hack was so...
stackoverflow-qa
# Delete all data for a kind in Google App Engine ## Question I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. ## Answer Unfortunately, there's no w...
stackoverflow-qa
# Delete all data for a kind in Google App Engine ## Question I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. ## Answer The official answer from Go...
stackoverflow-qa
# Delete all data for a kind in Google App Engine ## Question I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. ## Answer Try using App Engine Consol...
stackoverflow-qa
# Delete all data for a kind in Google App Engine ## Question I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. ## Answer I've tried db.delete(result...
stackoverflow-qa
# Delete all data for a kind in Google App Engine ## Question I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. ## Answer I am currently deleting the...
stackoverflow-qa
# Delete all data for a kind in Google App Engine ## Question I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. ## Answer One tip. I suggest you get ...
stackoverflow-qa
# Delete all data for a kind in Google App Engine ## Question I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. ## Answer If I were a paranoid person...
stackoverflow-qa
# Delete all data for a kind in Google App Engine ## Question I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. ## Answer With django, setup url: u...
stackoverflow-qa
# Delete all data for a kind in Google App Engine ## Question I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. ## Answer The fastest and efficient w...
stackoverflow-qa
# Delete all data for a kind in Google App Engine ## Question I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. ## Answer If you are using Java/JPA y...
stackoverflow-qa
# Delete all data for a kind in Google App Engine ## Question I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. ## Answer You can now use the Datasto...
stackoverflow-qa
# Delete all data for a kind in Google App Engine ## Question I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. ## Answer Yes you can: Go to Datastor...
stackoverflow-qa
# Python Music Library? ## Question I'm looking at writing a little drum machine in Python for fun. I've googled some and found the python pages on music and basic audio as well as a StackOverflow question on generating audio files, but what I'm looking for is a decent library for music creation. Has anyone on here ...
stackoverflow-qa
# Python Music Library? ## Question I'm looking at writing a little drum machine in Python for fun. I've googled some and found the python pages on music and basic audio as well as a StackOverflow question on generating audio files, but what I'm looking for is a decent library for music creation. Has anyone on here ...
stackoverflow-qa
# Python Music Library? ## Question I'm looking at writing a little drum machine in Python for fun. I've googled some and found the python pages on music and basic audio as well as a StackOverflow question on generating audio files, but what I'm looking for is a decent library for music creation. Has anyone on here ...
stackoverflow-qa
# Python Music Library? ## Question I'm looking at writing a little drum machine in Python for fun. I've googled some and found the python pages on music and basic audio as well as a StackOverflow question on generating audio files, but what I'm looking for is a decent library for music creation. Has anyone on here ...
stackoverflow-qa
# Python Music Library? ## Question I'm looking at writing a little drum machine in Python for fun. I've googled some and found the python pages on music and basic audio as well as a StackOverflow question on generating audio files, but what I'm looking for is a decent library for music creation. Has anyone on here ...
stackoverflow-qa
# Is there something like 'autotest' for Python unittests? ## Question Basically, growl notifications (or other callbacks) when tests break or pass. Does anything like this exist? If not, it should be pretty easy to write.. Easiest way would be to.. run python-autotest myfile1.py myfile2.py etc.py Check if files-to...
stackoverflow-qa
# Is there something like 'autotest' for Python unittests? ## Question Basically, growl notifications (or other callbacks) when tests break or pass. Does anything like this exist? If not, it should be pretty easy to write.. Easiest way would be to.. run python-autotest myfile1.py myfile2.py etc.py Check if files-to...
stackoverflow-qa
# Is there something like 'autotest' for Python unittests? ## Question Basically, growl notifications (or other callbacks) when tests break or pass. Does anything like this exist? If not, it should be pretty easy to write.. Easiest way would be to.. run python-autotest myfile1.py myfile2.py etc.py Check if files-to...
stackoverflow-qa
# Is there something like 'autotest' for Python unittests? ## Question Basically, growl notifications (or other callbacks) when tests break or pass. Does anything like this exist? If not, it should be pretty easy to write.. Easiest way would be to.. run python-autotest myfile1.py myfile2.py etc.py Check if files-to...
stackoverflow-qa
# Is there something like 'autotest' for Python unittests? ## Question Basically, growl notifications (or other callbacks) when tests break or pass. Does anything like this exist? If not, it should be pretty easy to write.. Easiest way would be to.. run python-autotest myfile1.py myfile2.py etc.py Check if files-to...
stackoverflow-qa
# Is there something like 'autotest' for Python unittests? ## Question Basically, growl notifications (or other callbacks) when tests break or pass. Does anything like this exist? If not, it should be pretty easy to write.. Easiest way would be to.. run python-autotest myfile1.py myfile2.py etc.py Check if files-to...
stackoverflow-qa
# Is there something like 'autotest' for Python unittests? ## Question Basically, growl notifications (or other callbacks) when tests break or pass. Does anything like this exist? If not, it should be pretty easy to write.. Easiest way would be to.. run python-autotest myfile1.py myfile2.py etc.py Check if files-to...
stackoverflow-qa
# Is there something like 'autotest' for Python unittests? ## Question Basically, growl notifications (or other callbacks) when tests break or pass. Does anything like this exist? If not, it should be pretty easy to write.. Easiest way would be to.. run python-autotest myfile1.py myfile2.py etc.py Check if files-to...
stackoverflow-qa
# Is there something like 'autotest' for Python unittests? ## Question Basically, growl notifications (or other callbacks) when tests break or pass. Does anything like this exist? If not, it should be pretty easy to write.. Easiest way would be to.. run python-autotest myfile1.py myfile2.py etc.py Check if files-to...
stackoverflow-qa
# How to get instance variables in Python? ## Question Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code: class hi: def __init__(self): self.ii = "foo" self.kk = "bar" Is there a way for me to do this: >>> mystery_method(hi) ["ii", "...
stackoverflow-qa
# How to get instance variables in Python? ## Question Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code: class hi: def __init__(self): self.ii = "foo" self.kk = "bar" Is there a way for me to do this: >>> mystery_method(hi) ["ii", "...
stackoverflow-qa
# How to get instance variables in Python? ## Question Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code: class hi: def __init__(self): self.ii = "foo" self.kk = "bar" Is there a way for me to do this: >>> mystery_method(hi) ["ii", "...
stackoverflow-qa
# How to get instance variables in Python? ## Question Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code: class hi: def __init__(self): self.ii = "foo" self.kk = "bar" Is there a way for me to do this: >>> mystery_method(hi) ["ii", "...
stackoverflow-qa
# How to get instance variables in Python? ## Question Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code: class hi: def __init__(self): self.ii = "foo" self.kk = "bar" Is there a way for me to do this: >>> mystery_method(hi) ["ii", "...
stackoverflow-qa
# How to get instance variables in Python? ## Question Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code: class hi: def __init__(self): self.ii = "foo" self.kk = "bar" Is there a way for me to do this: >>> mystery_method(hi) ["ii", "...
stackoverflow-qa
# How to get instance variables in Python? ## Question Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code: class hi: def __init__(self): self.ii = "foo" self.kk = "bar" Is there a way for me to do this: >>> mystery_method(hi) ["ii", "...
stackoverflow-qa
# How to get instance variables in Python? ## Question Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code: class hi: def __init__(self): self.ii = "foo" self.kk = "bar" Is there a way for me to do this: >>> mystery_method(hi) ["ii", "...
stackoverflow-qa
# Python signal woes: SIGQUIT handler delays execution if SIGQUIT recieved during execution of another signal handler? ## Question The following program is very simple: it outputs a single dot each half a second. If it recieves a SIGQUIT, it proceeds to output ten Qs. If it recieves a SIGTSTP (Ctrl-Z), it outputs ten ...
stackoverflow-qa
# Python signal woes: SIGQUIT handler delays execution if SIGQUIT recieved during execution of another signal handler? ## Question The following program is very simple: it outputs a single dot each half a second. If it recieves a SIGQUIT, it proceeds to output ten Qs. If it recieves a SIGTSTP (Ctrl-Z), it outputs ten ...
stackoverflow-qa
# Change the width of form elements created with ModelForm in Django ## Question How can i change the width of a textarea form element if i used ModelForm to create it? Here is my product class: class ProductForm(ModelForm): long_desc = forms.CharField(widget=forms.Textarea) short_desc = forms.CharField(widg...
stackoverflow-qa
# Change the width of form elements created with ModelForm in Django ## Question How can i change the width of a textarea form element if i used ModelForm to create it? Here is my product class: class ProductForm(ModelForm): long_desc = forms.CharField(widget=forms.Textarea) short_desc = forms.CharField(widg...
stackoverflow-qa
# Change the width of form elements created with ModelForm in Django ## Question How can i change the width of a textarea form element if i used ModelForm to create it? Here is my product class: class ProductForm(ModelForm): long_desc = forms.CharField(widget=forms.Textarea) short_desc = forms.CharField(widg...
stackoverflow-qa
# Is there an easy way to request a URL in python and NOT follow redirects? ## Question Looking at the source of urllib2 it looks like the easiest way to do it would be to subclass HTTPRedirectHandler and then use build_opener to override the default HTTPRedirectHandler, but this seems like a lot of (relatively compli...
stackoverflow-qa
# Is there an easy way to request a URL in python and NOT follow redirects? ## Question Looking at the source of urllib2 it looks like the easiest way to do it would be to subclass HTTPRedirectHandler and then use build_opener to override the default HTTPRedirectHandler, but this seems like a lot of (relatively compli...
stackoverflow-qa
# Is there an easy way to request a URL in python and NOT follow redirects? ## Question Looking at the source of urllib2 it looks like the easiest way to do it would be to subclass HTTPRedirectHandler and then use build_opener to override the default HTTPRedirectHandler, but this seems like a lot of (relatively compli...
stackoverflow-qa
# Is there an easy way to request a URL in python and NOT follow redirects? ## Question Looking at the source of urllib2 it looks like the easiest way to do it would be to subclass HTTPRedirectHandler and then use build_opener to override the default HTTPRedirectHandler, but this seems like a lot of (relatively compli...
stackoverflow-qa
# Is there an easy way to request a URL in python and NOT follow redirects? ## Question Looking at the source of urllib2 it looks like the easiest way to do it would be to subclass HTTPRedirectHandler and then use build_opener to override the default HTTPRedirectHandler, but this seems like a lot of (relatively compli...
stackoverflow-qa
# Is there an easy way to request a URL in python and NOT follow redirects? ## Question Looking at the source of urllib2 it looks like the easiest way to do it would be to subclass HTTPRedirectHandler and then use build_opener to override the default HTTPRedirectHandler, but this seems like a lot of (relatively compli...
stackoverflow-qa
# Is there an easy way to request a URL in python and NOT follow redirects? ## Question Looking at the source of urllib2 it looks like the easiest way to do it would be to subclass HTTPRedirectHandler and then use build_opener to override the default HTTPRedirectHandler, but this seems like a lot of (relatively compli...
stackoverflow-qa
# Report generation ## Question I am writing a web app using TurboGears, and in that app the users must be able to generate different reports. The data the reports need is stored in a database (MySQL). The reports must be returned either as a easily printable html document, or a pdf file. I have previously used jaspe...
stackoverflow-qa
# Report generation ## Question I am writing a web app using TurboGears, and in that app the users must be able to generate different reports. The data the reports need is stored in a database (MySQL). The reports must be returned either as a easily printable html document, or a pdf file. I have previously used jaspe...
stackoverflow-qa
# Report generation ## Question I am writing a web app using TurboGears, and in that app the users must be able to generate different reports. The data the reports need is stored in a database (MySQL). The reports must be returned either as a easily printable html document, or a pdf file. I have previously used jaspe...
stackoverflow-qa
# Re-ordering entries in a model using drag-and-drop ## Question Say I have a blogging app in Django. How can i re-order the posts using a draggable table in the default admin? It would be best if i didn't have to add any extra fields to the model, but if i really have to i can. ## Answer In model class you would pr...
stackoverflow-qa
# Re-ordering entries in a model using drag-and-drop ## Question Say I have a blogging app in Django. How can i re-order the posts using a draggable table in the default admin? It would be best if i didn't have to add any extra fields to the model, but if i really have to i can. ## Answer Note on the "It would be be...
stackoverflow-qa
# Re-ordering entries in a model using drag-and-drop ## Question Say I have a blogging app in Django. How can i re-order the posts using a draggable table in the default admin? It would be best if i didn't have to add any extra fields to the model, but if i really have to i can. ## Answer For working code to do this...
stackoverflow-qa
# Re-ordering entries in a model using drag-and-drop ## Question Say I have a blogging app in Django. How can i re-order the posts using a draggable table in the default admin? It would be best if i didn't have to add any extra fields to the model, but if i really have to i can. ## Answer There's a nice package for ...
stackoverflow-qa
# Dirty fields in django ## Question In my app i need to save changed values (old and new) when model gets saved. Any examples or working code? I need this for premoderation of content. For example, if user changes something in model, then administrator can see all changes in separate table and then decide to apply t...
stackoverflow-qa
# Dirty fields in django ## Question In my app i need to save changed values (old and new) when model gets saved. Any examples or working code? I need this for premoderation of content. For example, if user changes something in model, then administrator can see all changes in separate table and then decide to apply t...
stackoverflow-qa
# Dirty fields in django ## Question In my app i need to save changed values (old and new) when model gets saved. Any examples or working code? I need this for premoderation of content. For example, if user changes something in model, then administrator can see all changes in separate table and then decide to apply t...
stackoverflow-qa
# Dirty fields in django ## Question In my app i need to save changed values (old and new) when model gets saved. Any examples or working code? I need this for premoderation of content. For example, if user changes something in model, then administrator can see all changes in separate table and then decide to apply t...
stackoverflow-qa
# Dirty fields in django ## Question In my app i need to save changed values (old and new) when model gets saved. Any examples or working code? I need this for premoderation of content. For example, if user changes something in model, then administrator can see all changes in separate table and then decide to apply t...
stackoverflow-qa
# Dirty fields in django ## Question In my app i need to save changed values (old and new) when model gets saved. Any examples or working code? I need this for premoderation of content. For example, if user changes something in model, then administrator can see all changes in separate table and then decide to apply t...
stackoverflow-qa
# Dirty fields in django ## Question In my app i need to save changed values (old and new) when model gets saved. Any examples or working code? I need this for premoderation of content. For example, if user changes something in model, then administrator can see all changes in separate table and then decide to apply t...
stackoverflow-qa
# Dirty fields in django ## Question In my app i need to save changed values (old and new) when model gets saved. Any examples or working code? I need this for premoderation of content. For example, if user changes something in model, then administrator can see all changes in separate table and then decide to apply t...
stackoverflow-qa
# Close a tkinter window? ## Question How do I end a Tkinter program? Let's say I have this code: from Tkinter import * def quit(): # code to exit root = Tk() Button(root, text="Quit", command=quit).pack() root.mainloop() How should I define the quit function? ## Answer We can use: def quit(): root.quit...
stackoverflow-qa
# Close a tkinter window? ## Question How do I end a Tkinter program? Let's say I have this code: from Tkinter import * def quit(): # code to exit root = Tk() Button(root, text="Quit", command=quit).pack() root.mainloop() How should I define the quit function? ## Answer The usual method to exit a Python prog...
stackoverflow-qa
# Close a tkinter window? ## Question How do I end a Tkinter program? Let's say I have this code: from Tkinter import * def quit(): # code to exit root = Tk() Button(root, text="Quit", command=quit).pack() root.mainloop() How should I define the quit function? ## Answer import Tkinter as tk def quit(root): ...
stackoverflow-qa
# Close a tkinter window? ## Question How do I end a Tkinter program? Let's say I have this code: from Tkinter import * def quit(): # code to exit root = Tk() Button(root, text="Quit", command=quit).pack() root.mainloop() How should I define the quit function? ## Answer root.quit() Above line just Bypasses...
stackoverflow-qa
# Close a tkinter window? ## Question How do I end a Tkinter program? Let's say I have this code: from Tkinter import * def quit(): # code to exit root = Tk() Button(root, text="Quit", command=quit).pack() root.mainloop() How should I define the quit function? ## Answer I think you wrongly understood the qui...
stackoverflow-qa
# How do I handle the window close event in Tkinter? ## Question How do I handle the window close event (user clicking the 'X' button) in a Python Tkinter program? ## Answer Tkinter supports a mechanism called protocol handlers. Here, the term protocol refers to the interaction between the application and the window ...
stackoverflow-qa
# How do I handle the window close event in Tkinter? ## Question How do I handle the window close event (user clicking the 'X' button) in a Python Tkinter program? ## Answer Matt has shown one classic modification of the close button. The other is to have the close button minimize the window. You can reproduced this ...
stackoverflow-qa
# What is a "callable" in Python? ## Question Now that it's clear what a metaclass is, there is an associated concept that I use all the time without knowing what it really means. I suppose everybody made once a mistake with parenthesis, resulting in an "object is not callable" exception. What's more, using __init_...
stackoverflow-qa
# What is a "callable" in Python? ## Question Now that it's clear what a metaclass is, there is an associated concept that I use all the time without knowing what it really means. I suppose everybody made once a mistake with parenthesis, resulting in an "object is not callable" exception. What's more, using __init_...
stackoverflow-qa
# What is a "callable" in Python? ## Question Now that it's clear what a metaclass is, there is an associated concept that I use all the time without knowing what it really means. I suppose everybody made once a mistake with parenthesis, resulting in an "object is not callable" exception. What's more, using __init_...
stackoverflow-qa
# What is a "callable" in Python? ## Question Now that it's clear what a metaclass is, there is an associated concept that I use all the time without knowing what it really means. I suppose everybody made once a mistake with parenthesis, resulting in an "object is not callable" exception. What's more, using __init_...
stackoverflow-qa
# What is a "callable" in Python? ## Question Now that it's clear what a metaclass is, there is an associated concept that I use all the time without knowing what it really means. I suppose everybody made once a mistake with parenthesis, resulting in an "object is not callable" exception. What's more, using __init_...
stackoverflow-qa
# What is a "callable" in Python? ## Question Now that it's clear what a metaclass is, there is an associated concept that I use all the time without knowing what it really means. I suppose everybody made once a mistake with parenthesis, resulting in an "object is not callable" exception. What's more, using __init_...
stackoverflow-qa
# What is a "callable" in Python? ## Question Now that it's clear what a metaclass is, there is an associated concept that I use all the time without knowing what it really means. I suppose everybody made once a mistake with parenthesis, resulting in an "object is not callable" exception. What's more, using __init_...
stackoverflow-qa
# What is a "callable" in Python? ## Question Now that it's clear what a metaclass is, there is an associated concept that I use all the time without knowing what it really means. I suppose everybody made once a mistake with parenthesis, resulting in an "object is not callable" exception. What's more, using __init_...
stackoverflow-qa
# What is a "callable" in Python? ## Question Now that it's clear what a metaclass is, there is an associated concept that I use all the time without knowing what it really means. I suppose everybody made once a mistake with parenthesis, resulting in an "object is not callable" exception. What's more, using __init_...
stackoverflow-qa
# How do I find out the size of a canvas item in Python/Tkinter? ## Question I want to create some text in a canvas: myText = self.canvas.create_text(5, 5, anchor=NW, text="TEST") Now how do I find the width and height of myText? ## Answer bounds = self.canvas.bbox(myText) # returns a tuple like (x1, y1, x2, y2) ...
stackoverflow-qa
# How do I find out the size of a canvas item in Python/Tkinter? ## Question I want to create some text in a canvas: myText = self.canvas.create_text(5, 5, anchor=NW, text="TEST") Now how do I find the width and height of myText? ## Answer This method seemed to work well if all you are interested in is the width ...
stackoverflow-qa
# Is there any way to do HTTP PUT in python ## Question I need to upload some data to a server using HTTP PUT in python. From my brief reading of the urllib2 docs, it only does HTTP POST. Is there any way to do an HTTP PUT in python? ## Answer Have you taken a look at put.py? I've used it in the past. You can also ju...
stackoverflow-qa
# Is there any way to do HTTP PUT in python ## Question I need to upload some data to a server using HTTP PUT in python. From my brief reading of the urllib2 docs, it only does HTTP POST. Is there any way to do an HTTP PUT in python? ## Answer You can of course roll your own with the existing standard libraries at an...
stackoverflow-qa
# Is there any way to do HTTP PUT in python ## Question I need to upload some data to a server using HTTP PUT in python. From my brief reading of the urllib2 docs, it only does HTTP POST. Is there any way to do an HTTP PUT in python? ## Answer You should have a look at the httplib module. It should let you make what...
stackoverflow-qa
# Is there any way to do HTTP PUT in python ## Question I need to upload some data to a server using HTTP PUT in python. From my brief reading of the urllib2 docs, it only does HTTP POST. Is there any way to do an HTTP PUT in python? ## Answer import urllib2 opener = urllib2.build_opener(urllib2.HTTPHandler) request ...
stackoverflow-qa
# Is there any way to do HTTP PUT in python ## Question I need to upload some data to a server using HTTP PUT in python. From my brief reading of the urllib2 docs, it only does HTTP POST. Is there any way to do an HTTP PUT in python? ## Answer I needed to solve this problem too a while back so that I could act as a c...
stackoverflow-qa
# Is there any way to do HTTP PUT in python ## Question I need to upload some data to a server using HTTP PUT in python. From my brief reading of the urllib2 docs, it only does HTTP POST. Is there any way to do an HTTP PUT in python? ## Answer I also recommend httplib2 by Joe Gregario. I use this regularly instead o...
stackoverflow-qa
# Is there any way to do HTTP PUT in python ## Question I need to upload some data to a server using HTTP PUT in python. From my brief reading of the urllib2 docs, it only does HTTP POST. Is there any way to do an HTTP PUT in python? ## Answer Httplib seems like a cleaner choice. import httplib connection = httplib...
stackoverflow-qa
# Is there any way to do HTTP PUT in python ## Question I need to upload some data to a server using HTTP PUT in python. From my brief reading of the urllib2 docs, it only does HTTP POST. Is there any way to do an HTTP PUT in python? ## Answer I've used a variety of python HTTP libs in the past, and I've settled on '...
stackoverflow-qa
# Is there any way to do HTTP PUT in python ## Question I need to upload some data to a server using HTTP PUT in python. From my brief reading of the urllib2 docs, it only does HTTP POST. Is there any way to do an HTTP PUT in python? ## Answer You can use the requests library, it simplifies things a lot in comparison...
stackoverflow-qa
# Using Python's ftplib to get a directory listing, portably ## Question You can use ftplib for full FTP support in Python. However the preferred way of getting a directory listing is: # File: ftplib-example-1.py import ftplib ftp = ftplib.FTP("www.python.org") ftp.login("anonymous", "ftplib-example-1") data = [] ...
stackoverflow-qa