content stringlengths 85 101k | title stringlengths 0 150 | question stringlengths 15 48k | answers list | answers_scores list | non_answers list | non_answers_scores list | tags list | name stringlengths 35 137 |
|---|---|---|---|---|---|---|---|---|
Q:
Specifying python interpreter from virtualenv in emacs
Today I've been trying to bring more of the Python related modes into
my Emacs configuration but I haven't had much luck.
First what I've noticed is that depending on how Emacs is
launched (terminal vs from the desktop), the interpreter it decides to
use is di... | Specifying python interpreter from virtualenv in emacs | Today I've been trying to bring more of the Python related modes into
my Emacs configuration but I haven't had much luck.
First what I've noticed is that depending on how Emacs is
launched (terminal vs from the desktop), the interpreter it decides to
use is different.
launched from KDE menu: M-! which python gives /us... | [
"So it seems that python-shell does the right thing by picking up the environment settings, whereas py-shell does not. python-shell is provided by python.el and py-shell is provided by python-mode.el , There's bug reports etc related to this, so I'm just not going to use py-shell for now. Figured I'd close the loop... | [
8,
4
] | [] | [] | [
"emacs",
"python",
"virtualenv"
] | stackoverflow_0002303956_emacs_python_virtualenv.txt |
Q:
Python Vertical Array Slicing
Can anyone show me how to slice the structure below:
[[1, A], [2, B], [3,C]]
Into two separate lists:
[1, 2, 3]
[A, B, C]
I can obviously do this using code, but wondered if Python was able to do it natively?
A:
my_list = [[1, A], [2, B], [3, C]]
a, b = zip(*my_list)
Note that a ... | Python Vertical Array Slicing | Can anyone show me how to slice the structure below:
[[1, A], [2, B], [3,C]]
Into two separate lists:
[1, 2, 3]
[A, B, C]
I can obviously do this using code, but wondered if Python was able to do it natively?
| [
"my_list = [[1, A], [2, B], [3, C]]\na, b = zip(*my_list)\n\nNote that a and b will end up being tuples.\n"
] | [
13
] | [] | [] | [
"python"
] | stackoverflow_0006253586_python.txt |
Q:
Pass arguments to Zope browser page
In my Zope instance, I have a Python script registered as a browser page. I have the following code as its registry:
<browser:page name="test" for="*" permission="zope2.Public" class="browser.test.PyTest" attribute="CallPy" />
This function, "PyTest.CallPy" is defined as:
def C... | Pass arguments to Zope browser page | In my Zope instance, I have a Python script registered as a browser page. I have the following code as its registry:
<browser:page name="test" for="*" permission="zope2.Public" class="browser.test.PyTest" attribute="CallPy" />
This function, "PyTest.CallPy" is defined as:
def CallPy(self, data): ...
I then use JavaScr... | [
"You're missing rather a lot of detail on your method. Is it a method of a class? Or standalone? Normally, self would refer to an instance of the class PyTest - which would be a subclass of BrowserView.\nThen, the data you pass to the view (@@test) is retrieved from the Request object, which is available in self.... | [
3
] | [] | [] | [
"parameter_passing",
"python",
"zope"
] | stackoverflow_0006253541_parameter_passing_python_zope.txt |
Q:
How can I store data to a data dictionary in Python when headings are in mixed up order
I'd like to store the following data in a data dictionary so that I can easily export it to a CSV file. The problem is that the columns for each school id are not always in the same order:
text = """
school id= 28392
name|year... | How can I store data to a data dictionary in Python when headings are in mixed up order | I'd like to store the following data in a data dictionary so that I can easily export it to a CSV file. The problem is that the columns for each school id are not always in the same order:
text = """
school id= 28392
name|year|degree|age|race
Susan A. Smith|2007|PhD|27|white
Fred Collins|2006|PhD|26|hispanic
Amber Rea... | [
"This actually seems pretty easy. Process the file into a data structure, then export it into a csv.\nschool = None\nheaders = None\ndata = {}\nfor line in text.splitlines():\n if line.startswith(\"school id\"):\n school = line.split('=')[1].strip()\n headers = None\n continue\n if school... | [
6
] | [] | [] | [
"csv",
"dictionary",
"export_to_csv",
"python"
] | stackoverflow_0006253617_csv_dictionary_export_to_csv_python.txt |
Q:
Python access remote printer over socket connection
Have been asked to print to a remote printer via a socket connection, and struggling with how to approach this. I'm already passing data back and forth to a computer on the same network (also via a socket connection), and generating a PDF and/or HTML file with it... | Python access remote printer over socket connection | Have been asked to print to a remote printer via a socket connection, and struggling with how to approach this. I'm already passing data back and forth to a computer on the same network (also via a socket connection), and generating a PDF and/or HTML file with it when necessary. The idea is for me to send that file fro... | [
"I am not sure that this is a good idea.\nIf I understand the question correctly, this is about printing from a web application. I suggest the users simply use the browser's built-in print function for printing the generated HTML (or the PDF reader's in the case of PDFs).\nUPDATE\nIf you need to automatically print... | [
1
] | [] | [] | [
"printing",
"python",
"sockets"
] | stackoverflow_0006253311_printing_python_sockets.txt |
Q:
Invoking shell script from a python script using root privileges
I'm trying to invoke a shell script shell_script.sh from a python script (python_script.py) using the call command. The shell_script.sh invokes a executable that requires root access to execute.
The python_script.py invokes shell_script.sh using su... | Invoking shell script from a python script using root privileges | I'm trying to invoke a shell script shell_script.sh from a python script (python_script.py) using the call command. The shell_script.sh invokes a executable that requires root access to execute.
The python_script.py invokes shell_script.sh using subprocess.call().
See below:
subprocess.call(['/complete_path/shell_s... | [
"I'd put logic in the python_script.py to check its UID and fail if is not executed as root. if os.getuid() != 0:. That will ensure it only runs as root, ether by a root login, or sudo.\nIf you're getting permission denied when trying to execute the python_script.py, you need to set the execute bit on it. chmod +... | [
1
] | [] | [] | [
"linux",
"python",
"root",
"shell",
"sudo"
] | stackoverflow_0006253613_linux_python_root_shell_sudo.txt |
Q:
Python socket-module: How to change the local port on the client side?
I want to get packages from a network using TCP/IP as a client.
With ...
connect((TCP_IP, TCP_PORT))
... I can change the port of the peer address. But I change the port of my local computer?
EDIT: I want to use a network card with four ports... | Python socket-module: How to change the local port on the client side? | I want to get packages from a network using TCP/IP as a client.
With ...
connect((TCP_IP, TCP_PORT))
... I can change the port of the peer address. But I change the port of my local computer?
EDIT: I want to use a network card with four ports. The network card is connected to a measurement device which sends a lot of... | [
"Assume you have a socket named sock... use socket.bind()\nimport socket\nsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\nDESTINATION_ADDR = '1.1.1.1'\nSOURCE_PORT, DESTINATION_PORT = 31415, 80\nsock.bind(('0.0.0.0', SOURCE_PORT))\nsock.connect((DESTINATION_ADDR, DESTINATION_PORT))\n\nNow I run tshark (te... | [
12,
2,
0
] | [] | [] | [
"networking",
"port",
"python",
"sockets",
"tcp"
] | stackoverflow_0006250198_networking_port_python_sockets_tcp.txt |
Q:
problem: Getting to the element by using CSS selectors attribute 'style' with selenium
I'm having trouble getting to the element using the 'style' attribute with selenium. The problem is that using xpath selectors I am able to do it:
int(self.selenium.get_element_index("//div[contains(@class,'%s')][contains(@style... | problem: Getting to the element by using CSS selectors attribute 'style' with selenium | I'm having trouble getting to the element using the 'style' attribute with selenium. The problem is that using xpath selectors I am able to do it:
int(self.selenium.get_element_index("//div[contains(@class,'%s')][contains(@style,'%s')][contains(@style,'%s')]"%(pin_class_name,map_object_position[0],map_object_position[1... | [
"I did extensive experimentation comparing and contrasting XPath, CSS, and DOM locators for Selenium and found that while one can access the style attribute from XPath or DOM, one cannot from CSS (just as you surmised). You can find that tidbit (see Footnote 2), along with my complete analysis, in my quick referenc... | [
3,
0
] | [] | [] | [
"css_selectors",
"python",
"selenium",
"xpath"
] | stackoverflow_0006242149_css_selectors_python_selenium_xpath.txt |
Q:
Python tkinter Entry widget displays bar characters instead of line breaks
I'm coding a very simple Python Tkinter GUI to drive a command-line python script.
My GUI will run on a Windows host and I want it to display the multi-line plain-text output of the script, which is returned to the GUI as a string containin... | Python tkinter Entry widget displays bar characters instead of line breaks |
I'm coding a very simple Python Tkinter GUI to drive a command-line python script.
My GUI will run on a Windows host and I want it to display the multi-line plain-text output of the script, which is returned to the GUI as a string containing - of course - line breaks (\n characters).
So, I put a Text widget into the G... | [
"It could be an issue of '\\r' characters before each '\\n' character (you said you're on Windows).\nBefore updating the widget, try first:\ntext_output= text_output.replace('\\r', '')\n\n(text_output contains the output of your script, whose contents are to be inserted in the widget)\nIf you give us more informati... | [
3,
0,
0,
0
] | [] | [] | [
"character_encoding",
"python",
"tkinter",
"user_interface"
] | stackoverflow_0006250718_character_encoding_python_tkinter_user_interface.txt |
Q:
Are there tools, for analyzing python code?
I am looking for a tool to analyze my python script. For example
which part of the code takes the most time
which part of the code consumes too much memory
and so on...
Is there something like that?
A:
Python has a built-in profiler
There are various memory profiler... | Are there tools, for analyzing python code? | I am looking for a tool to analyze my python script. For example
which part of the code takes the most time
which part of the code consumes too much memory
and so on...
Is there something like that?
| [
"\nPython has a built-in profiler \nThere are various memory profilers for Python\n\n",
"Take a look at cProfile. Here's a usage example:\nme@mine:~ $ cat foo.py \ndef double(i):\n return i * 2\n\ndef halve(i):\n return i / 2.0\n\nfor i in range(10000):\n double(i)\n halve(i)\nme@mine:~ $ python -m cP... | [
5,
3,
0
] | [] | [] | [
"code_analysis",
"python"
] | stackoverflow_0006246543_code_analysis_python.txt |
Q:
How to format a MySQL query into JSON using webpy?
I am trying to query a MySQL database using webpy. From the SQL query, I get the following.
<Storage {'title': u'Learn web.py', 'done': 0, 'id': 0L, 'mytime': datetime.datetime(2011, 5, 30, 10, 53, 9)}>
I tried to serialize the data using json.dumps(data) into JS... | How to format a MySQL query into JSON using webpy? | I am trying to query a MySQL database using webpy. From the SQL query, I get the following.
<Storage {'title': u'Learn web.py', 'done': 0, 'id': 0L, 'mytime': datetime.datetime(2011, 5, 30, 10, 53, 9)}>
I tried to serialize the data using json.dumps(data) into JSON format, however I get an error indicating that the da... | [
"You can extend json.JSONEncoder to handle dates:\nI've not tested this using the Storage object as an argument, but as you say it works when there's no date in the query, I think this should work. (See the json module docs for information about extending the encoder object).\nimport datetime, json\n\nclass Extende... | [
1,
0
] | [] | [] | [
"json",
"mysql",
"python",
"web.py"
] | stackoverflow_0006182967_json_mysql_python_web.py.txt |
Q:
How can I layer images in PyQt using QGraphicsScene and QGraphicsView
Let's say I have two images, image A and image B. Using QGraphicsScene and QGraphicsView, how can I draw image A to the background, and layer image B on top of image A?
Thanks in advance.
A:
If you have QGraphicsItems that you draw your imag... | How can I layer images in PyQt using QGraphicsScene and QGraphicsView | Let's say I have two images, image A and image B. Using QGraphicsScene and QGraphicsView, how can I draw image A to the background, and layer image B on top of image A?
Thanks in advance.
| [
"If you have QGraphicsItems that you draw your images on you can use setZValue to set custom stack order.\nIf you only need background on the scene you can take advantage of scene layers, for example use backgroundBrush to change the background and then draw other things on top of that.\n"
] | [
3
] | [] | [] | [
"pyqt",
"python",
"qgraphicsscene",
"qgraphicsview"
] | stackoverflow_0006254038_pyqt_python_qgraphicsscene_qgraphicsview.txt |
Q:
Testing for specific method in a Python class
What is the best (or 'Pythonic') way to test if a class has a specific method defined?
Both of these work but don't feel 'correct' in that in the second one, I just try to access it and trap for an exception if it doesn't exist.
Is there a better / more correct way?
... | Testing for specific method in a Python class | What is the best (or 'Pythonic') way to test if a class has a specific method defined?
Both of these work but don't feel 'correct' in that in the second one, I just try to access it and trap for an exception if it doesn't exist.
Is there a better / more correct way?
class TestClass(object):
def TestFunc(self):
... | [
"Use hasattr:\nclass Foo(object):\n def bar():\n pass\n\nassert hasattr(Foo, 'bar')\n\nIf you really mean to test whether the attribute is a method, you could do this:\nassert hasattr(Foo, 'bar') and callable(getattr(Foo, 'bar'))\n\n",
"You're close.\nIt's Easier to Ask Forgiveness than to Ask Permissio... | [
10,
3
] | [] | [] | [
"class",
"methods",
"oop",
"python"
] | stackoverflow_0006254586_class_methods_oop_python.txt |
Q:
How To Deploy PyS60 Apps To The Ovi Store?
I'm developing some PyS60 applications and today I've seen that it's possible to deploy them to the Ovi Store according to the Release Notes(Discussion Thread too):
All the Pyds that have zero UID will be assigned with the applications UID at the time of packaging.
As ... | How To Deploy PyS60 Apps To The Ovi Store? | I'm developing some PyS60 applications and today I've seen that it's possible to deploy them to the Ovi Store according to the Release Notes(Discussion Thread too):
All the Pyds that have zero UID will be assigned with the applications UID at the time of packaging.
As a result, Python applications can now be symbia... | [
"Sorry, i ask so many time to add Python as an authorized Language for OVI. But the only answer i got, is that to not loose developper they focus their store on One language. App can be signed, but they will probably not accept them\n"
] | [
1
] | [] | [] | [
"ovi",
"pys60",
"python",
"s60",
"symbian"
] | stackoverflow_0006136844_ovi_pys60_python_s60_symbian.txt |
Q:
Python GTK window in Thread
I have a CLI application, which is digging some data, in case of need, fires up a thread which creates GTK window with some information. However the CLI (main thread) still analyzes the data in the background, so there could be numerous windows created. In case I close the window, the d... | Python GTK window in Thread | I have a CLI application, which is digging some data, in case of need, fires up a thread which creates GTK window with some information. However the CLI (main thread) still analyzes the data in the background, so there could be numerous windows created. In case I close the window, the destroy event is actually fired up... | [
"using a gtk.threads_enter() and leave around your main call should help.\nTake a look at the PyGtk Faq : PyGtk FAQ\n"
] | [
1
] | [] | [] | [
"pygtk",
"python"
] | stackoverflow_0006212171_pygtk_python.txt |
Q:
Python / Django implementation without previous experience with this syntax
I am a Web Developer that has a client that would like to have Django implemented into their next interface.
Having never been taught these two languages before, (Python & Django) I took it upon myself to go over the tutorials from start t... | Python / Django implementation without previous experience with this syntax | I am a Web Developer that has a client that would like to have Django implemented into their next interface.
Having never been taught these two languages before, (Python & Django) I took it upon myself to go over the tutorials from start to finish on djangoprojects page. Now I am a visual learner and need more. The sco... | [
"For python, you should take a look at DiveIntoPython.\nRegarding Django, you should take a lookt at :\n\nThe Django Tutorial (what you did, if I understood correctly)\nThe Django book\n\nAnd I believe that taking a look at how Django works by reading the source code is very interesting, for both your learning in p... | [
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006255188_django_python.txt |
Q:
How can I write data from a dictionary to a CSV file in Python
I have the following data in a dictionary:
{'323503': [{'name': 'Derek', 'age': '21', 'race': 'white'}, {'name': 'Josh', 'age': '15', 'race': 'white'}, {'name': 'Adam', 'age': '32', 'weight': '180'}],
'3802': [{'name': 'Abe', 'age': '12', 'weight': '1... | How can I write data from a dictionary to a CSV file in Python | I have the following data in a dictionary:
{'323503': [{'name': 'Derek', 'age': '21', 'race': 'white'}, {'name': 'Josh', 'age': '15', 'race': 'white'}, {'name': 'Adam', 'age': '32', 'weight': '180'}],
'3802': [{'name': 'Abe', 'age': '12', 'weight': '132', 'race': 'black'}, {'name': 'Amy', 'age': '31', 'weight': '180'}... | [
"First, transform your structure in a list of dictionaries.\nSomething like this (maybe in a more compact fashion):\ndata = {'323503': [{'name': 'Derek', 'age': '21', 'race': 'white'}, {'name': 'Josh', 'age': '15', 'race': 'white'}, {'name': 'Adam', 'age': '32', 'weight': '180'}],\n '3802': [{'name': 'Abe', ... | [
3
] | [] | [] | [
"csv",
"dictionary",
"python"
] | stackoverflow_0006254957_csv_dictionary_python.txt |
Q:
Find names of positional arguments through introspection
Is there a way to figure out the names of the positional arguments to a python function?
def foo(arg1, arg2):
pass
f=foo
# How do I find out want the 1st argument to f is called? I want 'arg1' as an answer
A:
The function inspect.getargspec() does what ... | Find names of positional arguments through introspection | Is there a way to figure out the names of the positional arguments to a python function?
def foo(arg1, arg2):
pass
f=foo
# How do I find out want the 1st argument to f is called? I want 'arg1' as an answer
| [
"The function inspect.getargspec() does what you need in Python 2.\nIn Python 3, this has been deprecated, and you should instead use signature.\n"
] | [
12
] | [] | [] | [
"python"
] | stackoverflow_0006255284_python.txt |
Q:
PyMongo error while running on Windows
I just installed pymongo from an .exe on a windows 7 box. I tried connecting to mongodb by:
import pymongo
c = pymongo.Connection()
i get the following error:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
c = pymongo.Connection()
File "E:\Sof... | PyMongo error while running on Windows | I just installed pymongo from an .exe on a windows 7 box. I tried connecting to mongodb by:
import pymongo
c = pymongo.Connection()
i get the following error:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
c = pymongo.Connection()
File "E:\Softwares\installed\Python2.7\lib\site-packages... | [
"Go to http://www.mongodb.org/downloads to download the version of mongodb for your operating system.\nUnzip the downloaded folder. \nRun the file mongod.exe. (This is in the \"bin\" folder)\nYou should now be able to connect using pymongo.\n"
] | [
2
] | [] | [] | [
"daemon",
"mongodb",
"pymongo",
"python",
"windows"
] | stackoverflow_0006255316_daemon_mongodb_pymongo_python_windows.txt |
Q:
using method as function in python
Say I have a list of strings, and I want to filter out all non-upper case strings. Is there a simpler way than doing filter(lambda x: x.isupper(), list)?
A:
While I would prefer a list comprehension, this seems to be what you're looking for:
filter(str.isupper, list)
A:
upper... | using method as function in python | Say I have a list of strings, and I want to filter out all non-upper case strings. Is there a simpler way than doing filter(lambda x: x.isupper(), list)?
| [
"While I would prefer a list comprehension, this seems to be what you're looking for:\nfilter(str.isupper, list)\n\n",
"uppers = [s for s in list if s.isupper()]\n\n"
] | [
10,
5
] | [] | [] | [
"function",
"methods",
"python"
] | stackoverflow_0006255789_function_methods_python.txt |
Q:
python regex question, ? op
in the following examples, i am trying to craft a regex to find the last group of 1 or more consecutive digits in a line.
as far as i know, in python3, re.search() goes through the search string trying to match from left to right.
does that explain the behavior in the examples below? S... | python regex question, ? op | in the following examples, i am trying to craft a regex to find the last group of 1 or more consecutive digits in a line.
as far as i know, in python3, re.search() goes through the search string trying to match from left to right.
does that explain the behavior in the examples below? Specifically, is that the reason w... | [
"\n^.*(\\d+) - Match from the start. .* will match all the way to the end of the line, and then \\d+ will make .* backtrack (cancel previous matches), as little as needed, so \\d+ will only match the last digit.\n^.*?(\\d+) - Match from the start. .*? matches nothing at first. \\d+ will fail later (if the first cha... | [
4,
3,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0006255606_python_regex.txt |
Q:
Multiple Domain and Multi Directory in the same Django App
I am trying to support a quite complex architecture with mixed multiple domains and multiple directory in the same django application. Basically, we'll have urls like this :
http://www.firstdomains.com/(DJANGO_APP)
http://www.firstdomains.com/de/(DJANGO_AP... | Multiple Domain and Multi Directory in the same Django App | I am trying to support a quite complex architecture with mixed multiple domains and multiple directory in the same django application. Basically, we'll have urls like this :
http://www.firstdomains.com/(DJANGO_APP)
http://www.firstdomains.com/de/(DJANGO_APP)
http://www.other.com/esp/best/(DJANGO_APP)
http://www.complex... | [
"You are in luck! Carl Meyer recently released the perfect app for you: django-hosts\nIf for some reason the URL parts don't work for you try also adding one of the apps that do URL i18n/l10n such as http://pypi.python.org/pypi/transurlvania\n"
] | [
4
] | [] | [] | [
"django",
"multiple_domains",
"python"
] | stackoverflow_0006251428_django_multiple_domains_python.txt |
Q:
Python GTK menu item takes two clicks to activate
Alright, first off I'm not quite sure how to phrase my problem. This could be lack of sleep, or being pretty new to Python and GTK, or a combination. To aid me, I have written a complete bare-bones example with the help of zetcode.com's tutorials.
The problem, as w... | Python GTK menu item takes two clicks to activate | Alright, first off I'm not quite sure how to phrase my problem. This could be lack of sleep, or being pretty new to Python and GTK, or a combination. To aid me, I have written a complete bare-bones example with the help of zetcode.com's tutorials.
The problem, as well as I can put it, is a menu item - with no sub-menus... | [
"You can solve your problem by connecting to the 'button-press-event' signal instead of the 'activate' signal, and making your callback like this:\ndef on_file_activate(self, widget, event):\n if event.button != 1:\n return False #only intercept left mouse button\n md = gtk.MessageDialog(self, gtk.DIA... | [
2,
2
] | [] | [] | [
"gtk",
"python"
] | stackoverflow_0004169811_gtk_python.txt |
Q:
Order by dig-like rating in django
I've got two models:
class Post(models.Model):
#some fields
pass
class Vote(models.Model):
post = mdoels.ForeignKey(Post)
value = models.IntegerField()
Votes' value can be either 1 or -1 (user can vote up or down).
How can i get a list of posts, ordered by their... | Order by dig-like rating in django | I've got two models:
class Post(models.Model):
#some fields
pass
class Vote(models.Model):
post = mdoels.ForeignKey(Post)
value = models.IntegerField()
Votes' value can be either 1 or -1 (user can vote up or down).
How can i get a list of posts, ordered by their rating?
| [
"You have to use annotation. https://docs.djangoproject.com/en/dev/topics/db/aggregation/\nclass Post(models.Model): \n name = models.CharField(max_length=20)\n\nclass Vote(models.Model):\n post = models.ForeignKey(Post)\n value = models.IntegerField()\n type = models.CharField(max_length=2, ch... | [
2,
0
] | [] | [] | [
"django",
"python",
"rating_system"
] | stackoverflow_0006255591_django_python_rating_system.txt |
Q:
Pyside QProcess Need Help
NOTE: class MyWindow(QWidget):
In init
self.proc = QtCore.QProcess(self)
self.te = QTextEdit(self)
self.btn = QPushButton("Execute", self)
self.btn.clicked.connect(self.__event_btn)
Now I have this:
def __event_btn(self):
w_dir = "" # This set to my working directory where my C fi... | Pyside QProcess Need Help | NOTE: class MyWindow(QWidget):
In init
self.proc = QtCore.QProcess(self)
self.te = QTextEdit(self)
self.btn = QPushButton("Execute", self)
self.btn.clicked.connect(self.__event_btn)
Now I have this:
def __event_btn(self):
w_dir = "" # This set to my working directory where my C files are
args = ["-o", "MyF... | [
"You need to ensure that the program (gcc in this case) runs with stdout unbuffered. Most console applications buffer unless writing to a console (cmd.exe or terminal) since that improves performance. Presumably the internal streams used by Qt to buffer the QProcess' output are not seen as ttys, which is why you ge... | [
3
] | [] | [] | [
"pyside",
"python",
"qprocess"
] | stackoverflow_0006234687_pyside_python_qprocess.txt |
Q:
Unable to connect to SQL Server via pymssql
I am attempting to connect to SQL Server running on Windows XP system from a *nix system on a local server via pymssql. However, the connection fails as shown below
db = pymssql.connect(host='192.168.1.102',user='www',password='test',database='TestDB')
Traceback (most r... | Unable to connect to SQL Server via pymssql | I am attempting to connect to SQL Server running on Windows XP system from a *nix system on a local server via pymssql. However, the connection fails as shown below
db = pymssql.connect(host='192.168.1.102',user='www',password='test',database='TestDB')
Traceback (most recent call last):
File "<stdin>", line 1, in <mo... | [
"Got it! I think the source of the problem was not giving Free TDS the attention it needs. Free TDS is apparently the driver behind pymssql and provides for connectivity to other databases - SQL Server being one of them.\nThe freetds.conf file is located in /usr/local/etc on my system (Mac Book Pro).\nThis file co... | [
14,
2,
0
] | [] | [] | [
"pymssql",
"python"
] | stackoverflow_0004150524_pymssql_python.txt |
Q:
Write to a Remote file with Fabric
I am trying to backup databases and move them around to different servers using Fabric.
When on a remote server, to open a file for writing it fails with the error.
newFile = open('%s%s' % (dumpPath,newFileName) ,'w')
IOError: [Errno 2] No such file or directory: '/home/ec2-user... | Write to a Remote file with Fabric | I am trying to backup databases and move them around to different servers using Fabric.
When on a remote server, to open a file for writing it fails with the error.
newFile = open('%s%s' % (dumpPath,newFileName) ,'w')
IOError: [Errno 2] No such file or directory: '/home/ec2-user/dbbackup.sql.bz2'
That files exists, a... | [
"In Fabric, you are never \"on a remote server\". Some Fabric commands run locally, and some run on the remote server. In this case, you are using Python's open function, which tries to open the file on your local computer, and understandably fails. You can use Fabric's put and get functions to move files between ... | [
7,
5,
0
] | [] | [] | [
"fabric",
"python"
] | stackoverflow_0006237514_fabric_python.txt |
Q:
Python 3.2 - Concatenate and string formatting behavior not behaving as expected
I want to create a "full file name" variable from several other variables, but the string concatenation and string format operations aren't behaving the way I expect.
My code is below:
file_date = str(input("Enter file date: "))
ro... | Python 3.2 - Concatenate and string formatting behavior not behaving as expected | I want to create a "full file name" variable from several other variables, but the string concatenation and string format operations aren't behaving the way I expect.
My code is below:
file_date = str(input("Enter file date: "))
root_folder = "\\\\SERVER\\FOLDER\\"
file_prefix = "sample_file_"
file_extension = ".txt... | [
"I think the method input used in your example, like so:\nfile_date = str(input(\"Enter file date: \"))\n\nmay be returning a carriage return character at the end.\nThis causes the cursor to go back to the start of the line when you try to print it out.\nYou may want to trim the return value of input().\n",
"Use ... | [
8,
3
] | [] | [] | [
"python",
"python_3.x",
"string_concatenation",
"string_formatting"
] | stackoverflow_0006256369_python_python_3.x_string_concatenation_string_formatting.txt |
Q:
Python toprettyxml() formatting problems
I'm trying to process XML using Python's minidom, and then output the result using toprettyxml(). I ran into two problems:
There are added blank lines.
There are added newlines and tabs for text nodes.
Here's the code and output:
$ cat test.py
from xml.dom import minidom... | Python toprettyxml() formatting problems | I'm trying to process XML using Python's minidom, and then output the result using toprettyxml(). I ran into two problems:
There are added blank lines.
There are added newlines and tabs for text nodes.
Here's the code and output:
$ cat test.py
from xml.dom import minidom
dom = minidom.parse("test.xml")
print dom.to... | [
"One solution is to patch minidom Library with the proposed patch to the bug you mention.\nI haven't tested myself, a bit hacky too, so it may not suit you!\n"
] | [
2
] | [] | [] | [
"python",
"xml"
] | stackoverflow_0006256336_python_xml.txt |
Q:
Yet another Python variable scope question
I have the following code:
>>> def f(v=1):
... def ff():
... print v
... v = 2
... ff()
...
>>> f()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 5, in f
File "<stdin>", line 3, in ff
Unbo... | Yet another Python variable scope question | I have the following code:
>>> def f(v=1):
... def ff():
... print v
... v = 2
... ff()
...
>>> f()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 5, in f
File "<stdin>", line 3, in ff
UnboundLocalError: local variable 'v' referenced bef... | [
"In Python 3.x, you can use nonlocal:\ndef f(v=1):\n def ff():\n nonlocal v\n print(v)\n v = 2\n ff()\n\nIn Python 2.x, there is no easy solution. A hack is to make v a list:\ndef f(v=None):\n if v is None:\n v = [1]\n def ff():\n print v[0]\n v[0] = 2\n ff(... | [
6,
1
] | [] | [] | [
"python",
"scope",
"variables"
] | stackoverflow_0006256537_python_scope_variables.txt |
Q:
scipy.sparse default value
The sparse matrix format (dok) assumes that values of keys not in the dictionary are equal to zero. Is there any way to make it use a default value other than zero?
Also, is there a way to calculate the log of a sparse matrix (akin to np.log in regular numpy matrix)
A:
That feature is ... | scipy.sparse default value | The sparse matrix format (dok) assumes that values of keys not in the dictionary are equal to zero. Is there any way to make it use a default value other than zero?
Also, is there a way to calculate the log of a sparse matrix (akin to np.log in regular numpy matrix)
| [
"That feature is not built-in, but if you really need this, you should be able to write your own dok_matrix class, or subclass Scipy's one. The Scipy implementation is here. At least in the places where dict.* calls are made, the default value needs to be changed --- and maybe there are some other changes that need... | [
8
] | [] | [] | [
"python",
"scipy",
"sparse_matrix"
] | stackoverflow_0006256206_python_scipy_sparse_matrix.txt |
Q:
converting text size into data coordinates
In matplotlib, what is a way of converting the text box size into data coordinates?
For example, in this toy script I'm fine-tuning the coordinates of the text box so that it's next to a data point.
#!/usr/bin/python
import matplotlib.pyplot as plt
xx=[1,2,3]
yy=[2,3,... | converting text size into data coordinates | In matplotlib, what is a way of converting the text box size into data coordinates?
For example, in this toy script I'm fine-tuning the coordinates of the text box so that it's next to a data point.
#!/usr/bin/python
import matplotlib.pyplot as plt
xx=[1,2,3]
yy=[2,3,4]
dy=[0.1,0.2,0.05]
fig=plt.figure()
ax=fig.ad... | [
"Generally speaking, you can't get the size of the text until after it's drawn (thus the hacks in @DSM's answer).\nFor what you're wanting to do, you'd be far better off using annotate.\nE.g. ax.annotate('Your text string', xy=(x, y), xytext=(x-0.1, y-0.4))\nNote that you can specify the offset in points as well, a... | [
11,
7
] | [] | [] | [
"matplotlib",
"python"
] | stackoverflow_0006251569_matplotlib_python.txt |
Q:
Uninstantiable superclass
So, I'm writing a module for connecting to external account providers (Twitter, Facebook etc) and I have a superclass that is useless on its own, but contains generic methods that need to be invoked by the subclasses for persisting auth tokens, getting auth tokens and deauthorizing the pr... | Uninstantiable superclass | So, I'm writing a module for connecting to external account providers (Twitter, Facebook etc) and I have a superclass that is useless on its own, but contains generic methods that need to be invoked by the subclasses for persisting auth tokens, getting auth tokens and deauthorizing the provider. My question is, is the... | [
"class NoInstantiation: # \"class NoInstantiation(object):\" in Python 2.2+ or whatever\n def __new__(cls):\n \"This class is not meant to be instantiated, so __new__ returns None.\"\n return None\n\nThis won't stop people from overriding that functionality if they want to, but it should be a fa... | [
7,
7,
7,
4
] | [] | [] | [
"python",
"superclass"
] | stackoverflow_0006256603_python_superclass.txt |
Q:
Python equivalent of C#'s .Select?
I've got an list of objects in Python, and they each have an id property. I want to get a list of those IDs.
In C# I'd write
myObjects.Select(obj => obj.id);
How would I do this in Python?
A:
Check out the section on "List Comprehension" here: http://docs.python.org/tutorial/d... | Python equivalent of C#'s .Select? | I've got an list of objects in Python, and they each have an id property. I want to get a list of those IDs.
In C# I'd write
myObjects.Select(obj => obj.id);
How would I do this in Python?
| [
"Check out the section on \"List Comprehension\" here: http://docs.python.org/tutorial/datastructures.html\nIf your starting list is called original_list and your new list is called id_list, you could do something like this:\nid_list = [x.id for x in original_list]\n\n",
"[obj.id for obj in myObjects]\n\n",
"If... | [
20,
14,
7,
4,
1
] | [] | [] | [
"c#",
"enumerable",
"linq",
"python"
] | stackoverflow_0004261486_c#_enumerable_linq_python.txt |
Q:
Python's list comprehension vs .NET LINQ
The following simple LINQ code
string[] words = { "hello", "wonderful", "linq", "beautiful", "world" };
// Get only short words
var shortWords =
from word in words
where word.Length <= 5
select word;
// Print each word out
shortWords.Dump();
can be translated into... | Python's list comprehension vs .NET LINQ | The following simple LINQ code
string[] words = { "hello", "wonderful", "linq", "beautiful", "world" };
// Get only short words
var shortWords =
from word in words
where word.Length <= 5
select word;
// Print each word out
shortWords.Dump();
can be translated into python using list comprehension as follows.
w... | [
"(Warning: Mammoth answer ahead. The part up to the first horizontal line makes a good tl;dr section, I suppose)\nI'm not sure if I qualify as Python guru... but I have a solid grasp on iteration in Python, so let's try :)\nFirst off: Afaik, LINQ queries are executed lazily - if that's the case, generator expressio... | [
59,
25,
17,
4
] | [] | [] | [
"c#",
"linq",
"list_comprehension",
"python"
] | stackoverflow_0003925093_c#_linq_list_comprehension_python.txt |
Q:
Comparison with unicode string in if-condition (python)
Possible Duplicate:
Python '==' vs 'is' comparing strings, 'is' fails sometimes, why?
I am going to skip the part where i tell you how i tested my code and jump straight to the problem.
Python seems to be having some problem matching split of a unicode stri... | Comparison with unicode string in if-condition (python) |
Possible Duplicate:
Python '==' vs 'is' comparing strings, 'is' fails sometimes, why?
I am going to skip the part where i tell you how i tested my code and jump straight to the problem.
Python seems to be having some problem matching split of a unicode string to another inline unicode string in an if statement.
>>>... | [
"It's because strings are objects in Python --- when you slice a string, you create a new one.\nIt's slightly more complicated than that, but that's the gist of it.\nSolution: use == and != instead of is and is not.\n"
] | [
2
] | [] | [] | [
"if_statement",
"python",
"unicode_string"
] | stackoverflow_0006257616_if_statement_python_unicode_string.txt |
Q:
Python builtin operator extension
I create a subclass of float called aF, which contains extra informations and methods. I need to create operations on this class, and in particular I need to be able to compute the product of a normal float with this aF.
How can I extend the * operator of the float, so that a floa... | Python builtin operator extension | I create a subclass of float called aF, which contains extra informations and methods. I need to create operations on this class, and in particular I need to be able to compute the product of a normal float with this aF.
How can I extend the * operator of the float, so that a float*an augmentedFloat returns an augmente... | [
"Let's assume f is a float and af is an AugmentedFloat. To make both the multiplications af * f and f * af work, you have to overwrite the __mul__() and __rmul__() methods. You don't need to add any methods to the built-in float type -- that's not even possible in Python.\n"
] | [
2
] | [] | [] | [
"operator_keyword",
"operator_overloading",
"python"
] | stackoverflow_0006257621_operator_keyword_operator_overloading_python.txt |
Q:
Wxpython - how to generate a series of text prompts without closing the app?
I have a text box in wxpython (see below) that stores the name of the value as a variable.
I am trying to do two things:
After the answer is entered, I want to display another question, and assign the new answer to another variable, using... | Wxpython - how to generate a series of text prompts without closing the app? | I have a text box in wxpython (see below) that stores the name of the value as a variable.
I am trying to do two things:
After the answer is entered, I want to display another question, and assign the new answer to another variable, using the same or an idential TextEntryDialog window.
Ideally, from a user standpoint, ... | [
"I don't recommend creating and destroying 250 dialogs like the other fellow did. I would probably create a list or dict at the beginning of my program that would get appended to whenever the user enters an answer. Also in that event handler, I would reset the StaticText control with a new question. You might need ... | [
3,
1
] | [] | [] | [
"python",
"wxpython"
] | stackoverflow_0006256818_python_wxpython.txt |
Q:
Program to factorize a number into two smaller prime numbers
I have a very big number, and I want to make a program, that finds two prime numbers, that will give the original number, if multiplied.
Ex.
Original_number = 299
// The program should get these two numbers:
q = 13
p = 23
The program runs fine at the ... | Program to factorize a number into two smaller prime numbers | I have a very big number, and I want to make a program, that finds two prime numbers, that will give the original number, if multiplied.
Ex.
Original_number = 299
// The program should get these two numbers:
q = 13
p = 23
The program runs fine at the start, but at a certain point, it just stops, and I'm not sure wha... | [
"Just factorize a number. You'll get a list of prime factors. If the list contains exactly two numbers, and the numbers are good for your purposes, you won. Else try another number.\nBut the approach above is quite wasteful. I'd rather take a list of primes, generate all pairs of it and multiply. The result would b... | [
3,
2,
1,
1,
0
] | [] | [] | [
"primes",
"python"
] | stackoverflow_0006254078_primes_python.txt |
Q:
incremental output with subprocess.PIPE
I am using subprocess module for running commands from another app I know that you are able to do the following
import subprocess
app = subprocess(args, stdout=subprocess.PIPE)
out, err = app.communicate()
print out
I would like the output to be displayed as it happening ... | incremental output with subprocess.PIPE | I am using subprocess module for running commands from another app I know that you are able to do the following
import subprocess
app = subprocess(args, stdout=subprocess.PIPE)
out, err = app.communicate()
print out
I would like the output to be displayed as it happening as supposed to one big blob at the end. Ideas... | [
"The problem may be that the command you are running in the subprocess buffers its output: in which case, in Blender's answer, the process.stdout.read(1) would not return until the output buffer of the subprocess filled up, causing it to be flushed, and thus seen by the parent process.\nSee this answer and this one... | [
6,
2
] | [] | [] | [
"python",
"stdout",
"subprocess"
] | stackoverflow_0006257800_python_stdout_subprocess.txt |
Q:
how can I make a Django model form with a field name in the form different from the model field name?
I have a model and a form like this:
class Content(models.Model):
title = models.CharField(_("title"), max_length=16)
category = models.ForeignKey(Category, verbose_name = _('category'))
class ContentForm... | how can I make a Django model form with a field name in the form different from the model field name? | I have a model and a form like this:
class Content(models.Model):
title = models.CharField(_("title"), max_length=16)
category = models.ForeignKey(Category, verbose_name = _('category'))
class ContentForm(forms.ModelForm):
class Meta:
model=Content
fields = ('title', 'category', )
I would ... | [
"Your comment reveals what you actually need to do - this is why you should always describe your actual problem, not your proposed solution. Naturally, there is a proper way to deal with two identical forms on the same page in Django - use the prefix parameter when instantiating the field.\nform1 = MyForm(prefix='f... | [
5,
1
] | [] | [] | [
"django",
"django_forms",
"django_models",
"python"
] | stackoverflow_0006256402_django_django_forms_django_models_python.txt |
Q:
python: What's the rationale behind not allowing * in relative imports?
What's the rationale behind not allowing * in relative imports? e.g.
from ..new_tool import *
or doing a relative import directly:
import ..new_tool
A:
The reason the latter is prohibited is that ..new_tool is not usable in an expression (P... | python: What's the rationale behind not allowing * in relative imports? | What's the rationale behind not allowing * in relative imports? e.g.
from ..new_tool import *
or doing a relative import directly:
import ..new_tool
| [
"The reason the latter is prohibited is that ..new_tool is not usable in an expression (PEP 328):\n\nThe reason import .foo is prohibited\n is because after\n import XXX.YYY.ZZZ\n\nthen XXX.YYY.ZZZ is usable in an\n expression. But\n .moduleY\n\nis not usable in an\n expression.\n\nSince *-imports should o... | [
7
] | [] | [] | [
"python",
"python_packaging",
"relative_path"
] | stackoverflow_0006257995_python_python_packaging_relative_path.txt |
Q:
Copying files from temporary internet cache in python
I'm copying files from the temporary internet files cache into a folder, in bulk using a python script. Using shutil to copy the full path to the os.cwd, it comes up with this error:
builtins.IOError: [Errno 22] Invalid argument:
'C:\\Users\\NICK\\AppData\\(... | Copying files from temporary internet cache in python | I'm copying files from the temporary internet files cache into a folder, in bulk using a python script. Using shutil to copy the full path to the os.cwd, it comes up with this error:
builtins.IOError: [Errno 22] Invalid argument:
'C:\\Users\\NICK\\AppData\\(no whitespace in path; only for readability)
Local\\Microso... | [
"There is a backslash at the end of your file name so it is maybe treated as a path.\n"
] | [
1
] | [] | [] | [
"python",
"shutil"
] | stackoverflow_0006258064_python_shutil.txt |
Q:
Convert hash.digest() to unicode
import hashlib
string1 = u'test'
hashstring = hashlib.md5()
hashstring.update(string1)
string2 = hashstring.digest()
unicode(string2)
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8f in position 1: ordinal
not in range(128)
The string HAS to be unicode for it to be any u... | Convert hash.digest() to unicode | import hashlib
string1 = u'test'
hashstring = hashlib.md5()
hashstring.update(string1)
string2 = hashstring.digest()
unicode(string2)
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8f in position 1: ordinal
not in range(128)
The string HAS to be unicode for it to be any use to me, can this be done?
Using pyth... | [
"Ignacio just gave the perfect answer. Just a complement: when you convert some string from an encoding which has chars not found in ASCII to unicode, you have to pass the encoding as a parameter:\n>>> unicode(\"órgão\")\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nUnicodeDecodeErro... | [
21,
13
] | [] | [] | [
"python",
"unicode",
"unicode_string"
] | stackoverflow_0006257647_python_unicode_unicode_string.txt |
Q:
Run all Tests in Directory Using Testoob
I'm looking for a Python testing framework that would allow me to type one command and run all tests in a certain directory. I've been using Testoob and, so far, I've been able to figure out how to run all the tests in a suite. But I can't figure out how to run an entire di... | Run all Tests in Directory Using Testoob | I'm looking for a Python testing framework that would allow me to type one command and run all tests in a certain directory. I've been using Testoob and, so far, I've been able to figure out how to run all the tests in a suite. But I can't figure out how to run an entire directory of test suites. Is this even possible ... | [
"nose lets you do precisely that.\ncd path/to/project\nnosetests\n\n"
] | [
0
] | [] | [] | [
"frameworks",
"python",
"testing"
] | stackoverflow_0006258181_frameworks_python_testing.txt |
Q:
In python how can I iterate through a string splitting it at different spots as I go?
I'm trying to write a quick solve for Kaprekar number's to show a friend of mine how easy it is to implement something like this in Python. I know how to do all the steps except for iterating through the squared number as a strin... | In python how can I iterate through a string splitting it at different spots as I go? | I'm trying to write a quick solve for Kaprekar number's to show a friend of mine how easy it is to implement something like this in Python. I know how to do all the steps except for iterating through the squared number as a string. For example 45 is a Kaprekar number because
45 ** 2 = 2025 and 20 + 25 = 45
What I'm try... | [
">>> s = '2025'\n>>> for i in range(1, len(s)):\n... print s[:i], s[i:]\n... \n2 025\n20 25\n202 5\n\n",
"I will spend a couple of extra days in purgatory for answering a math question already answered by Ignacio, but you may also experiment with some variant of:\n>>> a = 2025\n>>> for i in range(1,4):\n... ... | [
7,
1
] | [] | [] | [
"math",
"python",
"string"
] | stackoverflow_0006258091_math_python_string.txt |
Q:
Pythonic get element of array or default if it doesn't exist
We have
matches = re.findall(r'somewhat', 'somewhere')
Can we simplify this
if len(matches) > index:
return matches[index]
else:
return 'default'
or
return matches[index] if len(mathes) > index else 'default'
to something similar to JS's
retur... | Pythonic get element of array or default if it doesn't exist | We have
matches = re.findall(r'somewhat', 'somewhere')
Can we simplify this
if len(matches) > index:
return matches[index]
else:
return 'default'
or
return matches[index] if len(mathes) > index else 'default'
to something similar to JS's
return matches[index] || 'default'
that we can simply use
return 'some... | [
"Something like this might help:\n>>> reg = re.compile('-\\d+-')\n>>> reg.findall('a-23-b-12-c') or ['default']\n['-23-', '-12-']\n>>> reg.findall('a-b-c') or ['default']\n['default']\n\nEdit\nUgly one-liner\n(reg.findall('a-b-c')[index:] or ['default'])[0]\n\n",
"I'd be tempted to use a try except block. You'd b... | [
4,
1,
0
] | [] | [] | [
"default",
"element",
"list",
"python"
] | stackoverflow_0006258081_default_element_list_python.txt |
Q:
Bizarre inconsistent python ImportError - possible circular dependency?
I'm trying to refactor some python code and I'm stuck with an import error I don't understand. I suspect there might be a circular dependency somewhere but I don't see it, and I'm not getting much in the way of hints from the error messages. ... | Bizarre inconsistent python ImportError - possible circular dependency? | I'm trying to refactor some python code and I'm stuck with an import error I don't understand. I suspect there might be a circular dependency somewhere but I don't see it, and I'm not getting much in the way of hints from the error messages. The codebase is large, but there are two modules of interest here:
radian/mo... | [
"Any module in the datalayer folder (including radian.py), when it sees from radian, will assume that datalayer/radian.py is the relevant module. You might need to do\nfrom __future__ import absolute_import\n\nin datalayer/radian.py and other similarly affected modules, and then check all your imports to ensure tha... | [
1
] | [] | [] | [
"import",
"python"
] | stackoverflow_0006257394_import_python.txt |
Q:
No output from QProcess
Why does the following print a blank line instead of 'Hello QProcess'?
import sys
from PyQt4 import QtGui, QtCore
proc = QtCore.QProcess()
proc.start("echo 'Hello QProcess'")
proc.waitForFinished()
result = proc.readAll()
print result
proc.close()
I'm on Windows XP, btw.
A:
Because the... | No output from QProcess | Why does the following print a blank line instead of 'Hello QProcess'?
import sys
from PyQt4 import QtGui, QtCore
proc = QtCore.QProcess()
proc.start("echo 'Hello QProcess'")
proc.waitForFinished()
result = proc.readAll()
print result
proc.close()
I'm on Windows XP, btw.
| [
"Because there's no program called \"echo\".\nIf you wanted to run this through the shell then you should have used \"cmd /C echo Hello QProcess\".\nYour program also has no error checking. If you'd checked for errors properly the mistake would have been easier to spot.\n",
"You should provide system environment... | [
2,
0
] | [] | [] | [
"pyqt",
"python",
"qprocess",
"qt",
"windows"
] | stackoverflow_0001851930_pyqt_python_qprocess_qt_windows.txt |
Q:
Help re.search python length
Is it possible to read the length of re.search's output?
For example:
import re
list=['lost','post','cross','help','cost']
for i in range(len(list)):
output = re.search('os', list[i])
Can I read output length?
A:
In this case, the output length will be the same as the input leng... | Help re.search python length | Is it possible to read the length of re.search's output?
For example:
import re
list=['lost','post','cross','help','cost']
for i in range(len(list)):
output = re.search('os', list[i])
Can I read output length?
| [
"In this case, the output length will be the same as the input length, because you're searching for a specific substring. When you search in 'lost', the length of the match will be 2, because that's what the length of the search parameter is. Now if you want to differentiate between \"found\" and \"not found\", rem... | [
2,
2,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0006258758_python_regex.txt |
Q:
UnicodeWarning when comparing unicode strings to unicode results from os.walk command
Using python 2.7 I'm doing an os.walk with these files http://www.2shared.com/file/biSx7NI-/comer.html and then comparing the result against an array. In the actual program this array won't be predefined. The code that I am tryin... | UnicodeWarning when comparing unicode strings to unicode results from os.walk command | Using python 2.7 I'm doing an os.walk with these files http://www.2shared.com/file/biSx7NI-/comer.html and then comparing the result against an array. In the actual program this array won't be predefined. The code that I am trying to use is as follows
# -*- coding: utf-8 -*-
import os.path
group = ['comer.txt', 'coma.t... | [
"Have you tried (note the 'u' before the string, which turns it to Unicode):\nfor(path, dirs, files) in os.walk(u\"C:/corpus/zz-auto generated/spanish/comer\"):\n(note that having back-slashes in a string is not a good idea, Unicode or not).\n"
] | [
1
] | [] | [] | [
"os.walk",
"python",
"python_2.7",
"unicode",
"utf_8"
] | stackoverflow_0006258632_os.walk_python_python_2.7_unicode_utf_8.txt |
Q:
Representing a network in Python
I have a vertices such as dic = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'n':6, 'm':7, 'g':8} and i have two columns as follows represent the relationship between the vertices :
a a
b d
e f
c f
n f
m g
I want to associate each vertex in the first column with the correspond... | Representing a network in Python | I have a vertices such as dic = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'n':6, 'm':7, 'g':8} and i have two columns as follows represent the relationship between the vertices :
a a
b d
e f
c f
n f
m g
I want to associate each vertex in the first column with the corresponding vertex in the second column by an ... | [
"See: https://www.python.org/doc/essays/graphs/\ngraph = {\n 'a' : [ 'a' ],\n 'b' : [ 'd' ],\n 'c' : [ 'f' ],\n 'd' : [],\n 'e' : [ 'f' ],\n 'f' : [],\n 'g' : [],\n 'm' : [ 'g' ],\n 'n' : [ 'f' ]\n}\n\nprint [ vertex for vertex, edges in graph.items() if 'f' in edges ]\n\nEDIT:\nOk, it s... | [
5,
0
] | [] | [] | [
"graph_theory",
"python"
] | stackoverflow_0006258494_graph_theory_python.txt |
Q:
remotely start Python program in background
I need to use fabfile to remotely start some program in remote boxes from time to time, and get the results. Since the program takes a long while to finish, I wish to make it run in background and so I dont need to wait. So I tried os.fork() to make it work. The problem ... | remotely start Python program in background | I need to use fabfile to remotely start some program in remote boxes from time to time, and get the results. Since the program takes a long while to finish, I wish to make it run in background and so I dont need to wait. So I tried os.fork() to make it work. The problem is that when I ssh to the remote box, and run the... | [
"If I understand your question right, I think you're making this far too complicated. os.fork() is for multiprocessing, not for running a program in the background.\nLet's say for the sake of discussion that you wanted to run program.sh and collect what it sends to standard output. To do this with fabric, create ... | [
4,
2
] | [] | [] | [
"fork",
"python",
"python_daemon",
"shelve"
] | stackoverflow_0006243933_fork_python_python_daemon_shelve.txt |
Q:
Python Minesweeper game with GUI using Tkinter How to display on buttons correctly?
I am creating a minesweeper game in python 2.7. I have run into several problems when attempting to create the GUI. I have used a library called easyGUI (found here: http://easygui.sourceforge.net/) for some of the basic setup wind... | Python Minesweeper game with GUI using Tkinter How to display on buttons correctly? | I am creating a minesweeper game in python 2.7. I have run into several problems when attempting to create the GUI. I have used a library called easyGUI (found here: http://easygui.sourceforge.net/) for some of the basic setup windows, but that is not my problem. The issue is with the actual minesweeper window itself. ... | [
"You can change the text on a button with the configure method of the button (eg: b1.configure(text=\"whatever\")). You do not need to recreate the whole window with each update. Just create the buttons once and change the text or image as needed.\nFor example, change your button definition to look like this:\nb = ... | [
2
] | [] | [] | [
"button",
"minesweeper",
"python",
"tkinter",
"user_interface"
] | stackoverflow_0006259027_button_minesweeper_python_tkinter_user_interface.txt |
Q:
using python nltk to find similarity between two web pages?
I want to find whether two web pages are similar or not. Can someone suggest if python nltk with wordnet similarity functions helpful and how? What is the best similarity function to be used in this case?
A:
The spotsigs paper mentioned by joyceschan ad... | using python nltk to find similarity between two web pages? | I want to find whether two web pages are similar or not. Can someone suggest if python nltk with wordnet similarity functions helpful and how? What is the best similarity function to be used in this case?
| [
"The spotsigs paper mentioned by joyceschan addresses content duplication detection and it contains plenty of food for thought. \nIf you are looking for a quick comparison of key terms, nltk standard functions might suffice. \nWith nltk you can pull synonyms of your terms by looking up the synsets contained by Word... | [
14,
1
] | [] | [] | [
"nlp",
"nltk",
"python",
"wordnet"
] | stackoverflow_0006252236_nlp_nltk_python_wordnet.txt |
Q:
Docstrings in C extensions to Python?
When creating a C extension to Python, is it possible to be able to somehow write comments that are exposed as docstrings to users of the extension?
A:
Docstrings for types can be included as the tp_doc member in the PyTypeObject structure, see an example in the docs.
Docst... | Docstrings in C extensions to Python? | When creating a C extension to Python, is it possible to be able to somehow write comments that are exposed as docstrings to users of the extension?
| [
"Docstrings for types can be included as the tp_doc member in the PyTypeObject structure, see an example in the docs.\nDocstrings for functions can be included in the ml_doc field of the module's method table. If you want your docstrings to be \"physically close\" to the actual functions, you could include string ... | [
20
] | [] | [] | [
"cpython",
"python",
"python_c_extension"
] | stackoverflow_0006259114_cpython_python_python_c_extension.txt |
Q:
Set value of a string without setting it to str type?
I'm looking for a way to set a string's value without changing the type of the string.
class testStr(str):
myattr = ""
# this works fine.
t = testStr("testing")
t.myattr = "Yay!"
print "String value is: '" + t + "' and its attr is set to '" + t.myattr + "... | Set value of a string without setting it to str type? | I'm looking for a way to set a string's value without changing the type of the string.
class testStr(str):
myattr = ""
# this works fine.
t = testStr("testing")
t.myattr = "Yay!"
print "String value is: '" + t + "' and its attr is set to '" + t.myattr + "'"
# obviously once this is done the type of t goes back t... | [
"The statement t = \"whatever\" doesn't \"change the value contained by t\", but rather it rebinds t to a different object. If you want to change t then you must mutate it instead via an attribute, either by assigning to an attribute or by calling a method.\n",
"The problem (which you've figured out) is that t is... | [
2,
1,
0,
0
] | [] | [] | [
"python",
"setvalue",
"string"
] | stackoverflow_0006258842_python_setvalue_string.txt |
Q:
XOR ciphering works *most* of the time
I've been tasked with password-protecting a Java app with minimal concern for real security. So it seemed sensible to store username/password pairs in a text file and then encrypt it. For the encryption, it seemed appropriate to use XOR ciphers because they're easy and fast (... | XOR ciphering works *most* of the time | I've been tasked with password-protecting a Java app with minimal concern for real security. So it seemed sensible to store username/password pairs in a text file and then encrypt it. For the encryption, it seemed appropriate to use XOR ciphers because they're easy and fast (remember--it just has to discourage the casu... | [
"You are trying to store binary in text mode file. Use open(file, \"wb\") for writing and open(file, \"rb\") for reading to open file in binary mode and fix an issue.\nIn text mode every \"\\r\", \"\\n\" and \"\\r\\n\" sequences are treated as newlines so they are converted into your local OS line ending convention... | [
1,
0,
0
] | [] | [] | [
"encryption",
"python",
"xor"
] | stackoverflow_0006259194_encryption_python_xor.txt |
Q:
Data via jQuery AJAX to Pyramid backend woes
So, I'm trying to post the value of an element with an id of "AltTitle" via AJAX back to a Pyramid backend. With the code below, Python receives a request.param of AlternativeTitle. That's it. No value. I'm stuck. I want to learn how to build a dictionary of AJAX d... | Data via jQuery AJAX to Pyramid backend woes | So, I'm trying to post the value of an element with an id of "AltTitle" via AJAX back to a Pyramid backend. With the code below, Python receives a request.param of AlternativeTitle. That's it. No value. I'm stuck. I want to learn how to build a dictionary of AJAX data so I can then pass all values back to Python, ... | [
"Ok, it seems that the {} are causing the issue. This could be because the jQuery is inside a Jinja2 template, but even adding {% raw %} didn't change the outcome. By changing the script to:\ndata:\"AlternativeTitle:\" + alttitle + '&' \"othervalue\" + otherval,\n\nI got the serialized version at the server. I am y... | [
1,
0,
0
] | [] | [] | [
"ajax",
"jquery",
"pyramid",
"python"
] | stackoverflow_0006254230_ajax_jquery_pyramid_python.txt |
Q:
How do I add a header to urllib2 opener?
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.open('http://abc.com')
opener.open('http://google.com')
As you can see, I use opener to visit different websites, using a cookie jar. Can I set a header so that each time a... | How do I add a header to urllib2 opener? | cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.open('http://abc.com')
opener.open('http://google.com')
As you can see, I use opener to visit different websites, using a cookie jar. Can I set a header so that each time a website is it, the header is applied?
| [
"You can add the headers directly to the OpenerDirector object returned by build_opener. From the last example in the urllib2 docs:\n\nOpenerDirector automatically adds a User-Agent header to every Request. To change this:\n\nimport urllib2\nopener = urllib2.build_opener()\nopener.addheaders = [('User-agent', 'Mozi... | [
62,
18
] | [] | [] | [
"header",
"http",
"python",
"urllib2"
] | stackoverflow_0006259489_header_http_python_urllib2.txt |
Q:
sqlalchemy bind values
I want to get the value of a parameter in a sqlalchemy query object dynamically:
q = session.query(Model).filter(Model.foo = 6)
I now want to be able to retrieve the value 6 from q
assert(q.magic == 6)
Attempts:
print(q._criterion) # -> models.foo = :foo_1
But where is the value of foo_1?... | sqlalchemy bind values | I want to get the value of a parameter in a sqlalchemy query object dynamically:
q = session.query(Model).filter(Model.foo = 6)
I now want to be able to retrieve the value 6 from q
assert(q.magic == 6)
Attempts:
print(q._criterion) # -> models.foo = :foo_1
But where is the value of foo_1?
| [
"SQLAlchemy generates a tree structure from your filter predicates, appending each leaf on as appropriate and putting the result in Query._criterion. You can explore this with the get_children() method of various ClauseElement and ColumnElement classes. \nFor Model.foo == 6 you'll end up with something like this:... | [
14
] | [] | [] | [
"python",
"sqlalchemy"
] | stackoverflow_0006258562_python_sqlalchemy.txt |
Q:
Why is '362' > 378?
Possible Duplicate:
How does Python compare string and int?
An intern was just asking me to help debug code that looked something like this:
widths = [image.width for image in images]
widths.append(374)
width = max(widths)
...when the first line should have been:
widths = [int(image.width) f... | Why is '362' > 378? |
Possible Duplicate:
How does Python compare string and int?
An intern was just asking me to help debug code that looked something like this:
widths = [image.width for image in images]
widths.append(374)
width = max(widths)
...when the first line should have been:
widths = [int(image.width) for image in images]
Thu... | [
"Python 2.x compares every built-in type to every other. From the docs:\n\nObjects of different types, except different numeric types and different string types, never compare equal; such objects are ordered consistently but arbitrarily (so that sorting a heterogeneous array yields a consistent result).\n\nThis \"... | [
11,
6,
0
] | [] | [] | [
"comparison",
"integer",
"python",
"string"
] | stackoverflow_0006259623_comparison_integer_python_string.txt |
Q:
How to unzip a zip file in django , which contains .shp , .prj , .shx and .dbf , thus being able to upload in the database?
I have uploaded a zip file using django in a local directory . How do I unzip it , and store it in 3 different files ?
Ok . Let me explain my problem a bit more in detail .
def upload(reques... | How to unzip a zip file in django , which contains .shp , .prj , .shx and .dbf , thus being able to upload in the database? | I have uploaded a zip file using django in a local directory . How do I unzip it , and store it in 3 different files ?
Ok . Let me explain my problem a bit more in detail .
def upload(request):
if request.method == 'POST':
form = UploadForm(request.POST, request.FILES)
if form.is_valid():
... | [
"It doesnt look like you're actually opening the upload, but a file in the current directory called 'file_obj'. You want something more like \nz = zipfile.ZipFile(request.FILES['file_obj'])\n\nalso I might be wrong, but i don't think you need the form.handle() call at all, at least I've never used it, but i might s... | [
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006256039_django_python.txt |
Q:
Best script to modify file contents on server
Problem:
I have web server that was recently compromised. They targeted javascript files. They inserted the following snippet
document.write('<iframe src="http://lcbmc.co.uk/showthread.php?t=31540750" width="1" height="1" frameborder="0"></iframe>')
this was added to... | Best script to modify file contents on server | Problem:
I have web server that was recently compromised. They targeted javascript files. They inserted the following snippet
document.write('<iframe src="http://lcbmc.co.uk/showthread.php?t=31540750" width="1" height="1" frameborder="0"></iframe>')
this was added to the top of every single .js file on the server.
So... | [
"sed -i '1d;' *.js\n\nsimple, and will delete the first line from every javascript file. \nyou could do it a bit more throughly in python, but you said 1st line in every *.js file, no?\nbetter yet, you could consider perl\npython would work, but a Python soultion isn't a garbbled quick one-liner\nand for something ... | [
5,
4,
2,
1
] | [] | [] | [
"bash",
"perl",
"python",
"scripting",
"sed"
] | stackoverflow_0006259521_bash_perl_python_scripting_sed.txt |
Q:
Handling multiple windows in PyGTK/GtkBuilder
How can I store multiple different windows/dialogs in a single GtkBuilder file and then load these windows in different classes (each class corresponding to a different window)? For instance, currently I'm doing things like:
def __init__(self):
self.builder = gtk.B... | Handling multiple windows in PyGTK/GtkBuilder | How can I store multiple different windows/dialogs in a single GtkBuilder file and then load these windows in different classes (each class corresponding to a different window)? For instance, currently I'm doing things like:
def __init__(self):
self.builder = gtk.Builder()
self.builder.add_from_file('gtkbuilder... | [
"Using gtk.Builder.add_from_file adds the entire hierarchy from your file to the Builder object, which is why you're getting the signal connection warnings; the builder.connect_signals() call tries to connect up everything.\nInstead, use gtk.Builder.add_objects_from_file to choose the individual top-level window or... | [
7
] | [] | [] | [
"glade",
"gtkbuilder",
"pygtk",
"python"
] | stackoverflow_0006259089_glade_gtkbuilder_pygtk_python.txt |
Q:
python script does not run from cron
I have a python script "start.py" that executes well from the command line. There is only one statement in it (print "hello"). EDIT: start.py contains also a working interpreter directive in the first line.
As soon as I run the script from a cron job, every time it fires there ... | python script does not run from cron | I have a python script "start.py" that executes well from the command line. There is only one statement in it (print "hello"). EDIT: start.py contains also a working interpreter directive in the first line.
As soon as I run the script from a cron job, every time it fires there is a message in syslog:
Jun 7 02:57:01 mi... | [
"A recent update of PAM broke cron. Try restarting your computer (or restarting cron with sudo /etc/init.d/cron restart)\n",
"You forgot to add python in front of it.\n* * * * * mit /usr/bin/python /home/mit/dev/start.py\n\n"
] | [
3,
0
] | [] | [] | [
"cron",
"pam",
"python",
"ubuntu",
"ubuntu_10.04"
] | stackoverflow_0006259674_cron_pam_python_ubuntu_ubuntu_10.04.txt |
Q:
Python parsing large text files and capturing multi-level data
First let me appologize if my description of this is completely retarded, still learning most of this on-the-fly.
I have several large text-files (.txt) (~600,000 lines) of general hospital information, which I'm parsing with python. I have been using ... | Python parsing large text files and capturing multi-level data | First let me appologize if my description of this is completely retarded, still learning most of this on-the-fly.
I have several large text-files (.txt) (~600,000 lines) of general hospital information, which I'm parsing with python. I have been using default dicts (python2.7) to get counts and sub-counts one level dee... | [
"You can generalise the concept of hierarchic counts to get clearer code that is easier to modify. A basic example of an hierachic counter class is\nclass HierarchicCounter(object):\n def __init__(self, key, hierarchy):\n self.key = key\n self.hierarchy = hierarchy\n self.counts = defaultdi... | [
5,
2,
0
] | [] | [] | [
"parsing",
"python"
] | stackoverflow_0006258531_parsing_python.txt |
Q:
ExpatError: not well-formed (invalid token)
please consider this code:
import xml.etree.ElementTree as ET
import urllib
XML_response = urllib.urlopen('http://www.navlost.eu/aero/metar/?icao=LWSK&dt0=2011-05-03+12%3A00%3A00&c=1&rt=metar').read()
tree = ET.fromstring(XML_response)
Which raises this error:
--------... | ExpatError: not well-formed (invalid token) | please consider this code:
import xml.etree.ElementTree as ET
import urllib
XML_response = urllib.urlopen('http://www.navlost.eu/aero/metar/?icao=LWSK&dt0=2011-05-03+12%3A00%3A00&c=1&rt=metar').read()
tree = ET.fromstring(XML_response)
Which raises this error:
---------------------------------------------------------... | [
"Double dashes are not valid within comments (other than when ending them). There was a bug filed against Expat with the same issue you have, and they rejected it with a link to the relevant standard.\n"
] | [
2
] | [] | [] | [
"python"
] | stackoverflow_0006260144_python.txt |
Q:
python SocketServer.BaseRequestHandler knowing the port and use the port already opened
This is the code which i played, but each time i make a mistake i can't relaunch it.
It says to me that the port / socket is already used
That's the first question
The second one is in my MyTCPHandler how can i kno the port use... | python SocketServer.BaseRequestHandler knowing the port and use the port already opened | This is the code which i played, but each time i make a mistake i can't relaunch it.
It says to me that the port / socket is already used
That's the first question
The second one is in my MyTCPHandler how can i kno the port used ?
here is my code :
# MetaProject v 0.2
# -*- coding: utf-8 -*-
"""
Thanks to :
People from... | [
"It's actually easier than that -- you can just set it as a class variable, rather than overriding init. E.g.,\nclass MyServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):\n allow_reuse_address = True\n\n",
"Create your SocketServer with bind_and_activate=True in the call to the constructor.\nThen set... | [
11,
3
] | [] | [] | [
"port",
"python",
"sockets",
"socketserver"
] | stackoverflow_0003911009_port_python_sockets_socketserver.txt |
Q:
How to enter the escape characters for telnet programmatically?
I'm using paramiko to ssh into a remote machine, this much seems to be working fine so far
client.connect(hostname, port=ssh_port, username=username, key_filename=key_fname, password=password)
Now from the remote machine I need to go deeper, and usin... | How to enter the escape characters for telnet programmatically? | I'm using paramiko to ssh into a remote machine, this much seems to be working fine so far
client.connect(hostname, port=ssh_port, username=username, key_filename=key_fname, password=password)
Now from the remote machine I need to go deeper, and using
stdin, stdout, stderr = client.exec_command('telnet localhost %d'%... | [
"Finally I've worked it out. \nThe short answer: '\\x1d'\nThat's the escape sequence to bring up the little menu. I found this via curses module:\nfrom curses.ascii import ctrl\nprint ctrl(']')\n\n"
] | [
6
] | [] | [] | [
"escaping",
"paramiko",
"python",
"ssh",
"telnet"
] | stackoverflow_0006248766_escaping_paramiko_python_ssh_telnet.txt |
Q:
Is it possible to code search engine in beautiful Soup
I am using Beautiful Soup for parsing web pages.
Are there any functions in BS which i can use i making search engine or crawling the website to index it in database.
A:
No, BeautifulSoup is not a search engine. It is also not a Swiss Army knife, nor can it... | Is it possible to code search engine in beautiful Soup | I am using Beautiful Soup for parsing web pages.
Are there any functions in BS which i can use i making search engine or crawling the website to index it in database.
| [
"No, BeautifulSoup is not a search engine. It is also not a Swiss Army knife, nor can it make you a sandwich. You will need a database (preferably one that's optimized for search, like Sphinx or Lucene) to do that.\n"
] | [
1
] | [] | [] | [
"beautifulsoup",
"linux",
"python",
"search"
] | stackoverflow_0006260277_beautifulsoup_linux_python_search.txt |
Q:
Using Matplotlib to create a partial multiplication table checkerboard?
My kid is trying to learn his multiplication tables and I was thinking of using matplotlib to create a partially filled out multiplication table for him to practice on. The tricky part is to have the text of the horizontal and vertical axes li... | Using Matplotlib to create a partial multiplication table checkerboard? | My kid is trying to learn his multiplication tables and I was thinking of using matplotlib to create a partially filled out multiplication table for him to practice on. The tricky part is to have the text of the horizontal and vertical axes line up between the tic marks instead of being centered on the tic marks.
Any ... | [
"As everyone has already said, matplotlib is really not the best tool for this... If you really want to do it programatically, generating HTML would honestly be easier. \nThat having been said, it makes a nice example.\nThe easiest way to tweak the axis label positions is to either replace them with text objects o... | [
6
] | [] | [] | [
"matplotlib",
"numpy",
"python"
] | stackoverflow_0006256583_matplotlib_numpy_python.txt |
Q:
Will this eventually lead to a crash (wxpython)
I have over 300 questions/prompts that I plan to include in the program. The flow is pretty much like this:
Create a window with the question.
Store answer in variable.
Create NEW window with question.
Store NEW answer.
this continues on for over 300 questions.
I h... | Will this eventually lead to a crash (wxpython) | I have over 300 questions/prompts that I plan to include in the program. The flow is pretty much like this:
Create a window with the question.
Store answer in variable.
Create NEW window with question.
Store NEW answer.
this continues on for over 300 questions.
I have 2 concerns:
1) Will this eventually lead to a cr... | [
"Holy Cow. You're not really chaining the dialogs like that are you? To try to answer your questions:\n\nWill this eventually lead to a crash: This snippet of code should fail at the first print following someone clicking No. See bullet point #2. There's a lot missing here, I don't see any error handling, no _... | [
3
] | [] | [] | [
"python",
"user_interface",
"wxpython"
] | stackoverflow_0006258810_python_user_interface_wxpython.txt |
Q:
Does anyone know of an open source operations management system?
Hi I dont know if this is the right place to ask... but could someone tell me if there is any open source operations management system available?
My apologies if someone thinks that this is not the right place to ask this...I came across openOMS but ... | Does anyone know of an open source operations management system? | Hi I dont know if this is the right place to ask... but could someone tell me if there is any open source operations management system available?
My apologies if someone thinks that this is not the right place to ask this...I came across openOMS but looks like that project is dead..
Thanks!
| [
"If by operations, you mean \"automated deployment and maintenance of systems\", perhaps you're looking for something like Opscode and their Chef framework. I just happen to have heard of this one, probably there are many others.\n"
] | [
0
] | [] | [] | [
"c",
"java",
"php",
"python"
] | stackoverflow_0006260697_c_java_php_python.txt |
Q:
Django query phone numbers excluding brackets
I am trying to build a django query that filters phone numbers (CharField) but excludes brackets
eg.
if I search for 0123456789 it would find (01) 234 567 89
Thanks
A:
Well, you can either use regex, or you can reformat your search:
pn = '0123456789'
Model.objects.fi... | Django query phone numbers excluding brackets | I am trying to build a django query that filters phone numbers (CharField) but excludes brackets
eg.
if I search for 0123456789 it would find (01) 234 567 89
Thanks
| [
"Well, you can either use regex, or you can reformat your search:\npn = '0123456789'\nModel.objects.filter(phone='(%s) %s %s %s' % (pn[:2], pn[2:5], pn[5:8], pn[8:]))\n\nIdeally you normalize all phone numbers and you'd search for them in that format. If you check out django.contrib.localflavors.us's PhoneNumberFie... | [
3,
0,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006246963_django_python.txt |
Q:
Help with exercise(8-13) for Python Programming by John Zelle
The program seems to work, however the linear regression line created does not seem to really be the line of best fit.
I think the problem is the implementation of the equation. I'm not sure if i'm interpreting it right, also I am unsure if I am doing w... | Help with exercise(8-13) for Python Programming by John Zelle | The program seems to work, however the linear regression line created does not seem to really be the line of best fit.
I think the problem is the implementation of the equation. I'm not sure if i'm interpreting it right, also I am unsure if I am doing what should be done in regards to the last paragraph of the exercise... | [
"I think the problem is that your pointBuild routine adds the point where the user clicks in the \"DONE\" box to the regression list, so every dataset has a point in the lower left. You can confirm this by adding \"print xList, yList\" before pointBuild returns. I would modify the routine to:\nwhile True: # (a co... | [
1
] | [] | [] | [
"python"
] | stackoverflow_0006256382_python.txt |
Q:
Create a list from a long int
I've got a very long ( 1000 digit ) number.
I want to convert it into a list , how would you go about it since :
list(n)
TypeError: 'long' object is not
iterable
A:
It's not exactly clear what you're asking for, but if what you want is to iterate over the digits, just convert i... | Create a list from a long int | I've got a very long ( 1000 digit ) number.
I want to convert it into a list , how would you go about it since :
list(n)
TypeError: 'long' object is not
iterable
| [
"It's not exactly clear what you're asking for, but if what you want is to iterate over the digits, just convert it to a string:\nx = str(n)\n\nYou can iterate over a string as if it were a list.\nIf you really want a true list (only reason I can think of is you want to modify digits), you can do:\nxl = list(str(n)... | [
7,
3,
0
] | [] | [] | [
"python"
] | stackoverflow_0006261197_python.txt |
Q:
Ajax to Python Pyramid data
So far, I have managed to take a bunch of HTML elements for whose contentEditable attribute is True and join their id's and HTML data together to make an Ajax data string. I can get the serialized data back to the server, no problem. For example,
$(document).ready(function(){
$("#s... | Ajax to Python Pyramid data | So far, I have managed to take a bunch of HTML elements for whose contentEditable attribute is True and join their id's and HTML data together to make an Ajax data string. I can get the serialized data back to the server, no problem. For example,
$(document).ready(function(){
$("#save").click(function(){
v... | [
"You say you want to convert each request.param string into a dictionary object, but is that what you meant? It looks like each string is just a key/value pair.\nYou can pretty simply create a dictionary from those values using:\nopts = {}\nfor r in request.params:\n parts = r.split(':', 1)\n if len(parts) ==... | [
0
] | [] | [] | [
"ajax",
"pyramid",
"python"
] | stackoverflow_0006260236_ajax_pyramid_python.txt |
Q:
Draw directly to the root window with PyCairo
I want to be able to draw directly to the root window in Python using Cairo. I have tested my code drawing on a fullscreened window, so I know that's not the issue. However, when I try to draw directly to the root window like so:
root = gtk.gdk.get_default_root_window(... | Draw directly to the root window with PyCairo | I want to be able to draw directly to the root window in Python using Cairo. I have tested my code drawing on a fullscreened window, so I know that's not the issue. However, when I try to draw directly to the root window like so:
root = gtk.gdk.get_default_root_window()
cr = root.cairo_create()
...
# Drawing code here
... | [
"Virtual root window.\nNote that KDE4 doesn't follow this convention. You need to find a child of the root window which has a property _NET_WM_WINDOW_TYPE set to _NET_WM_WINDOW_TYPE_DESKTOP.\n"
] | [
1
] | [] | [] | [
"cairo",
"linux",
"python"
] | stackoverflow_0006259924_cairo_linux_python.txt |
Q:
Is it bad style to reassign long variables as a local abbreviation?
I prefer to use long identifiers to keep my code semantically clear, but in the case of repeated references to the same identifier, I'd like for it to "get out of the way" in the current scope. Take this example in Python:
def define_many_mappings... | Is it bad style to reassign long variables as a local abbreviation? | I prefer to use long identifiers to keep my code semantically clear, but in the case of repeated references to the same identifier, I'd like for it to "get out of the way" in the current scope. Take this example in Python:
def define_many_mappings_1(self):
self.define_bidirectional_parameter_mapping("status", "curr... | [
"itertools to the rescue again! Try using starmap - here's a simple demo:\nlist(itertools.starmap(min,[(1,2),(2,2),(3,2)]))\n\nprints\n[1,2,2]\n\nstarmap is a generator, so to actually invoke the methods, you have to consume the generator with a list.\nimport itertools\n\ndef define_many_mappings_4(self): \n ... | [
1,
0,
0,
0
] | [] | [] | [
"naming_conventions",
"python",
"readability"
] | stackoverflow_0006260620_naming_conventions_python_readability.txt |
Q:
Python Regex to Parse String and Return Tuple
I've been given some strings to work with. Each one represents a data set and consists of the data set's name and the associated statistics. They all have the following form:
s= "| 'TOMATOES_PICKED' | 914 | 1397 |"
I'm tryi... | Python Regex to Parse String and Return Tuple | I've been given some strings to work with. Each one represents a data set and consists of the data set's name and the associated statistics. They all have the following form:
s= "| 'TOMATOES_PICKED' | 914 | 1397 |"
I'm trying to implement a function that will parse the stri... | [
"I would use a single regular expression to match the entire line, with the parts I want in named groups ((?P<name>exampl*e)).\nimport re\ndef extract_data2(s):\n pattern = re.compile(r\"\"\"\\|\\s* # opening bar and whitespace\n '(?P<name>.*?)' # quoted name\n ... | [
32,
7,
3,
2,
1,
0
] | [] | [] | [
"numbers",
"python",
"regex",
"return",
"string"
] | stackoverflow_0006260777_numbers_python_regex_return_string.txt |
Q:
pylint not recognizing some of the standard library
I'm using pylint + pydev, with python 2.6.
I have a module with just this line of code
from email import Message
Now when I try to run this module it runs fine. But pylint reports an error:
ID: E0611 No name 'Message' in module 'email'
Although it exists...
Any... | pylint not recognizing some of the standard library | I'm using pylint + pydev, with python 2.6.
I have a module with just this line of code
from email import Message
Now when I try to run this module it runs fine. But pylint reports an error:
ID: E0611 No name 'Message' in module 'email'
Although it exists...
Any idea why?
| [
"realise this is an old question, but the correct answer is that the older ways of invoking what you need, which use the \"import hackery\" that Richie describes, have long been deprecated (despite still appearing in many tutorials). If you use the new ways, you'll be writing better code and pylint won't complain.... | [
15,
12,
1
] | [] | [] | [
"email",
"import",
"pydev",
"pylint",
"python"
] | stackoverflow_0001316334_email_import_pydev_pylint_python.txt |
Q:
Python object holding a dict() of objects
Here is a test case I've created for a problem I found out.
For some reason the dict() 'l' in B() does not seem to hold the correct value. See the output below on my Linux 11.04 Ubuntu, python 2.7.1+.
class A():
name = None
b = None
def __init__(self, name, bna... | Python object holding a dict() of objects | Here is a test case I've created for a problem I found out.
For some reason the dict() 'l' in B() does not seem to hold the correct value. See the output below on my Linux 11.04 Ubuntu, python 2.7.1+.
class A():
name = None
b = None
def __init__(self, name, bname, cname, dname):
self.name = name
... | [
"What happened is that you created a class attribute. Create an instance attribute instead by instantiating in __init__().\n",
"It looks like you are trying to \"declare\" instance attributes at the class level. Class attributes have their own specific uses in Python, and it is wrong to put them there if you are ... | [
6,
1
] | [] | [] | [
"dictionary",
"instance",
"object",
"python"
] | stackoverflow_0006261459_dictionary_instance_object_python.txt |
Q:
Factors Analysis using MDP in Python
Excuse my ignorance, I'm very new to Python. I'm trying to perform factor analysis in Python using MDP (though I can use another library if there's a better solution).
I have an m by n matrix (called matrix) and I tried to do:
import mdp
mdp.nodes.FANode()(matrix)
but I get b... | Factors Analysis using MDP in Python | Excuse my ignorance, I'm very new to Python. I'm trying to perform factor analysis in Python using MDP (though I can use another library if there's a better solution).
I have an m by n matrix (called matrix) and I tried to do:
import mdp
mdp.nodes.FANode()(matrix)
but I get back an error. I'm guessing maybe my matri... | [
"I have absolutely no experience with mdp, but it looks like it expects your matrices to be passed as a Numpy array instead of a list. Numpy is a package for high performance scientific computing. You can go to the Numpy home page and install it. After doing so, try altering your code to this:\nimport mdp, numpy... | [
4,
4
] | [] | [] | [
"factor_analysis",
"lsa",
"python"
] | stackoverflow_0006066974_factor_analysis_lsa_python.txt |
Q:
list group and sum by column
I have the following
(Decimal('1.000'), Decimal('419.760000'), Decimal('4.197600000'), Decimal('423.957600000'))
(Decimal('1.000'), Decimal('62.370000'), Decimal('0.623700000'), Decimal('62.993700000'))
(Decimal('2.000'), Decimal('7.920000'), Decimal('0.0792... | list group and sum by column | I have the following
(Decimal('1.000'), Decimal('419.760000'), Decimal('4.197600000'), Decimal('423.957600000'))
(Decimal('1.000'), Decimal('62.370000'), Decimal('0.623700000'), Decimal('62.993700000'))
(Decimal('2.000'), Decimal('7.920000'), Decimal('0.079200000'), Decimal('7.999200000'))
... | [
"Assuming those three tuples are items in a tuple or list numbers:\ncolumn_sums = [sum(items) for items in zip(*numbers)]\n\nRereading your question, I think you may instead mean you want to group all numbers except the first of each row by what the number in the first row is, and then get the sum of each group. If... | [
3,
0
] | [] | [] | [
"list",
"python"
] | stackoverflow_0006262149_list_python.txt |
Q:
Svarga py framework. Would you start learning a "one man band" framework?
Would you start learning a "one man band" framework if someone you admired thought it had very good design choises? More so. Would you require the framework to have at least semi-good documentation before you thougt It would be worth investi... | Svarga py framework. Would you start learning a "one man band" framework? | Would you start learning a "one man band" framework if someone you admired thought it had very good design choises? More so. Would you require the framework to have at least semi-good documentation before you thougt It would be worth investing your time in?
I read a blog post quite some time ago (can't find it now) an... | [
"Svarga looks like it's still very, very young. Bleeding-edge software can be cool, but things break. They do. And when Svarga breaks, there is only one person who knows everything about it, and that person can go away, lose interest or just be too busy. Then you're out of luck.\nThere are also other upsides to usi... | [
1,
0
] | [] | [] | [
"python",
"web_frameworks"
] | stackoverflow_0006259578_python_web_frameworks.txt |
Q:
Any Python memcached client that batches and parallelizes multiple get to multiple servers?
Very often I need to get the values for a long list of N keys such as
[1267, 56578, ... , 9800]
Those values are stored on M different Memcached servers.
I don't want to send out a get() request, wait for a response, and ... | Any Python memcached client that batches and parallelizes multiple get to multiple servers? | Very often I need to get the values for a long list of N keys such as
[1267, 56578, ... , 9800]
Those values are stored on M different Memcached servers.
I don't want to send out a get() request, wait for a response, and then repeat N times.
Is there any Python memcached clients that will let me call a single multipl... | [
"Use either python-memcached: Python or pylibmc - Python client for memcached, both which has a get_mult() method for that purpose. That will cause the get operations to run asyncronously in parallell to each server. \nSee also Batch your requests with get_multi. \n"
] | [
2
] | [] | [] | [
"distributed",
"memcached",
"python",
"python_memcached"
] | stackoverflow_0006260842_distributed_memcached_python_python_memcached.txt |
Q:
Unicode Decode Error
Although I'm not a Python developer, I created some Python to convert some data to RDF.
I ran the code in Python 3.2 last week and it ran fine. Today however it is giving me the error
**Traceback (most recent call last):**
**File "C:\Users\Karen\Desktop\Linked Data new\RGC_v3.2.py", line 10, ... | Unicode Decode Error | Although I'm not a Python developer, I created some Python to convert some data to RDF.
I ran the code in Python 3.2 last week and it ran fine. Today however it is giving me the error
**Traceback (most recent call last):**
**File "C:\Users\Karen\Desktop\Linked Data new\RGC_v3.2.py", line 10, in <module>
for row in... | [
"You're assuming that the data is encoded in CP1252. Check the usual suspects to determine the encoding used.\n"
] | [
3
] | [] | [] | [
"decode",
"python",
"rdf"
] | stackoverflow_0006262470_decode_python_rdf.txt |
Q:
How to get a class instance name or the right format for eval(class_instance."func1().func2()") in Python?
In the code below I can get the class name via:
s.__class__.__name__ #Seq
but I can not get the intance name "s" directly, this will be problem if i use eval() in:
eval(s."head(20).tail(10)") # must b... | How to get a class instance name or the right format for eval(class_instance."func1().func2()") in Python? | In the code below I can get the class name via:
s.__class__.__name__ #Seq
but I can not get the intance name "s" directly, this will be problem if i use eval() in:
eval(s."head(20).tail(10)") # must be eval("s.head(20).tail(10)")
And
def foo(i_cls):
eval(i_cls."head(20).tail(10)")
How?
Code
class Seq(obje... | [
"If you want to filter all instances of class A and then evaluate call func_foo for them then you are also able to use Ignacio code with a small addition:\nmap(lambda inst: getattr(inst, 'func_foo')(), filter(lambda x: isinstance(x, A), locals().values()))\n\nI am sorry if it is duplicate.\nEDITED:\nl = locals()\ni... | [
1
] | [] | [] | [
"eval",
"instance",
"parameters",
"python"
] | stackoverflow_0006262492_eval_instance_parameters_python.txt |
Q:
Odd behavior of stacked filter() calls
So I'm getting some interesting behaviour from some filters stacked within a for loop.
I'll start with a demonstration:
>>> x = range(100)
>>> x = filter(lambda n: n % 2 == 0, x)
>>> x = filter(lambda n: n % 3 == 0, x)
>>> list(x)
[0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66... | Odd behavior of stacked filter() calls | So I'm getting some interesting behaviour from some filters stacked within a for loop.
I'll start with a demonstration:
>>> x = range(100)
>>> x = filter(lambda n: n % 2 == 0, x)
>>> x = filter(lambda n: n % 3 == 0, x)
>>> list(x)
[0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96]
Here we get the expec... | [
"In Python 3.x, filter() returns a generator instead of a list. As such, only the final value of factor gets used since all three filters use the same factor. You will need to modify your lambda slightly in order to make it work.\nresult = filter(lambda n, factor=factor: n % factor != 0, result)\n\n",
"The evalua... | [
7,
1,
1
] | [] | [] | [
"filter",
"python"
] | stackoverflow_0006263017_filter_python.txt |
Q:
Invoking Wine From Apache
I have Apache/2.2.11 using mod_python 3.3.1/Python 2.5 running under Gentoo linux. In my python script I invoke a win32 exe using wine (os.popen2 call). This works fine outside of Apache but under mod_python I get:
wine: cannot open /root/.wine : Permission denied
in /var/log/apache/er... | Invoking Wine From Apache | I have Apache/2.2.11 using mod_python 3.3.1/Python 2.5 running under Gentoo linux. In my python script I invoke a win32 exe using wine (os.popen2 call). This works fine outside of Apache but under mod_python I get:
wine: cannot open /root/.wine : Permission denied
in /var/log/apache/error_log. My apache install is ... | [
"It's probably because $HOME isn't set correctly...\nBtw. Are you really sure invoking wine from mod_python is a good idea?\nIf you are sure, something like that could work...\nfrom subprocess import Popen \n\nHOME = '/the/home/of/www-data' #PLEASE edit\nproc = Popen(cmd, shell=False, stdin=PIPE,\n ... | [
3,
1
] | [] | [] | [
"apache",
"mod_python",
"python",
"wine"
] | stackoverflow_0000513023_apache_mod_python_python_wine.txt |
Q:
Python install uninstall easy_install
I have two versions of python on my mac:
One preinstalled by Apple in /usr/bin
One from python.org in /Library/Frameworks/Python.framework/Versions/2.6
easy_install always installs to /usr/bin for some ununderstanable reason
So I explicitly now install easy_install in:
sh se... | Python install uninstall easy_install | I have two versions of python on my mac:
One preinstalled by Apple in /usr/bin
One from python.org in /Library/Frameworks/Python.framework/Versions/2.6
easy_install always installs to /usr/bin for some ununderstanable reason
So I explicitly now install easy_install in:
sh setuptools-0.6c11-py2.6.egg --install-dir=/Li... | [
"It's hard to tell exactly what state your installation is in based on the information supplied. /usr/local/bin is the default installation location for the Apple-supplied /usr/bin/easy_install so, most likely, you are somehow invoking that instead of the easy_install that should have been installed by running the... | [
8,
1
] | [] | [] | [
"easy_install",
"python"
] | stackoverflow_0003582715_easy_install_python.txt |
Q:
Python + webkit + os.fork()
I have some troubles trying to callback webkit functions from a child process. This code are meant to load background resources and insert them by javascript asynchronously. I need to callback javascript functions once the resource is loaded while keep the interface working. I tried to ... | Python + webkit + os.fork() | I have some troubles trying to callback webkit functions from a child process. This code are meant to load background resources and insert them by javascript asynchronously. I need to callback javascript functions once the resource is loaded while keep the interface working. I tried to sync threads throught pipes, but ... | [
"webkit is not thread-safe.\nSee: http://markmail.org/message/4dwft6s6g6ptavj6\n"
] | [
0
] | [] | [] | [
"fork",
"python",
"webkit",
"webview"
] | stackoverflow_0006259977_fork_python_webkit_webview.txt |
Q:
Python tkinter Entry widget status switch via Radio buttons
a simple question (not so simple for a tkinter newby like me): I'm building a GUI and I want to have two radio buttons driving the status (enabled or disabled) of an Entry widget, into which the user will input data. When the first radio button is pressed... | Python tkinter Entry widget status switch via Radio buttons | a simple question (not so simple for a tkinter newby like me): I'm building a GUI and I want to have two radio buttons driving the status (enabled or disabled) of an Entry widget, into which the user will input data. When the first radio button is pressed, I want the Entry to be disabled; when the second radio button i... | [
"You have a few things wrong with your program, but the general structure is OK.\n\nyou aren't calling root.mainloop(). This is necessary for the event loop to service events such as button clicks, etc.\nyou use ENABLED and DISABLED but don't define or import those anywhere. Personally I prefer to use the string va... | [
7
] | [] | [] | [
"python",
"radio_button",
"tkinter",
"user_interface"
] | stackoverflow_0006263226_python_radio_button_tkinter_user_interface.txt |
Q:
Converting Python regex to VisualBasic
I'm converting a python application to VB.net and I need help with this regular expression:
a = 'abcdef'
b = re.compile('[' + a + ']{3,}$', re.I)
Is it possible to convert it to Visual Basic, if so, can you provide any code?
A:
Dim b As New Regex("[" + a + "]{3,}$", RegexO... | Converting Python regex to VisualBasic | I'm converting a python application to VB.net and I need help with this regular expression:
a = 'abcdef'
b = re.compile('[' + a + ']{3,}$', re.I)
Is it possible to convert it to Visual Basic, if so, can you provide any code?
| [
"Dim b As New Regex(\"[\" + a + \"]{3,}$\", RegexOptions.IgnoreCase)\n\nI fail to see the problem, though.\n"
] | [
4
] | [] | [] | [
"python",
"regex",
"vb.net"
] | stackoverflow_0006264250_python_regex_vb.net.txt |
Q:
Create a list with boolean values which represent results of a predicate when applied to a list
I am trying to figure out if there is a way to get a logical list through comparison in Python 3.
Basically what I want to input is this
x = [1, 2, 3, 4, 5, 6, 7, 8, 9]
xlist = 4 <= x
and what I am looking to output is... | Create a list with boolean values which represent results of a predicate when applied to a list | I am trying to figure out if there is a way to get a logical list through comparison in Python 3.
Basically what I want to input is this
x = [1, 2, 3, 4, 5, 6, 7, 8, 9]
xlist = 4 <= x
and what I am looking to output is a list that would look like this
xlist = [False, False, False, True, True, True, True, True, True]
... | [
"There is really nothing wrong with a list comprehension. This is exactly the sort of thing list comprehensions were designed for.\nIf you're using NumPy (or SciPy), the syntax you're looking for actually does work:\nfrom numpy import array\n\n...\n\nx = array([1,2,3,4,5,6,7,8,9])\nxlist = 4<=x\n\nBut if you don't ... | [
5,
4,
2,
1,
1,
0
] | [] | [] | [
"list_comprehension",
"python",
"python_3.x"
] | stackoverflow_0006258962_list_comprehension_python_python_3.x.txt |
Q:
Python WebKitWebView: how to get (generated) source code
Is it possible to get the generated source code (so including JavaScript added DOM nodes) with Python and WebKit, and if so, how?
import webkit
web_view = webkit.WebView()
web_view.open('http://google.com')
But then?
A:
Bind a function to the loadFinished... | Python WebKitWebView: how to get (generated) source code | Is it possible to get the generated source code (so including JavaScript added DOM nodes) with Python and WebKit, and if so, how?
import webkit
web_view = webkit.WebView()
web_view.open('http://google.com')
But then?
| [
"Bind a function to the loadFinished(bool) signal, in that function you can use mainFrame().toHtml() to get the source code.\n",
"I found how to do it here: http://blog.motane.lu/2009/06/18/pywebkitgtk-execute-javascript-from-python/\n"
] | [
1,
0
] | [] | [] | [
"python",
"web_scraping",
"webkit"
] | stackoverflow_0006255120_python_web_scraping_webkit.txt |
Q:
Performing multiple regex matches to same index with pymongo
I need to translate some MySQL to mongodb. I have a MySQL query with multiple regular expression matches on one column. Is it possible to do the same thing with mongodb?
SELECT * FROM table WHERE column1 REGEXP r1 AND column1 REGEXP r2 AND colum1 REGEXP ... | Performing multiple regex matches to same index with pymongo | I need to translate some MySQL to mongodb. I have a MySQL query with multiple regular expression matches on one column. Is it possible to do the same thing with mongodb?
SELECT * FROM table WHERE column1 REGEXP r1 AND column1 REGEXP r2 AND colum1 REGEXP r3;
With pymongo I can perform regex searches with single regex l... | [
"db.collection.find({\"column1\": {\"$all\": [re.compile(\"r1\"), re.compile(\"r2\")]}})\n\nAlso take a look at future $and operator.\nBTW unless your regexp is prefix-like (/^text/) the index won't be used.\n"
] | [
6
] | [] | [] | [
"mongodb",
"mysql",
"pymongo",
"python"
] | stackoverflow_0006264263_mongodb_mysql_pymongo_python.txt |
Q:
How deploy Flask application on Webfaction?
Anybody know how to deploy a simple Flask application on Webfaction?
I know Webfaction support mod_wsgi and I read the guide on the Flask site but still I can't make my app working. Anybody have a working configuration?
UPDATE to answer a comment by Graham Dumpleton.
I g... | How deploy Flask application on Webfaction? | Anybody know how to deploy a simple Flask application on Webfaction?
I know Webfaction support mod_wsgi and I read the guide on the Flask site but still I can't make my app working. Anybody have a working configuration?
UPDATE to answer a comment by Graham Dumpleton.
I get a 500 Internal server error. Apache does not s... | [
"I got it working with the following procedure:\n\ncreate and app named 'myapp' of type mod_wsgi 3.3/Python 2.7. Webfaction will create the following folders:\nmyapp\n |- apache2\n |- htdocs\n\nWebfaction will also automatically create a simple script index.py in your htdocs directory. Check if the sample s... | [
16,
1
] | [] | [] | [
"flask",
"python"
] | stackoverflow_0003277657_flask_python.txt |
Q:
How can I make Plone display events during DST with the correct time?
I'm writing a Plone product that takes iCalendar, pulls it in, and creates Plone Event types. I've got it all working perfectly, except that, for half of the year's dates, the timestamps are off by an hour.
My iCalendar feed is passing these as ... | How can I make Plone display events during DST with the correct time? | I'm writing a Plone product that takes iCalendar, pulls it in, and creates Plone Event types. I've got it all working perfectly, except that, for half of the year's dates, the timestamps are off by an hour.
My iCalendar feed is passing these as UTC timestamps:
DTSTART;VALUE=DATE:20110812T130000Z should be 9am in the Am... | [
"Try Time Zone Converter.\nYou are experimenting daylight saving time.\nThis arises when you change the date.\nCheck one of the supposedly wrong dates:\nDTSTART;VALUE=DATE:20111225T175525Z should be 1:55pm, but it's showing as 12:55pm\nand read the legend:\n\nDaylight Saving Time is not in effect\non this date/time... | [
2
] | [] | [] | [
"dst",
"icalendar",
"plone",
"python",
"zope"
] | stackoverflow_0006257741_dst_icalendar_plone_python_zope.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.