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:
numpy: operating on multidimensional arrays
Sorry for title's vagueness. I have two related questions.
First, let's say I have a function "hessian" that given two parameters (x, y) returns a matrix. I now want to compute that matrix for (x,y) running over a two dimensional space. I'd like to do something like:
x =... | numpy: operating on multidimensional arrays | Sorry for title's vagueness. I have two related questions.
First, let's say I have a function "hessian" that given two parameters (x, y) returns a matrix. I now want to compute that matrix for (x,y) running over a two dimensional space. I'd like to do something like:
x = linspace(1, 4, 100).reshape(-1,1)
y = linspace(1... | [
"You could try to use meshgrid, maybe you have to flatten xn, yn:\nx = linspace(1, 4, 100)\ny = linspace(1, 4, 100)\nxn,yn=meshgrid(x,y)\nH = vectorize(hessian)(xn, yn)\n\n"
] | [
0
] | [] | [] | [
"multidimensional_array",
"numpy",
"python"
] | stackoverflow_0005306875_multidimensional_array_numpy_python.txt |
Q:
python ObjectListView has a single un-editable column
I have a ObjectListView that I have made editable with
self.TrackOlv.cellEditMode = ObjectListView.CELLEDIT_SINGLECLICK
The gives me 2 odd issues.
1) I can't edit the first cell/column. Is this due to OLV treating it like a primary key or something to that ef... | python ObjectListView has a single un-editable column | I have a ObjectListView that I have made editable with
self.TrackOlv.cellEditMode = ObjectListView.CELLEDIT_SINGLECLICK
The gives me 2 odd issues.
1) I can't edit the first cell/column. Is this due to OLV treating it like a primary key or something to that effect? I assume I can get around it by creating another att... | [
"1.) For each column have you added isEditable=True?\nfirst_col = ColumnDefn('Name', 'left', -1, 'name', isEditable=True)\n\nThis works perfectly for me in my OLV, along with having;\nself.TrackOlv.cellEditMode = self.TrackOlv.CELLEDIT_SINGLECLICK\n\n2.) You can read why this is the case here. Basically, if you don... | [
1
] | [] | [] | [
"objectlistview",
"python",
"wxpython"
] | stackoverflow_0005180521_objectlistview_python_wxpython.txt |
Q:
How can I view source code for datetime.py from PyCharm?
I'm ctrl-clicking on the datetime.timedelta function from within PyCharm, and getting to a file named ....PyCharm10\system\python_stubs\76178323\datetime.py, which appears to contain many empty methods. Specifically, ctrl-clicking on datetime.delta brings me... | How can I view source code for datetime.py from PyCharm? | I'm ctrl-clicking on the datetime.timedelta function from within PyCharm, and getting to a file named ....PyCharm10\system\python_stubs\76178323\datetime.py, which appears to contain many empty methods. Specifically, ctrl-clicking on datetime.delta brings me to this part of the file:
def __init__(self, *args, **kwargs)... | [
"Perhaps, there is no way. Possible, OS does not contain source code of the library, only the compiled binary (e.g. /usr/lib/python2.6/lib-dynload/datetime.so).\n"
] | [
2
] | [] | [] | [
"pycharm",
"python"
] | stackoverflow_0005309716_pycharm_python.txt |
Q:
How to pack a dict into a struct so that I can store it in a file and later unpack it
I have the following code to pack the dictionary into a struct ...
>>> this = bytearray(2)
>>> this[0] = 100
>>> this[1] = 150
>>> bool = True
>>> str = 'new'
>>> dct = {'bt_arr': this, 'string':str, 'boolean': boo... | How to pack a dict into a struct so that I can store it in a file and later unpack it | I have the following code to pack the dictionary into a struct ...
>>> this = bytearray(2)
>>> this[0] = 100
>>> this[1] = 150
>>> bool = True
>>> str = 'new'
>>> dct = {'bt_arr': this, 'string':str, 'boolean': bool}
>>> print dct
{'bt_arr': bytearray(b'd\x96'), 'boolean': True, 'string': 'new'}
va... | [
"Thanks to martineau and eumiro I got this solution, please let me know if there is a better solution\nval = struct.pack ('!' + 'B' +'B' + 'c'*3 + '?', *(tuple(dct['bt_arr'][0:2])+ tuple(dct['string'][0:3]) + (dct['boolean'],)))\n\n",
"There is a problem with missing bracket here:\ndct['bt_arr'[1]\n\nEDIT:\nval =... | [
2,
0
] | [] | [] | [
"python",
"struct"
] | stackoverflow_0005309144_python_struct.txt |
Q:
Inclusion Tags in Django on Google App Engine
I want to create a reusable template (almost like a UserControl from the .NET world) that I can apply in multiple places, something like:
{% for thing in things %}
{% render_thing thing %}
{% endfor %}
Where render_thing is my custom inclusion tag. My Python code ... | Inclusion Tags in Django on Google App Engine | I want to create a reusable template (almost like a UserControl from the .NET world) that I can apply in multiple places, something like:
{% for thing in things %}
{% render_thing thing %}
{% endfor %}
Where render_thing is my custom inclusion tag. My Python code reads as follows:
def get_full_path(relative_path):... | [
"If you are using Django 1.2 templates, you will need to supply a Python module-style reference to your custom tag code rather than a file path.\nThere's a full description of the problem and the solution on my blog.\nEDIT:\nSorry to be so high-level on you. Here's a more step-by-step explanation:\n\nPut your custo... | [
3,
2,
0
] | [] | [] | [
"django",
"django_templates",
"google_app_engine",
"python"
] | stackoverflow_0005306178_django_django_templates_google_app_engine_python.txt |
Q:
how to implement ajax in django app?
My issue is similar to that mention in
use of ajax in django problem with the code
I tried the solution given into that but still i am not getting the response value. below is my code
chkAjax.html
------------
<html>
<head>
<script>
function chkAjax(form)
{
... | how to implement ajax in django app? | My issue is similar to that mention in
use of ajax in django problem with the code
I tried the solution given into that but still i am not getting the response value. below is my code
chkAjax.html
------------
<html>
<head>
<script>
function chkAjax(form)
{
var xmlhttp;
if (window.XMLHttpRequ... | [
"best example to find ajax in django \n\nhttp://webcloud.se/log/AJAX-in-Django-with-jQuery/\n\n"
] | [
3
] | [] | [] | [
"ajax",
"django",
"google_app_engine",
"javascript",
"python"
] | stackoverflow_0005310451_ajax_django_google_app_engine_javascript_python.txt |
Q:
file reading in python
I need to read the file like below:
config = {
'name': 'hello',
'see?': 'world'
}
using keys like name and see? ,but I don't want to hard code the values in script.And how to deal with more deep nesting in this case.The file may contain more sections like this how can I recognize th... | file reading in python | I need to read the file like below:
config = {
'name': 'hello',
'see?': 'world'
}
using keys like name and see? ,but I don't want to hard code the values in script.And how to deal with more deep nesting in this case.The file may contain more sections like this how can I recognize that 'name' belongs to which s... | [
"If you encode your structure as JSON data, as I think you want and you did in the example, you just need to write and read the structure in a file.\nAs an example:\n import json \n config = {\n 'name': 'hello',\n 'see?': 'world'\n }\n out = open('config.json','w')\n out.write(json.dumps(config))\n out.close() \n... | [
4,
3,
1,
0
] | [] | [] | [
"config",
"file",
"python"
] | stackoverflow_0005310378_config_file_python.txt |
Q:
Access to the values of set()
Any way to access the values of BIF "set()" without using an iterator.
For instance, I got this output from my code:
>>> set([1,2,3])
How can I access it as a list?
Like:
>>> [1,2,3]
A:
Use a simple type conversion:
>>> a
set([1, 2, 3])
>>> list(a)
[1, 2, 3]
A:
Make a list, like... | Access to the values of set() | Any way to access the values of BIF "set()" without using an iterator.
For instance, I got this output from my code:
>>> set([1,2,3])
How can I access it as a list?
Like:
>>> [1,2,3]
| [
"Use a simple type conversion:\n>>> a\nset([1, 2, 3])\n>>> list(a)\n[1, 2, 3]\n\n",
"Make a list, like\nlist(set([1, 2, 3]))\n\n"
] | [
25,
4
] | [] | [] | [
"python"
] | stackoverflow_0005310646_python.txt |
Q:
Regex Replace [*]
I have a string as follows:
something.something[0].somethingelse[21].blah
I want to replace all the [*] section with an empty string so that I end up with a string like this:
something.something.somethingelse.blah
(I'm doing this in Python if that makes any difference)
A:
Try this:
re.sub(r'\... | Regex Replace [*] | I have a string as follows:
something.something[0].somethingelse[21].blah
I want to replace all the [*] section with an empty string so that I end up with a string like this:
something.something.somethingelse.blah
(I'm doing this in Python if that makes any difference)
| [
"Try this:\nre.sub(r'\\[\\d+\\]', '', 'something.something[0].somethingelse[21].blah')\n\n",
"import re\n\np = re.compile(r'\\[[0-9]+\\]')\ns = 'something.something[0].somethingelse[21].blah'\n\nprint p.sub('', s)\n\n",
"this should work \n\\[\\d*\\]\n\nand replace with \"\"\n"
] | [
6,
4,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0005311219_python_regex.txt |
Q:
Import shared module from folders
I have modules written in c++ for python. For example, here is folders structure:
|Main/
|--SubMain/
|----Module1.so
|--SubMain2/
|----Module2.so
|----Module3.so
Now I want to import this into python like:
import Main.SubMain.Module1
First of all, I did recursively for all that ... | Import shared module from folders | I have modules written in c++ for python. For example, here is folders structure:
|Main/
|--SubMain/
|----Module1.so
|--SubMain2/
|----Module2.so
|----Module3.so
Now I want to import this into python like:
import Main.SubMain.Module1
First of all, I did recursively for all that folders:
import sys
sys.path.append(...... | [
"In order to make something a package, you need to add __init__.py (not __input__.py) to the folders. So if you add __init__.py to Main, Submain1, and Submain2, then call sys.path.append with the parent of Main, you should be able to import as you desire.\n"
] | [
2
] | [] | [] | [
"import",
"module",
"python"
] | stackoverflow_0005311711_import_module_python.txt |
Q:
PyQt Hide QDialogs Inside of QTreeWidget
I have a QTreeWidget with QComboBoxes inside of it. I would like to be able to hide the combo boxes.
I am getting the QComboBox out of the tree using the itemWidget function. I have tried using setVisible(False) and hide() but neither work. Can anyone explain why this is... | PyQt Hide QDialogs Inside of QTreeWidget | I have a QTreeWidget with QComboBoxes inside of it. I would like to be able to hide the combo boxes.
I am getting the QComboBox out of the tree using the itemWidget function. I have tried using setVisible(False) and hide() but neither work. Can anyone explain why this is the case and possibly offer a soultion?
I s... | [
"Have you tried putting the QComboBoxes inside a layout inside a QWidget, and placing the QWidget in the QTreeWidget?\n"
] | [
0
] | [] | [] | [
"pyqt",
"python",
"qt",
"qt4",
"user_interface"
] | stackoverflow_0005307007_pyqt_python_qt_qt4_user_interface.txt |
Q:
Binary file email attachment problem
Using Python 3.1.2 I am having a problem sending binary attachment files (jpeg, pdf, etc.) - MIMEText attachments work fine. The code in question is as follows...
for file in self.attachments:
part = MIMEBase('application', "octet-stream")
part.set_payload(open(file,"rb"... | Binary file email attachment problem | Using Python 3.1.2 I am having a problem sending binary attachment files (jpeg, pdf, etc.) - MIMEText attachments work fine. The code in question is as follows...
for file in self.attachments:
part = MIMEBase('application', "octet-stream")
part.set_payload(open(file,"rb").read())
encoders.encode_base64(part)
... | [
"solution from this SO answer\nfrom base64 import encodebytes\nfor file in self.attachments:\n fp = open(file, 'rb')\n part = MIMEBase('application', \"octet-stream\")\n part.set_payload(encodebytes(fp.read()).decode())\n fp.close()\n part.add_header('Content-Transfer-Encoding', 'base64')\n part.a... | [
6,
3,
3
] | [] | [] | [
"attachment",
"binary",
"email",
"python",
"smtp"
] | stackoverflow_0002798470_attachment_binary_email_python_smtp.txt |
Q:
Python on Windows: path as subprocess argument gets modified and generating error
Am using subprocess on Windows and Python 2.6 as follows. I am trying to parse a text file using a legacy parser application (assume parser.py) as follows:
import subprocess
k = subprocess.Popen(['python', 'parser.py', '-f C:\Report1... | Python on Windows: path as subprocess argument gets modified and generating error | Am using subprocess on Windows and Python 2.6 as follows. I am trying to parse a text file using a legacy parser application (assume parser.py) as follows:
import subprocess
k = subprocess.Popen(['python', 'parser.py', '-f C:\Report1\2011-03-14.txt'],
shell=True, stdout=subprocess.PIPE, stderr=subp... | [
"Change your parameter list to encode the path as a raw string:\nk = subprocess.Popen(['python', 'parser.py', '-f', r'C:\\Report1\\2011-03-14.txt'],\n shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)\n\na simple program that reads a file and reports the length:\nimport sys\nimport o... | [
4,
3,
1
] | [] | [] | [
"python",
"subprocess"
] | stackoverflow_0005302995_python_subprocess.txt |
Q:
save a webpage with urllib
import urllib
url='www.something.com/something..'
f = urllib.urlretrieve(url,'copy.html')
this code only creates a html file which provides direct link to the url specified (ie, it is not accessible offline). How to to store the webpage so that it will be available offline.??
A:
You ... | save a webpage with urllib | import urllib
url='www.something.com/something..'
f = urllib.urlretrieve(url,'copy.html')
this code only creates a html file which provides direct link to the url specified (ie, it is not accessible offline). How to to store the webpage so that it will be available offline.??
| [
"You need to get all the other resources the page is pointing to (CSS files, images ...).\nI suggest that you use \"wget\", it already does what you want.\n"
] | [
2
] | [] | [] | [
"python",
"urllib",
"urllib2"
] | stackoverflow_0005312487_python_urllib_urllib2.txt |
Q:
Good programming guide for a middleschooler
I hope that this forum is the right place to ask this question!
I am a teacher at a combined middle/high school and one of the eighth graders is interested in teaching himself some programming.
I've recommended Python as an introductory language. I have struggled to find... | Good programming guide for a middleschooler | I hope that this forum is the right place to ask this question!
I am a teacher at a combined middle/high school and one of the eighth graders is interested in teaching himself some programming.
I've recommended Python as an introductory language. I have struggled to find any programming guides, however, that are access... | [
"How to Think Like a Computer Scientist - Learning with Python\nhttp://openbookproject.net/thinkcs/python/english2e/\nIt is free and aimed at beginner programmers. In my opinion - the best choice for your students.\n",
"I think Python is an excellent choice for students who are completely new to programming.\nThe... | [
6,
3,
2,
2,
1,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0005308597_python.txt |
Q:
searching in python
I am trying to search a file to find all words which use any or all of the letters of a persons first name and are the same length as their first name. I have imported the file and it can be opened and read etc, but now i want to be able to seach the file for any words which would contain the ... | searching in python | I am trying to search a file to find all words which use any or all of the letters of a persons first name and are the same length as their first name. I have imported the file and it can be opened and read etc, but now i want to be able to seach the file for any words which would contain the specified letters, the wo... | [
"You can use itertools (for permutations) and regular expressions (for searching)\n",
"def find_anagrams_in_file(filename, searchword):\n import re\n searchword = searchword.lower()\n found_words = []\n for line in open(filename, 'rt'):\n words = re.split(r'\\W', line)\n for word in word... | [
1,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0005312099_python.txt |
Q:
How to test if a dictionary contains a specific key?
What's the cleanest way to test if a dictionary contains a key?
x = {'a' : 1, 'b' : 2}
if (x.contains_key('a')):
....
A:
'a' in x
and a quick search reveals some nice information about it: http://docs.python.org/3/tutorial/datastructures.html#dictionaries... | How to test if a dictionary contains a specific key? | What's the cleanest way to test if a dictionary contains a key?
x = {'a' : 1, 'b' : 2}
if (x.contains_key('a')):
....
| [
"'a' in x\n\nand a quick search reveals some nice information about it: http://docs.python.org/3/tutorial/datastructures.html#dictionaries\n"
] | [
676
] | [] | [] | [
"python"
] | stackoverflow_0005312778_python.txt |
Q:
Python .exe problem
I created an executable version of my application succesfully. It is just a basic database related app. So it has a database and an icon file in the same directory called “data”.
When I try to add an entry to my database by using the .exe file, it gives an error such as “unable to open database... | Python .exe problem | I created an executable version of my application succesfully. It is just a basic database related app. So it has a database and an icon file in the same directory called “data”.
When I try to add an entry to my database by using the .exe file, it gives an error such as “unable to open database file”. But there is no p... | [
"Are your globs returning the files you expect? Try print glob('Veriler\\*'). You may need to give the full directory path.\nAnother option is that the dlls necessary to work with your db have been left out.\nI would recommend pyInstaller over py2exe any day of the week though - you may find there is good mileage i... | [
0,
0
] | [] | [] | [
"executable",
"py2exe",
"python"
] | stackoverflow_0005312284_executable_py2exe_python.txt |
Q:
Can difflib be used to make a plagiarism detection program?
I am trying to figure this out...
Can the difflib.* library in Python be used to make some kind of plagiarism detection program? If so how?
Maybe anyone could help me to figure out this question.
A:
It could be used, but you're going to face all the sam... | Can difflib be used to make a plagiarism detection program? | I am trying to figure this out...
Can the difflib.* library in Python be used to make some kind of plagiarism detection program? If so how?
Maybe anyone could help me to figure out this question.
| [
"It could be used, but you're going to face all the same general issues you find in automated plagiarism detection. It might give you a little bit of a head start on implementing some of the algorithms you need, but I don't think it is likely to take you very far.\n",
"The short answer is yes. \nThe long answer ... | [
1,
0
] | [] | [] | [
"diff",
"difflib",
"python"
] | stackoverflow_0005312982_diff_difflib_python.txt |
Q:
php DAL out of a schema
I developed a web platform in PHP a year ago, and I was kinda proud of the data access layer I wrote for it. Since then, I started re-using the same concept over and over. But now I'm thinking to take it to the next level, instead of re-writing the whole database access code I'd like to cre... | php DAL out of a schema | I developed a web platform in PHP a year ago, and I was kinda proud of the data access layer I wrote for it. Since then, I started re-using the same concept over and over. But now I'm thinking to take it to the next level, instead of re-writing the whole database access code I'd like to create a tool that will parse my... | [
"The immitiate thought would be to simply use regular python syntax to define your tables:\n{\n 'TableName': {'FieldA': ['Type', FK(..)], 'FieldB': ['type']}\n}\n\nand so on.\nYou could however have a look at how django does it: you define a class and add properties to that class, which will then represent your ... | [
1
] | [] | [] | [
"parser_generator",
"python"
] | stackoverflow_0005312370_parser_generator_python.txt |
Q:
How do you manage multiple services while developing locally?
We're building web applications in Python and it isn't rare to require 3 or more services to be running (search, db(s), task queues, web app, etc.) just to work on the project locally. Manually firing off each service in a new console (then remembering ... | How do you manage multiple services while developing locally? | We're building web applications in Python and it isn't rare to require 3 or more services to be running (search, db(s), task queues, web app, etc.) just to work on the project locally. Manually firing off each service in a new console (then remembering to restart it when you change the code) is slow and error prone.
Id... | [
"I personally like supervisord. I used it when I was writing an app that combined nginx and tornado. It will handle starting and monitoring of the services you define, and give you an interface to control them as a group. \nIt doesn't have file monitoring built in, but there may be a plugin (update: there doesn't ... | [
0
] | [] | [] | [
"python",
"service"
] | stackoverflow_0005313628_python_service.txt |
Q:
Python RE question - proper state initial formatting
I have a string that I need to edit, it looks something similar to this:
string = "Idaho Ave N,,Crystal,Mn,55427-1463,US,,610839124763,Expedited"
If you notice the state initial "Mn" is not in proper formatting. I'm trying to use a regular expression to change ... | Python RE question - proper state initial formatting | I have a string that I need to edit, it looks something similar to this:
string = "Idaho Ave N,,Crystal,Mn,55427-1463,US,,610839124763,Expedited"
If you notice the state initial "Mn" is not in proper formatting. I'm trying to use a regular expression to change this:
re.sub("[A-Z][a-z],", "[A-Z][A-Z],", string)
Howeve... | [
"Your re.sub might modify also parts of the string you would not want to modify. Try to process the right element in your list explicitly:\ninput = \"Idaho Ave N,,Crystal,Mn,55427-1463,US,,610839124763,Expedited\"\nelems = input.split(',')\nelems[3] = elems[3].upper()\noutput = ','.join(elems)\n\nreturns\n'Idaho Av... | [
2,
0,
0
] | [
"You create a group by surrounding it in parentheses withing your regex, then refer to is by its group number:\nre.sub(\"([A-Z][a-z]),\", \"\\1,\".upper(), string)\n\n"
] | [
-1
] | [
"python"
] | stackoverflow_0005313920_python.txt |
Q:
Turning a generator into a callback with an eventloop in Python
Is there a simple way in python to turn a generator into a callback from an event loop, without using threads?
I'd like to change the code
for x in generator:
callback(x)
to something that can be used with Tornado's event loop. The problem with ... | Turning a generator into a callback with an eventloop in Python | Is there a simple way in python to turn a generator into a callback from an event loop, without using threads?
I'd like to change the code
for x in generator:
callback(x)
to something that can be used with Tornado's event loop. The problem with the above code is that it blocks the current thread if the generator ... | [
"You could try multiprocessing, but that is one huge sledgehammer for that tiny little nut - you're better looking for another foodsource, i.e. make sure your callback is non-blocking, because even using threads you're going to end up fighting the GIL.\n"
] | [
1
] | [] | [] | [
"python",
"tornado"
] | stackoverflow_0005304384_python_tornado.txt |
Q:
Python: how do I replace all of the same elements in an int array?
I have 1,2,3,6,7,8,1,1,1,6,7,5
What is the syntax for replacing all 1's with ... say.. 0?
for strings its .replace("1", "0")
A:
If by "array" you mean "list":
[0 if e == 1 else e for e in a]
where a is your list.
If by "array" you mean array.arr... | Python: how do I replace all of the same elements in an int array? | I have 1,2,3,6,7,8,1,1,1,6,7,5
What is the syntax for replacing all 1's with ... say.. 0?
for strings its .replace("1", "0")
| [
"If by \"array\" you mean \"list\":\n[0 if e == 1 else e for e in a]\n\nwhere a is your list.\nIf by \"array\" you mean array.array:\narray.array('i', [0 if e == 1 else e for e in a])\n\n",
"I just wanted to mention can also use numpy arrays, in which case you can do the following:\nimport numpy\na = numpy.array(... | [
9,
4,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0005313960_python.txt |
Q:
Django UKPhoneNumberField problem!
I'm currently using UKPhoneNumberField in one of my forms. I recently found that if I submit a London number 02081112222 (or as 020 8111 2222) it saves the number as 020 81112222 8111 in the DB. I'm not very good at debugging python so I was wondering if someone could help me tra... | Django UKPhoneNumberField problem! | I'm currently using UKPhoneNumberField in one of my forms. I recently found that if I submit a London number 02081112222 (or as 020 8111 2222) it saves the number as 020 81112222 8111 in the DB. I'm not very good at debugging python so I was wondering if someone could help me track down the problem. Cheers
EDIT:
I sure... | [
"The problem looks likes its caused by the following in format_number \nlast_index = len(number_spec) - 1\n\nAs the code loops the second (or last -1) iteration will match, this results in the code appending 81112222 (position:) to the string rather then 8111, the 3rd iteration then adds 8111. Removing - 1 form the... | [
2,
0
] | [] | [] | [
"django",
"django_forms",
"python"
] | stackoverflow_0005313600_django_django_forms_python.txt |
Q:
Difference between consecutive elements in list
Possible Duplicate:
Python - Differences between elements of a list
I have a list and I want to find difference between consecutive elements:
a = [0, 4, 10, 100]
find_diff(a)
>>> [4,6,90]
How would you code find_diff() function? I can code this with "for" iterator... | Difference between consecutive elements in list |
Possible Duplicate:
Python - Differences between elements of a list
I have a list and I want to find difference between consecutive elements:
a = [0, 4, 10, 100]
find_diff(a)
>>> [4,6,90]
How would you code find_diff() function? I can code this with "for" iterator but I am sure there are very simple ways to do it w... | [
"You could utilize enumerate, zip and list comprehensions:\n>>> a = [0, 4, 10, 100]\n\n# basic enumerate without condition:\n>>> [x - a[i - 1] for i, x in enumerate(a)][1:]\n[4, 6, 90]\n\n# enumerate with conditional inside the list comprehension:\n>>> [x - a[i - 1] for i, x in enumerate(a) if i > 0]\n[4, 6, 90]\n\... | [
73,
18,
5
] | [] | [] | [
"list",
"python"
] | stackoverflow_0005314241_list_python.txt |
Q:
Making exe using py2exe + sqlalchemy + mssql
I have a problem with making exe using py2exe. In my project i'm using sqlalchemy with mssql module.
My setup.py script looks like:
from distutils.core import setup
import py2exe
setup(
windows=[{"script" : "pyrmsutil.py"}],
options={"pyrmsutil" : {
"includes":... | Making exe using py2exe + sqlalchemy + mssql | I have a problem with making exe using py2exe. In my project i'm using sqlalchemy with mssql module.
My setup.py script looks like:
from distutils.core import setup
import py2exe
setup(
windows=[{"script" : "pyrmsutil.py"}],
options={"pyrmsutil" : {
"includes": ["sqlalchemy.dialects.mssql", "sqlalchemy"],
... | [
"I know it's no an answer per se but have you tries pyInstaller? I used to use py2exe and found it tricky to get something truly distributable. pyInstaller requires a little more setup but the docs are good and the result seems better.\nFor solving this issue you could try searching for the mentioned dlls and placi... | [
1,
0
] | [] | [] | [
"py2exe",
"python",
"sql_server",
"sqlalchemy"
] | stackoverflow_0005310922_py2exe_python_sql_server_sqlalchemy.txt |
Q:
(in Boost::Python)How can I instantiate an object of a class defined in a python module and invoke its methods from C++
Assume I have a class defined in a python module:
class A(object):
def __init__(self):
print 'init'
def method(self):
print 'method'
I'd like to instantiate an object of ... | (in Boost::Python)How can I instantiate an object of a class defined in a python module and invoke its methods from C++ | Assume I have a class defined in a python module:
class A(object):
def __init__(self):
print 'init'
def method(self):
print 'method'
I'd like to instantiate an object of that class with boost::python. I tried it the following way:
namespace py = boost::python;
// importing the module and extra... | [
"I found the answer myself: use eval instead of exec.\n"
] | [
1
] | [] | [] | [
"boost",
"object",
"python"
] | stackoverflow_0005183216_boost_object_python.txt |
Q:
Datetime string with timezone in Python?
I'm working on Google app engine with Python.
I have stored a datetime object in database and fetched it and applied timezone, and I saved it using template. The result is "2011-03-15 16:54:24.398503+09:00", but what I want is: "2011-03-16 01:54:24" (timezone applied string... | Datetime string with timezone in Python? | I'm working on Google app engine with Python.
I have stored a datetime object in database and fetched it and applied timezone, and I saved it using template. The result is "2011-03-15 16:54:24.398503+09:00", but what I want is: "2011-03-16 01:54:24" (timezone applied string without millisecond - note that day is change... | [
"Once you have the datetime object, use strftime, like so;\nfrom datetime import datetime\ndatetime.now().strftime('%Y-%m-%d %H:%M:%S')\n\nhttp://docs.python.org/release/2.6.6/library/datetime.html#strftime-and-strptime-behavior\n",
"using strftime is encouraged, but make sure that your localtime is correct. This... | [
2,
0
] | [] | [] | [
"python",
"timezone"
] | stackoverflow_0005314267_python_timezone.txt |
Q:
Load a numpy array into C from a file that was saved with numpy.save(...)
I'd like to access data in a C program that resides in a file that was written from python using numpy.save(...). So far, I was looking for a way to call the C version of numpy.load my C program, but it seems there is no directly accessible ... | Load a numpy array into C from a file that was saved with numpy.save(...) | I'd like to access data in a C program that resides in a file that was written from python using numpy.save(...). So far, I was looking for a way to call the C version of numpy.load my C program, but it seems there is no directly accessible C version, because numpy.load uses the pickle module. Another solution would be... | [
"The .npy format is not really meant to be read from outside NumPy. There are many formats available with provide both, excellent C and Python libraries, like HDF5 and NetCDF, so I can't see any reason whatsoever to access native NumPy files from C.\nIf you want to do this anyway, here are the docs of the .npy for... | [
6
] | [] | [] | [
"c",
"c++",
"numpy",
"python"
] | stackoverflow_0005314432_c_c++_numpy_python.txt |
Q:
Schedule Python Script - Windows 7
I have a python script which I would like to run at regular intervals. I am running windows 7. What is the best way to accomplish this? Easiest way?
A:
You can do it in the command line as follows:
schtasks /Create /SC HOURLY /TN PythonTask /TR "PATH_TO_PYTHON_EXE PATH_TO_PY... | Schedule Python Script - Windows 7 | I have a python script which I would like to run at regular intervals. I am running windows 7. What is the best way to accomplish this? Easiest way?
| [
"You can do it in the command line as follows:\nschtasks /Create /SC HOURLY /TN PythonTask /TR \"PATH_TO_PYTHON_EXE PATH_TO_PYTHON_SCRIPT\"\n\nThat will create an hourly task called 'PythonTask'. You can replace HOURLY with DAILY, WEEKLY etc. \nPATH_TO_PYTHON_EXE will be something like: C:\\python25\\python.exe. Ch... | [
66,
52,
15
] | [] | [] | [
"python",
"scheduled_tasks",
"windows"
] | stackoverflow_0002725754_python_scheduled_tasks_windows.txt |
Q:
Im getting "The server encountered an error and could not complete your request" error
Im getting "The server encountered an error and could not complete your request" error in my google app engine:
my app.yaml:
application: myapp
version: 2
runtime: python
api_version: 1
builtins:
- remote_api: on
- datastore_ad... | Im getting "The server encountered an error and could not complete your request" error | Im getting "The server encountered an error and could not complete your request" error in my google app engine:
my app.yaml:
application: myapp
version: 2
runtime: python
api_version: 1
builtins:
- remote_api: on
- datastore_admin: on
handlers:
- url: /AJAX
script: main.py
- url: /emailtrigger
script: main.py
-... | [
"\ntry adding this as first line of your code\n\n# -- coding: utf-8 -- \n\ntry coverting your strings to unicode\nself.response.out.write(unicode(\"ã\",\"UTF-8\"))\n\n"
] | [
2
] | [] | [] | [
"encoding",
"google_app_engine",
"python"
] | stackoverflow_0005313225_encoding_google_app_engine_python.txt |
Q:
Functional append/extend
The methods append and extend in Python are not functional by nature, they modify the callee and return None.
Is there an alternative way to do what these methods do and get a new list as a returned value?
Consider this example:
def myfun(first, *args):
for elem in [first].extend(args):
... | Functional append/extend | The methods append and extend in Python are not functional by nature, they modify the callee and return None.
Is there an alternative way to do what these methods do and get a new list as a returned value?
Consider this example:
def myfun(first, *args):
for elem in [first].extend(args):
print elem
Obviously, thi... | [
">>> def append(lst, elem):\n... return lst + [elem]\n... \n>>> append([1, 2, 3], 4)\n[1, 2, 3, 4]\n>>> def extend(lst1, lst2):\n... return lst1 + lst2\n... \n>>> extend([1, 2], [3, 4])\n[1, 2, 3, 4]\nIs that what you wanted?\nYou may also define your own type, which returns the list itself on these operation... | [
14,
7
] | [] | [] | [
"python"
] | stackoverflow_0005314820_python.txt |
Q:
django-admin cannot find settings file?
Currently I have 3 django projects and they share some common settings like database_engine. I created a folder settings to house the settings for each project. I have
top_settings.py: settings shared
among the 3 projects
site1to3_settings.py: common
settings inherited fro... | django-admin cannot find settings file? | Currently I have 3 django projects and they share some common settings like database_engine. I created a folder settings to house the settings for each project. I have
top_settings.py: settings shared
among the 3 projects
site1to3_settings.py: common
settings inherited from top_settings
and site_specific settings
Qu... | [
"You can import settings from other files using the 'from x import *' statement.\nSet DJANGO_SETTINGS_MODULE to the site specific setting file and in that include\nfrom top_settings import *\n\n"
] | [
3
] | [] | [] | [
"django",
"django_admin",
"python"
] | stackoverflow_0005314404_django_django_admin_python.txt |
Q:
Python OpenCV: Detecting a general direction of movement?
I'm still hacking together a book scanning script, and for now, all I need is to be able to automagically detect a page turn. The book fills up 90% of the screen (I'm using a cruddy webcam for the motion detection), so when I turn a page, the direction of m... | Python OpenCV: Detecting a general direction of movement? | I'm still hacking together a book scanning script, and for now, all I need is to be able to automagically detect a page turn. The book fills up 90% of the screen (I'm using a cruddy webcam for the motion detection), so when I turn a page, the direction of motion is basically in that same direction.
I have modified a mo... | [
"I haven't used OpenCV in Python before, just a bit in C++ with openframeworks.\nFor this I presume OpticalFlow's velx,vely properties would work.\nFor more on how Optical Flow works check out this paper.\nHTH\n",
"why don't you use cv.GoodFeaturesToTrack ? it may solve the script runtime ... and shorten the code... | [
3,
1
] | [] | [] | [
"motion_detection",
"opencv",
"python"
] | stackoverflow_0004496063_motion_detection_opencv_python.txt |
Q:
Naming variable, best convention
What is the most used convention for naming variables in Python / Django?
ex: pub_date or pubdate
What about for classes and methods?
A:
Django's coding style
A:
PEP 8, nothing more to say.
Of course you can use your own style (I use camelCase, for example), but most people use... | Naming variable, best convention | What is the most used convention for naming variables in Python / Django?
ex: pub_date or pubdate
What about for classes and methods?
| [
"Django's coding style\n",
"PEP 8, nothing more to say.\nOf course you can use your own style (I use camelCase, for example), but most people use recommendations from that PEP.\n",
"Code Complete (http://www.cc2e.com/) has some great chapters about function/variable naming, not for Python explicitly, but perhap... | [
15,
10,
2,
2,
1,
1
] | [] | [] | [
"django",
"naming_conventions",
"python"
] | stackoverflow_0005314421_django_naming_conventions_python.txt |
Q:
Python: How do I check email with a loop without there being a message in the inbox?
import serial
import imaplib
from time import sleep
IMAP_SERVER='imap.gmail.com'
IMAP_PORT=993
ser= serial.Serial ('/dev/ttyACM0',9600)
M = imaplib.IMAP4_SSL(IMAP_SERVER, IMAP_PORT)
rc, resp = M.login('user@gmail.com', 'password... | Python: How do I check email with a loop without there being a message in the inbox? | import serial
import imaplib
from time import sleep
IMAP_SERVER='imap.gmail.com'
IMAP_PORT=993
ser= serial.Serial ('/dev/ttyACM0',9600)
M = imaplib.IMAP4_SSL(IMAP_SERVER, IMAP_PORT)
rc, resp = M.login('user@gmail.com', 'password')
print rc, resp
while True:
M.select()
for msg_num in M.search("INBOX", "UNDEL... | [
"A quick and dirty fix is to catch the TypeError. Something like this:\ntry:\n String = msg[1][0][1][139:161]\nexcept TypeError:\n continue\n\nThat said, this could stand to be improved. For one thing, you can use\nif 'This is just a test...' in String:\n # ...\n\ninstead of slicing your message body to bi... | [
0
] | [] | [] | [
"gmail_imap",
"imaplib",
"python"
] | stackoverflow_0005315537_gmail_imap_imaplib_python.txt |
Q:
What's the difference between /usr/local/lib/python2.6 and /usr/lib/python2.6?
I'm using Ubuntu and noticed these two directories:
/usr/local/lib/python2.6/dist-packages
/usr/lib/python2.6/dist-packages
Which one should be used for installing Python packages?
Thanks.
A:
Ubuntu packages in .deb format should ... | What's the difference between /usr/local/lib/python2.6 and /usr/lib/python2.6? | I'm using Ubuntu and noticed these two directories:
/usr/local/lib/python2.6/dist-packages
/usr/lib/python2.6/dist-packages
Which one should be used for installing Python packages?
Thanks.
| [
"Ubuntu packages in .deb format should use\n/usr/lib/python2.6/dist-packages\n\nFiles you install outside the package management, i.e. files dpkg is unaware of, should go into\n/usr/local/lib/python2.6/dist-packages\n\nSe also the file system hierarchy standard.\n"
] | [
11
] | [] | [] | [
"python",
"ubuntu"
] | stackoverflow_0005315714_python_ubuntu.txt |
Q:
System.DateTime format as a web service arg
I would like to use a web service which is written on .NET.
I should pass a date value to a method webservicemethod(on_date).
It's written in a description that format of this date is System.DateTime.
I'm using Python as a client language. After googling I tried to use ... | System.DateTime format as a web service arg | I would like to use a web service which is written on .NET.
I should pass a date value to a method webservicemethod(on_date).
It's written in a description that format of this date is System.DateTime.
I'm using Python as a client language. After googling I tried to use many combinations but without success. This param... | [
".Net uses ISO 8601 time format when representing (or parsing) it in string format.\nExample: 2007-04-05T14:30\n"
] | [
7
] | [] | [] | [
".net",
"python",
"web_services"
] | stackoverflow_0005315730_.net_python_web_services.txt |
Q:
problem sending an HTTPGET with PyCurl
I am having problems converting the following curl command into PyCurl:
curl -k --cert /tmp/blablabla "https://blablabla"
My attempt so far is shown below:
c = pycurl.Curl()
c.setopt(pycurl.URL, submit_url)
c.setopt(pycurl.HTTPGET, 1)
b = StringIO.StringIO()
c.setopt(pycurl.W... | problem sending an HTTPGET with PyCurl | I am having problems converting the following curl command into PyCurl:
curl -k --cert /tmp/blablabla "https://blablabla"
My attempt so far is shown below:
c = pycurl.Curl()
c.setopt(pycurl.URL, submit_url)
c.setopt(pycurl.HTTPGET, 1)
b = StringIO.StringIO()
c.setopt(pycurl.WRITEFUNCTION, b.write)
c.setopt(pycurl.FOLLO... | [
"Add \"--libcurl example.c\" to your curl command line to get to see better what libcurl options curl uses, then you can copy them into your pycurl program rather swiftly.\n"
] | [
0
] | [] | [] | [
"curl",
"http_get",
"pycurl",
"python"
] | stackoverflow_0005315070_curl_http_get_pycurl_python.txt |
Q:
How do I get both functions to work at once in Python?
I'm really new to all this and right now I'm trying to get two functions to perform and print, but I can't seem to grasp it:
import datetime
def get_date(prompt):
while True:
user_input = raw_input(prompt)
try:
user_date =... | How do I get both functions to work at once in Python? | I'm really new to all this and right now I'm trying to get two functions to perform and print, but I can't seem to grasp it:
import datetime
def get_date(prompt):
while True:
user_input = raw_input(prompt)
try:
user_date = datetime.datetime.strptime(user_input, "%m-%d")
... | [
"\nOne error is due to calling checkNight(date) without the variable \"date\" having been defined.\ndatetime.strptime should read datetime.datetime.strptime. \nThe concatenation of a string and a date in that same line ('2011-'+date) might also cause an error.\nThe checkNight(date) function is not returning anythin... | [
2
] | [] | [] | [
"datetime",
"python",
"weekday"
] | stackoverflow_0005315873_datetime_python_weekday.txt |
Q:
Quick overview OOP php to python?
I am from PHP and quick learn OOP Python base PHP 's knowledge
for example I have a class
<?php
class Cat{
private $name;
private $age;
private $color;
public function getName()
{
return $this->name;
}
public function setName($value)
{
... | Quick overview OOP php to python? | I am from PHP and quick learn OOP Python base PHP 's knowledge
for example I have a class
<?php
class Cat{
private $name;
private $age;
private $color;
public function getName()
{
return $this->name;
}
public function setName($value)
{
$this->name = $value;
}
... | [
"class Cat(object):\n def __init__(self, name, age, color):\n self.name = name\n self.age = age\n self.color = color\n\nNo, I'm not joking.\n\nCut that getter/setter stuff, we have properties for a reason.\nIf you're going to have an attribute, you better have it all the time (i.e. from crea... | [
8,
3,
2,
2,
2
] | [] | [] | [
"python"
] | stackoverflow_0005315078_python.txt |
Q:
What is the best way of hide a password?
I have a Python script that is connecting to the database. To that, obviously, I need the password. I need to hide it somewhere.
My problem is that this code is stored in a folder that everybody who has access to the server can look. So, if I write this password encrypted i... | What is the best way of hide a password? | I have a Python script that is connecting to the database. To that, obviously, I need the password. I need to hide it somewhere.
My problem is that this code is stored in a folder that everybody who has access to the server can look. So, if I write this password encrypted in a file, in the code will appear the key to d... | [
"You're using a scripting language and accessing a database directly with a password. No matter what you do, at some level that password is going to be easily accessible. Obscuring it doesn't really buy you much.\nYou have to rely on the machine's security and permissions, and perhaps the database (restricting acce... | [
10,
7,
1,
0
] | [
"A more advanced idea is to do the mysql authentication manually. That is, learn the mysql protocol (it's a standard handshake with a challenege and a response) and do the procedure yourself. This way, you never send the password directly.\n"
] | [
-1
] | [
"passwords",
"python"
] | stackoverflow_0005315829_passwords_python.txt |
Q:
Re-using part of user input string that has matched a regular expression
I'm working on a Python project with user input, and want to reuse specific parts (i.e the part/s that have matched a regular expression) in the output, so a dialog could go something like:
Program: Hello, what have you been doing today?
User... | Re-using part of user input string that has matched a regular expression | I'm working on a Python project with user input, and want to reuse specific parts (i.e the part/s that have matched a regular expression) in the output, so a dialog could go something like:
Program: Hello, what have you been doing today?
User: I have been foobaring./I went foobaring./(anything else containing 'foobarin... | [
"If you surround the regex with parentheses (to make it a group), then you can access that group using match.group(1):\nIn [89]: import re\n\nIn [90]: gerund=re.compile(r'(?u)\\b([\\w-]+ing)\\b')\n\nIn [91]: sentence='I went foobaring'\n\nIn [92]: match=gerund.search(sentence)\n\nIn [93]: match.group(1)\nOut[93]: '... | [
2
] | [] | [] | [
"python",
"regex",
"string",
"substring"
] | stackoverflow_0005316505_python_regex_string_substring.txt |
Q:
Python hash holding file handles
So I'm working on a script that will automatically download certain files from IRC XDCC bots when run. These requests are asynchronous and there can be a varying number, depending on a config file so I wanted to keep the file handles in a hash table or library so they could easily... | Python hash holding file handles | So I'm working on a script that will automatically download certain files from IRC XDCC bots when run. These requests are asynchronous and there can be a varying number, depending on a config file so I wanted to keep the file handles in a hash table or library so they could easily be referenced based on who the file s... | [
"The problem is that the left side of an assignment statement must be an lvalue, that is something that the compiler knows has a memory address, like a variable. It is the same in other programming languages. The return value of a function is an rvalue, or a pure value.\nThese are other illegal assignments:\nf() = ... | [
0,
0
] | [] | [] | [
"filehandle",
"hashtable",
"irc",
"python"
] | stackoverflow_0005316685_filehandle_hashtable_irc_python.txt |
Q:
Getting the maximum value from dictionary
I'm facing problem with this. I have 10,000 rows in my dictionary and this is one of the rows
Example: A (8) C (4) G (48419) T (2) when printed out
I'd like to get 'G' as an answer, since it has the highest value.
I'm currently using Python 2.4 and I have no idea how to so... | Getting the maximum value from dictionary | I'm facing problem with this. I have 10,000 rows in my dictionary and this is one of the rows
Example: A (8) C (4) G (48419) T (2) when printed out
I'd like to get 'G' as an answer, since it has the highest value.
I'm currently using Python 2.4 and I have no idea how to solve this as I'm quite new in Python.
Thanks a l... | [
"Here's a solution that\n\nuses a regexp to scan all occurrences of an uppercase letter followed by a number in brackets \ntransforms the string pairs from the regexp with a generator expression into (value,key) tuples\nreturns the key from the tuple that has the highest value\n\nI also added a main function so tha... | [
3,
1,
1,
0,
0
] | [] | [] | [
"key_value_coding",
"max",
"python",
"python_2.4",
"rows"
] | stackoverflow_0004919787_key_value_coding_max_python_python_2.4_rows.txt |
Q:
generate a dependency tree of the inheritance hierarchy
i am trying to write a recursive algorithm to generate a dependency tree of the inheritance hierarchy of a class. Below is my sample code. The problem i am getting is when we the elements in the bases list are more than one, only the 1st element of the list a... | generate a dependency tree of the inheritance hierarchy | i am trying to write a recursive algorithm to generate a dependency tree of the inheritance hierarchy of a class. Below is my sample code. The problem i am getting is when we the elements in the bases list are more than one, only the 1st element of the list and its parent classes are printed.
def get_bases(klass):
b... | [
"The problem is here:\nfor item in bases:\n print item\n return get_bases(item)\n\nYou recurse into the item, and then immediately return without continuing through the for loop. You can replace with something like:\nfor item in bases:\n print item\n get_bases(item)\n\nor you could perhaps build up a tr... | [
4
] | [] | [] | [
"inheritance",
"python",
"recursion"
] | stackoverflow_0005316803_inheritance_python_recursion.txt |
Q:
python os.path.isdir() is slow on windows
We are experiencing really slow performance with os.path.isdir() method on windows.
The same function under osx is running in 0.3 sec vs 1.8 for windows when checking a lot of files.
Is there an alternative to os.path.isdir() that would be faster?
A:
I think the quickes... | python os.path.isdir() is slow on windows | We are experiencing really slow performance with os.path.isdir() method on windows.
The same function under osx is running in 0.3 sec vs 1.8 for windows when checking a lot of files.
Is there an alternative to os.path.isdir() that would be faster?
| [
"I think the quickest way to check on Windows is to call GetFileAttributes(). You could try this through ctypes and see if it is any faster.\nIf it is not faster then you'll probably just have to suck it down. And if it is faster then you have your solution.\n"
] | [
2
] | [] | [] | [
"python",
"windows"
] | stackoverflow_0005316928_python_windows.txt |
Q:
craps in python
I'm trying to simulate n games of craps. The code seems to make sense to me but I never get the right result. For example, if I put in n = 5 i.e. fives games the wins and losses sum to something greater than 5.
Here's how it's supposed to work: if initial roll is 2, 3, or 12, the player loses.... | craps in python | I'm trying to simulate n games of craps. The code seems to make sense to me but I never get the right result. For example, if I put in n = 5 i.e. fives games the wins and losses sum to something greater than 5.
Here's how it's supposed to work: if initial roll is 2, 3, or 12, the player loses. If the roll is 7 or... | [
"The problem is with\n if game():\n wins = wins + 1\n if not game():\n losses = losses + 1\n\nInstead, it should be\n if game():\n wins = wins + 1\n else:\n losses = losses + 1\n\nIn your code, you are simulating two games instead of one (by ca... | [
5,
3,
1,
0,
0
] | [] | [] | [
"dice",
"python"
] | stackoverflow_0005315981_dice_python.txt |
Q:
How do I create lists in Python while using object oriented programming?
I'm trying to create an initial attribute that also creates a list.
class Player(object):
"""A virtual player"""
def __init__(self, name, items, max_items = 5):
# still need to create item list
self._items = []
... | How do I create lists in Python while using object oriented programming? | I'm trying to create an initial attribute that also creates a list.
class Player(object):
"""A virtual player"""
def __init__(self, name, items, max_items = 5):
# still need to create item list
self._items = []
self.name = name
self.max_items = max_items
print "\nA new p... | [
"self._items = [] is absolutely correct.\nBut you have some logical errors in your code:\nif len(self.items) > 1: should be if len(self.items) > 0: or even better if self.items: - you want to check if theres 1+ in the item, not if there's more than one item in the list.\n",
"try:\n inp = raw_input # Python 2.... | [
2,
1,
0
] | [] | [] | [
"list",
"oop",
"python"
] | stackoverflow_0005317206_list_oop_python.txt |
Q:
How to remove \x1b from a string in python
I have a text file which contains a list of files.
I want to copy the files to certain location.
I have the following code
f= open("filename")
l = f.readline()
while l:
cmd = "cp {0}/{1} {2}".format(indir,l.strip(),outdir)
commands.getstatusoutput(cmd)
Now when I... | How to remove \x1b from a string in python | I have a text file which contains a list of files.
I want to copy the files to certain location.
I have the following code
f= open("filename")
l = f.readline()
while l:
cmd = "cp {0}/{1} {2}".format(indir,l.strip(),outdir)
commands.getstatusoutput(cmd)
Now when I read the file, each line is padded with "\x1b[0... | [
"While it's possible to make Python do this for you. I find it odd that you have VT100 escape sequences in your file. In comments you show the command you use to generate the file. I would suggest doing most of your file manipulation using the shutil module\n and the os.listdir function.\nBut, if you want to use ls... | [
0
] | [] | [] | [
"padding",
"python"
] | stackoverflow_0005317294_padding_python.txt |
Q:
How to force valid properties & values to be set on all files being added/updated in SVN?
Is it possible to force a user who is either committing a change or adding a new file to set valid values for svn:keywords (e.g. Date, Author, & URL)?
It would be great if this behavior could be included in a pre-commit hook,... | How to force valid properties & values to be set on all files being added/updated in SVN? | Is it possible to force a user who is either committing a change or adding a new file to set valid values for svn:keywords (e.g. Date, Author, & URL)?
It would be great if this behavior could be included in a pre-commit hook, preferably written in python.
| [
"check this out:\nhttp://mr-ats.tigris.org/svn/mr-ats/trunk/src/hooks/property-check/\nlogin is: guest /[no password]\n"
] | [
0
] | [] | [] | [
"pre_commit_hook",
"properties",
"python",
"svn"
] | stackoverflow_0005316744_pre_commit_hook_properties_python_svn.txt |
Q:
how to use bazaar to access the same folder on 2 computers
hey guys, i use two computers frequently, a laptop with ubuntu 10.10 and a pc with windows 7. i want to be able to access the folders from both pc's. then programming will be less annoying. someone told me bazaar was the best way to do this.
A:
If you're... | how to use bazaar to access the same folder on 2 computers | hey guys, i use two computers frequently, a laptop with ubuntu 10.10 and a pc with windows 7. i want to be able to access the folders from both pc's. then programming will be less annoying. someone told me bazaar was the best way to do this.
| [
"If you're looking to make programming on two computers \"less annoying,\" you probably are looking for some version control system. Bazaar (bzr) is one such system, as are Subversion (svn), Mercurial (hg), and Git (git).\nAll of these systems will make it easy for you to record your changes on one computer and ap... | [
2,
0,
0
] | [] | [] | [
"cloud_hosting",
"java",
"python",
"version_control"
] | stackoverflow_0005317301_cloud_hosting_java_python_version_control.txt |
Q:
How to profile PyCuda code in Linux?
I have a simple (tested) pycuda app and am trying to profile it. I've tried NVidia's Compute Visual Profiler, which runs the program 11 times, then emits this error:
NV_Warning: Ignoring the invalid profiler config option: fb0_subp0_read_sectors
Error : Profiler data file '/hom... | How to profile PyCuda code in Linux? | I have a simple (tested) pycuda app and am trying to profile it. I've tried NVidia's Compute Visual Profiler, which runs the program 11 times, then emits this error:
NV_Warning: Ignoring the invalid profiler config option: fb0_subp0_read_sectors
Error : Profiler data file '/home/jguy/proj/gpu/tdbp/pyArch/temp_compute_p... | [
"When using import pycuda.autoinit, it is important to have pycuda.autoinit.context.detach() at the end of the program. This fixed the problem.\n"
] | [
1
] | [] | [] | [
"cuda",
"gpgpu",
"profiling",
"pycuda",
"python"
] | stackoverflow_0005317691_cuda_gpgpu_profiling_pycuda_python.txt |
Q:
Python "IN PLACE" functions
What's the particular reason that some functions in Python operate "IN PLACE", like [].sort and [].reverse, while some others like [].append not?
A:
According to my Programming Python 4th edition:
By default, pop is equivalent to
fetching, and then deleting, the last
item at offs... | Python "IN PLACE" functions | What's the particular reason that some functions in Python operate "IN PLACE", like [].sort and [].reverse, while some others like [].append not?
| [
"According to my Programming Python 4th edition:\n\nBy default, pop is equivalent to\n fetching, and then deleting, the last\n item at offset −1. With an argument,\n pop deletes and returns the item at\n that offset—list.pop(-1) is the same\n as list.pop(). For in-place change\n operations like append, insert... | [
7,
1
] | [] | [] | [
"in_place",
"python"
] | stackoverflow_0005317817_in_place_python.txt |
Q:
Using built-in libxml2 on Mac 10.6.x
I understand that Mac OS 10.6.x contains a built-in version of libxml2.
I feel pretty stupid here, but then why doesn't this work?
python -c "import libxml2"
Is there some step I'm missing that makes the library accessible in Python?
which python
...returns:
/usr/bin/python... | Using built-in libxml2 on Mac 10.6.x | I understand that Mac OS 10.6.x contains a built-in version of libxml2.
I feel pretty stupid here, but then why doesn't this work?
python -c "import libxml2"
Is there some step I'm missing that makes the library accessible in Python?
which python
...returns:
/usr/bin/python2.6 -> ../../System/Library/Frameworks/Pyt... | [
"You almost certainly have libxml2 -- which comes with the OS -- but you're likely missing the Python bindings, which don't seem to. That would be a shared library named something like \"libxml2mod.so\" inside the /Library/Python or /Library/Frameworks/Python trees. I don't think there's any way to avoid installing... | [
0,
0
] | [] | [] | [
"libxml2",
"macos",
"osx_snow_leopard",
"python"
] | stackoverflow_0005316871_libxml2_macos_osx_snow_leopard_python.txt |
Q:
Guidelines to write fast code for PyPy's JIT
PyPy's JIT can make Python code execute much faster than CPython. Are there a set of guidelines for writing code that can be optimised better by the JIT compiler? For example, Cython can compile some static code into C++, and it has guidelines to write efficient code. A... | Guidelines to write fast code for PyPy's JIT | PyPy's JIT can make Python code execute much faster than CPython. Are there a set of guidelines for writing code that can be optimised better by the JIT compiler? For example, Cython can compile some static code into C++, and it has guidelines to write efficient code. Are there a set of good practices for PyPy? I know ... | [
"PyPy wiki's at BitBucket has a section on JIT Friendliness. Some blog posts offer further advice on making code run fast in PyPy, but AFAIK the idea is that idiomatic code that doesn't force interpreting/realizing frames should be fast and is a bug if it isn't.\nI know that for 3, some \"assert x > 0\" or similar ... | [
13
] | [] | [] | [
"compilation",
"jit",
"optimization",
"pypy",
"python"
] | stackoverflow_0005318157_compilation_jit_optimization_pypy_python.txt |
Q:
retrieving essential data from a webpage using python
Following is a part of a webpage i downloaded with urlretrieve (urllib). I want to write only this data from the webpage given below in to another text file as:
ENGINEERING MATHEMATICS-IV, 4 ,36 ,40 , F
ENVIRONMENTAL STUDIES, 47, 36, 83 , p
...
..
.
likeways..... | retrieving essential data from a webpage using python | Following is a part of a webpage i downloaded with urlretrieve (urllib). I want to write only this data from the webpage given below in to another text file as:
ENGINEERING MATHEMATICS-IV, 4 ,36 ,40 , F
ENVIRONMENTAL STUDIES, 47, 36, 83 , p
...
..
.
likeways..
which module should i use?, which all commands??
thanx in ... | [
"import urllib2\nimport BeautifulSoup\n\ndef main():\n infname = 'htmltable.html'\n outfname = 'courses.txt'\n\n with open(infname) as inf:\n html = inf.read()\n\n doc = BeautifulSoup.BeautifulSoup(html)\n table = doc.find('table',{'id':'content'})\n\n with open(outfname, 'w') as outf:\n... | [
1
] | [] | [] | [
"beautifulsoup",
"get",
"python",
"urllib",
"urllib2"
] | stackoverflow_0005315856_beautifulsoup_get_python_urllib_urllib2.txt |
Q:
How to combine two table rows where a series of conditions are met
I am working on a parsing program that parses info from two files into a
sqlite3 table.
Lets say the table has the following values:
filename, value2, value3, value4
There are never more than two filename values in the table,
I would like to write ... | How to combine two table rows where a series of conditions are met | I am working on a parsing program that parses info from two files into a
sqlite3 table.
Lets say the table has the following values:
filename, value2, value3, value4
There are never more than two filename values in the table,
I would like to write a sql query that will join two rows when the following
conditions are tr... | [
"x below is the table name\nselect a.*, b.*\nfrom x as a\ninner join x as b\n on a.filename<b.filename\n and a.value2 = b.value2\n and a.value3 = b.value3\n and a.value4 = b.value4\nunion all\nselect a.*, b.*\nfrom x as a\nleft join x as b\n on a.filename!=b.filename\n and a.value2 = b.val... | [
2
] | [] | [] | [
"database",
"python",
"sql",
"sqlite"
] | stackoverflow_0005318538_database_python_sql_sqlite.txt |
Q:
Indentation standards when writing django Application
I am using notepad++ as an editor, and I find that it is easier to follow relations in my code when I use tabs.
1- What is the standard when it comes to putting indentation in the django code (tabs or space)?
2- Do you recommend a code editor other than notepad... | Indentation standards when writing django Application | I am using notepad++ as an editor, and I find that it is easier to follow relations in my code when I use tabs.
1- What is the standard when it comes to putting indentation in the django code (tabs or space)?
2- Do you recommend a code editor other than notepad++?
| [
"Python PEP 8 encourages 4 spaces, no tabs. \nMany editors support this, including: Vim, Emacs, Komodo, WingWare, and PyCharm to name just a few.\nI should point out that I'm not specifically discouraging you from using tabs, but addressing your question regarding indentation standards.\n",
"Definitely follow PE... | [
3,
3,
2,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0005318640_django_python.txt |
Q:
Is there an easy way in Plone to get email notifications when new users join the portal?
I want to get email notifications to the portal email address whenever a new user joins the portal.
My guess is that I should code a new product to do that.
Does such product already exist (for Plone 4)?
I checked content rule... | Is there an easy way in Plone to get email notifications when new users join the portal? | I want to get email notifications to the portal email address whenever a new user joins the portal.
My guess is that I should code a new product to do that.
Does such product already exist (for Plone 4)?
I checked content rules, but AFAICT it could work only if I made the users contentish themselves with something like... | [
"I don't think such a product already exists.\nIt should be trivial to create a package that adds a content rule condition, that would let you write a content rule for the Products.PluggableAuthService.interfaces.events.IPrincipalCreatedEvent event.\nThe Plone knowledgebase documents how to create such a package.\n... | [
5,
1,
1,
0
] | [] | [] | [
"notifications",
"plone",
"python"
] | stackoverflow_0005070055_notifications_plone_python.txt |
Q:
Using Python to extract dictionary keys within a list
I received a list when inputting the following URL - http://api.twitter.com/1/trends/44418.json
The list contains multiple dictionaries, and I'm a bit confused with the list structure. I'm trying to obtain the values associated with the 'name' key.
For example:... | Using Python to extract dictionary keys within a list | I received a list when inputting the following URL - http://api.twitter.com/1/trends/44418.json
The list contains multiple dictionaries, and I'm a bit confused with the list structure. I'm trying to obtain the values associated with the 'name' key.
For example:
"name":"#throwagrenade"
"name":"Rebecca Black"
"name... | [
"The first thing I would do when working with a big lump of json, is try to get it into a more readable format. This online json formatting tool should do the job.\nHere's some code that will get all the trend names:\nimport urllib2\nimport json\n\nurl = 'http://api.twitter.com/1/trends/44418.json'\n\n# download th... | [
22,
8,
4,
1
] | [] | [] | [
"dictionary",
"json",
"list",
"python",
"twitter"
] | stackoverflow_0005318747_dictionary_json_list_python_twitter.txt |
Q:
Constructor B is not called in an A -> B -> C inheritance chain
I have the following inheritance chain:
class Foo(object):
def __init__(self):
print 'Foo'
class Bar(Foo):
def __init__(self):
print 'Bar'
super(Foo, self).__init__()
class Baz(Bar):
def __init__(self):
pr... | Constructor B is not called in an A -> B -> C inheritance chain | I have the following inheritance chain:
class Foo(object):
def __init__(self):
print 'Foo'
class Bar(Foo):
def __init__(self):
print 'Bar'
super(Foo, self).__init__()
class Baz(Bar):
def __init__(self):
print 'Baz'
super(Bar, self).__init__()
When instantiating Baz... | [
"The call to super() takes the current class as the first argument, not the super class (super() works that out for itself). In this case, the following should fix it... note the change to both super() calls:\nclass Foo(object):\n def __init__(self):\n print 'Foo'\n\nclass Bar(Foo):\n def __init__(self... | [
9
] | [] | [] | [
"constructor",
"inheritance",
"oop",
"python"
] | stackoverflow_0005318849_constructor_inheritance_oop_python.txt |
Q:
Crawler produces duplicates when run twice?
I use the crawler framework "scrapy" in python and I use the pipelines.py file to store my items in a json format to a file.The code for doing this is given below
import json
class AYpiPipeline(object):
def __init__(self):
self.file = open("a11ypi_dict.json","ab+")
... | Crawler produces duplicates when run twice? | I use the crawler framework "scrapy" in python and I use the pipelines.py file to store my items in a json format to a file.The code for doing this is given below
import json
class AYpiPipeline(object):
def __init__(self):
self.file = open("a11ypi_dict.json","ab+")
# this method is called to process an item after... | [
"You can filter out duplicates by using some custom middleware, e.g, this. To actually use this in your spider, though, you'll need two more things: some way of assigning ids to items so that you the filter can identify duplicates, and some way of persisting the set of visited ids between spider runs. The second ... | [
1
] | [] | [] | [
"python",
"scrapy",
"web_crawler"
] | stackoverflow_0005317554_python_scrapy_web_crawler.txt |
Q:
Is there something like a "symbolic link" (in *nixes terms) but for objects in ZODB in Plone?
Suppose I have an object in /school1/document-rules.
Suppose in another context, /school2, I need to have the same document-rules that is available in /school1/document-rules.
In ZODB, having /school1/document-rules and /... | Is there something like a "symbolic link" (in *nixes terms) but for objects in ZODB in Plone? | Suppose I have an object in /school1/document-rules.
Suppose in another context, /school2, I need to have the same document-rules that is available in /school1/document-rules.
In ZODB, having /school1/document-rules and /school2/document-rules means I have two different objects.
I would like to know if it's possible to... | [
"SimpleAlias does what you want. I've used it and it works well. You could also look at collective.alias\n",
"ZODB handles references transparently as you would expect in plain Python. You have a nice explanation here.\nYou should watch out for multiple references for the same object when you want to delete the o... | [
7,
1,
1
] | [] | [] | [
"plone",
"python",
"symlink",
"zodb",
"zope"
] | stackoverflow_0004832664_plone_python_symlink_zodb_zope.txt |
Q:
Python threading question
I have some python application with 2 threads. Each thread operates within a separate gui. The GUIs need to operate independently without blocking. I am trying to figure out how to make thread_1 trigger an event to happen in thread_2?
Below is some code I want function foo to trigger f... | Python threading question | I have some python application with 2 threads. Each thread operates within a separate gui. The GUIs need to operate independently without blocking. I am trying to figure out how to make thread_1 trigger an event to happen in thread_2?
Below is some code I want function foo to trigger function bar in the simplest, mo... | [
"Without knowing what you're doing and what GUI framework you're using, I can't get into much more detail, but from your problem's code snippet, it sounds like you're looking for something called conditional variables. \nPython comes with them included by default in the threading module, under threading.Condition Y... | [
1,
0,
0
] | [] | [] | [
"multithreading",
"python"
] | stackoverflow_0005319033_multithreading_python.txt |
Q:
What is the process for using MySQL from Python in Windows?
I come from a PHP background where MySQL easily works from PHP, and don't the process for getting MySQL to work from Python. From all the research i did and reading of similar yet non-exact questions, it seems to me that there are different ways to achie... | What is the process for using MySQL from Python in Windows? | I come from a PHP background where MySQL easily works from PHP, and don't the process for getting MySQL to work from Python. From all the research i did and reading of similar yet non-exact questions, it seems to me that there are different ways to achieve this, which makes it even harder for me to wrap my head around... | [
"If you just want to use the DBAPI, then here's a simple snippet explaining how to issue a SELECT query.\nimport MySQLdb\ndb = MySQLdb.connect(host=\"host\", user=\"username\", passwd=\"your-pass\", db=\"the-db-name\")\n\nTo perform a query, you first need a cursor, and then you can execute queries on it:\ncursor =... | [
2
] | [] | [] | [
"database",
"database_connection",
"mysql",
"python"
] | stackoverflow_0005319128_database_database_connection_mysql_python.txt |
Q:
How can I achieve something like "from foo.bar import baz.qux"?
I have a few packages that include modules named util, so that it becomes difficult to tell which util module is referred to if you see something like this:
util.some_func()
What I would like to do is something like this:
views.util.some_func()
...b... | How can I achieve something like "from foo.bar import baz.qux"? | I have a few packages that include modules named util, so that it becomes difficult to tell which util module is referred to if you see something like this:
util.some_func()
What I would like to do is something like this:
views.util.some_func()
...but I can't figure out a good way to import this. Of course this does... | [
"Would this work for you:\n from apture.main.view import util as view_util\n\n"
] | [
4
] | [] | [] | [
"import",
"module",
"package",
"python",
"python_2.x"
] | stackoverflow_0005319337_import_module_package_python_python_2.x.txt |
Q:
Numpy conditional arithmetic operations on two arrays
Still trying to earn my numpy stripes: I want to perform an arithmetic operation on two numpy arrays, which is simple enough:
return 0.5 * np.sum(((array1 - array2) ** 2) / (array1 + array2))
Problem is, I need to be able to specify the condition that, if both... | Numpy conditional arithmetic operations on two arrays | Still trying to earn my numpy stripes: I want to perform an arithmetic operation on two numpy arrays, which is simple enough:
return 0.5 * np.sum(((array1 - array2) ** 2) / (array1 + array2))
Problem is, I need to be able to specify the condition that, if both arrays are element-wise 0 at the same element i, don't per... | [
"return numpy.select([array1 == array2, array1 != array2], [0.5 * np.sum(((array1 - array2) ** 2) / (array1 + array2)), 0])\n\nshould do the trick... numpy.where might also be used.\n",
"Just replace np.sum() by np.nansum():\nreturn 0.5 * np.nansum(((array1 - array2) ** 2) / (array1 + array2))\n\nnp.nansum() trea... | [
3,
3,
0
] | [] | [] | [
"arrays",
"conditional",
"math",
"numpy",
"python"
] | stackoverflow_0005319257_arrays_conditional_math_numpy_python.txt |
Q:
Where do I place the .egg (Python)?
I'm trying to install the zope interface script for Python. However, the only download I saw was a .egg file type. I'm running Windows Python 2.7, where should I place this file for the Zope interface to work properly with my Python?
A:
Or, if you're like me and have an irrati... | Where do I place the .egg (Python)? | I'm trying to install the zope interface script for Python. However, the only download I saw was a .egg file type. I'm running Windows Python 2.7, where should I place this file for the Zope interface to work properly with my Python?
| [
"Or, if you're like me and have an irrational hatred of the python egg cache and how poorly it handles effective user ids, install the egg unzipped via:\neasy_install -Z zopepackage.egg\n\n",
"If you have easy_install, simply run:\neasy_install zopepackage.egg\n\nIf you don't have that, you could also just unzip ... | [
3,
2
] | [] | [] | [
"egg",
"python",
"zope.interface"
] | stackoverflow_0005319215_egg_python_zope.interface.txt |
Q:
Python: format datetime efficiently whilst leaving it as a datetime object
I want to be able to format a datetime object, while leaving it as an object. I have worked a way to do it, but it doesn't seem very efficient.
My specific aim is to limit the extra digits on the seconds to 2. This is how I am currently do... | Python: format datetime efficiently whilst leaving it as a datetime object | I want to be able to format a datetime object, while leaving it as an object. I have worked a way to do it, but it doesn't seem very efficient.
My specific aim is to limit the extra digits on the seconds to 2. This is how I am currently doing it:
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
now_frmt = d... | [
"You could do this to subtract off the microseconds:\nnow = datetime.datetime.now()\nnow_frmt = now - datetime.timedelta(microseconds=now.microsecond)\n\nTo round to the nearest second you can do the following:\nnow = datetime.datetime.now()\ndelta = (0 if now.microsecond < 500000 else 1000000) - now.microsecond\nn... | [
2
] | [] | [] | [
"datetime",
"formatting",
"python"
] | stackoverflow_0005319465_datetime_formatting_python.txt |
Q:
Variables and class properties don't show using automodule in Python Sphinx
I am wondering why I am not able to see class properties when using automodule directive in Sphinx...Even if a propertie has a docstring.
Same thing with Django settings CONSTANTS, they don't shown.
I use:
.. automodule:: settings
:memb... | Variables and class properties don't show using automodule in Python Sphinx | I am wondering why I am not able to see class properties when using automodule directive in Sphinx...Even if a propertie has a docstring.
Same thing with Django settings CONSTANTS, they don't shown.
I use:
.. automodule:: settings
:members:
:show-inheritance:
:undoc-members:
I split settings into module
setti... | [
"docstrings normally don't apply to class properties, but the autodoc extension to Sphinx is able to if you put it after the field. You can also use this special syntax, before the field:\n#: Documentation for my_field. You can\n#: use one or more lines as well.\nmy_field = \"something\"\n\nOther things to check ... | [
5
] | [] | [] | [
"django",
"module",
"python",
"python_sphinx"
] | stackoverflow_0005319484_django_module_python_python_sphinx.txt |
Q:
Python Regex doesn't work as expected
i've crafted this regular expression:
<entry>\\n<(\w+)>(.+?)</\w+>\\n</entry>
to parse the following RSS Feed:
<?xml version="1.0" encoding="UTF-8"?>\n<feed version="0.3" xmlns="http://purl.org/atom/ns#">\n<title>Gmail - Inbox for g.bargelli@gmail.com</title>\n<tagline>New me... | Python Regex doesn't work as expected | i've crafted this regular expression:
<entry>\\n<(\w+)>(.+?)</\w+>\\n</entry>
to parse the following RSS Feed:
<?xml version="1.0" encoding="UTF-8"?>\n<feed version="0.3" xmlns="http://purl.org/atom/ns#">\n<title>Gmail - Inbox for g.bargelli@gmail.com</title>\n<tagline>New messages in your Gmail Inbox</tagline>\n<full... | [
"Before the regex compiler sees a string, Python has already processed the slash-escapes, therefore you'd have to escape it twice (e.g. \\\\\\\\n for \\\\n). However, Python has a handy notation for exactly this sort of thing, just stick an r before the string:\nregex = re.compile(r\"\"\"<entry>\\\\n<(\\w+)>(.+?)<... | [
5,
4,
2,
1
] | [] | [] | [
"python",
"regex",
"rss"
] | stackoverflow_0005319571_python_regex_rss.txt |
Q:
Mocking chained calls in Python
I am trying to test the following class using unittest and the mock library:
class Connection(object):
def __init__(self, cookie):
self.connect = None
self.session = Session()
self.session.load(cookie)
# do some stuff with self.session
self.some_info = self.s... | Mocking chained calls in Python | I am trying to test the following class using unittest and the mock library:
class Connection(object):
def __init__(self, cookie):
self.connect = None
self.session = Session()
self.session.load(cookie)
# do some stuff with self.session
self.some_info = self.session.data['the_info']
How could I ... | [
"Assume Connection is located in module package.module.connection\nThe following code should be how you would test your session:\nimport mock\n\n\nclass TestConnection(unittest.TestCase):\n\n @mock.patch('package.module.connection.Session')\n def test_some_info_on_session_is_set(self, fake_session):\n ... | [
3
] | [] | [] | [
"mocking",
"python",
"python_mock",
"unit_testing"
] | stackoverflow_0005319274_mocking_python_python_mock_unit_testing.txt |
Q:
mainloop prevents Tkinter application to run from the IDLE
When using Ubuntu, I am able to play with Tk in real-time, by writing commands in the IDLE.
On Windows, I need to call root.mainloop() to spawn a window, and the loop keeps me from running any code from IDLE.
Is it a matter of platform, or am I doing som... | mainloop prevents Tkinter application to run from the IDLE | When using Ubuntu, I am able to play with Tk in real-time, by writing commands in the IDLE.
On Windows, I need to call root.mainloop() to spawn a window, and the loop keeps me from running any code from IDLE.
Is it a matter of platform, or am I doing something wrong?
| [
"I don't have a complete solution or answer, but here is something that I found on the subject:\nFrom this page: Thinking in Tkinter\n\nNote that you should not run these programs under IDLE. IDLE is itself a Tkinter application, with its own \"mainloop\" that will conflict with the mainloop in these programs. If... | [
1
] | [] | [] | [
"python",
"tkinter"
] | stackoverflow_0005020533_python_tkinter.txt |
Q:
Django User model validators
Can anyone suggest a clever way to add validators to the Django User model? I create files and directories based on first_name, last_name, and username, so I'd like to carefully control what characters are allowed in there using the same standard validators I have on other models. I ... | Django User model validators | Can anyone suggest a clever way to add validators to the Django User model? I create files and directories based on first_name, last_name, and username, so I'd like to carefully control what characters are allowed in there using the same standard validators I have on other models. I can't see an easy way to do this.
... | [
"Really you should be subclassing the User object and adding validators the correct way, but if you like to live dangerously you could try monkey patching the User class as well.\nYou might put this in your app's __init__.py file...\nfrom django.contrib.auth.models import User\n\ndef validate_for_fs(value): # <-- I... | [
2
] | [] | [] | [
"django",
"python",
"validation"
] | stackoverflow_0005318787_django_python_validation.txt |
Q:
django cached session
I have two questions:
1) I am wondering whether using
django.contrib.sessions.backends.cache
for storing sessions really improves performance of a website? Assuming there are around 25k simultaneous users. Each user making many database changes (for example browser game). Is the difference ... | django cached session | I have two questions:
1) I am wondering whether using
django.contrib.sessions.backends.cache
for storing sessions really improves performance of a website? Assuming there are around 25k simultaneous users. Each user making many database changes (for example browser game). Is the difference even noticable?
2) Again wh... | [
"re 1.\nfrom my experience difference is huge.\nin your scenario, every time session is created or changed - this will generate a db write.\neach time user is accessing a site - a db read will be generated.\nmoving this out of the DB - saves at least one query per request.\nthis additional traffic, plus your normal... | [
6
] | [] | [] | [
"caching",
"django",
"django_sessions",
"memcached",
"python"
] | stackoverflow_0005319843_caching_django_django_sessions_memcached_python.txt |
Q:
Decode json and Iterate through items in django template
Hi I am using simplejson to import some json and then decode for use within a django template,
this is the decoded json:
{u'ServerID': 1, u'Cache': {u'CacheBusted': False, u'FromCache': True}, u'Result': [{u'Url': u'http://listen.grooveshark.com/playlist/Sou... | Decode json and Iterate through items in django template | Hi I am using simplejson to import some json and then decode for use within a django template,
this is the decoded json:
{u'ServerID': 1, u'Cache': {u'CacheBusted': False, u'FromCache': True}, u'Result': [{u'Url': u'http://listen.grooveshark.com/playlist/Soul_Power/399134', u'Cache': {u'FromCache': True}, u'PlaylistID'... | [
"Once you've used Python's json or simplejson module to load the JSON data into Python objects, everything should just work in your template.\nBefore sending things to your template I would pull out the results like so...\ndef foo_view(request):\n ....\n decoded_json = json.loads(json_string)\n return rend... | [
13,
0
] | [] | [] | [
"django",
"json",
"loops",
"python",
"simplejson"
] | stackoverflow_0005319896_django_json_loops_python_simplejson.txt |
Q:
Is there any other way to set a dict value using python?
This is my code:
a={}
a['b']=0
print a['b']
And this is my other code (that is wrong):
a={}
a.b=0
print a.b
Is there any other way to set the value associated with a key in a python dict?
A:
a = {'b':0}
or
a = dict([('b',0)])
or
a = dict.fromkeys(['b'... | Is there any other way to set a dict value using python? | This is my code:
a={}
a['b']=0
print a['b']
And this is my other code (that is wrong):
a={}
a.b=0
print a.b
Is there any other way to set the value associated with a key in a python dict?
| [
"a = {'b':0}\n\nor \na = dict([('b',0)])\n\nor\na = dict.fromkeys(['b'], 0)\n\nor\na = {}\nb = {'b':0}\na.update(b)\n\nor\na = {}\na.__setitem__('b',0)\n\n"
] | [
3
] | [] | [] | [
"dictionary",
"python"
] | stackoverflow_0005320174_dictionary_python.txt |
Q:
Implementation of a C pre-processor in Python or JavaScript?
Is there a known implementation of the C pre-processor tool implemented either in Python or JavaScript? I am looking for a way to robustly pre-process C (and C like) source code and want to be able to process, for example, conditional compilation and mac... | Implementation of a C pre-processor in Python or JavaScript? | Is there a known implementation of the C pre-processor tool implemented either in Python or JavaScript? I am looking for a way to robustly pre-process C (and C like) source code and want to be able to process, for example, conditional compilation and macros without invoking an external CPP tool or native code library. ... | [
"Check out pypreprocessor\nIt can also be found on PYPI (Python Package Index) so it can be downloaded directly using pip.\nIf you're looking to use #define and #ifdef statements to do simple conditional compilation it should meet your needs. You can either run it as a standalone script and specify an input file (t... | [
7,
6,
2,
1,
0
] | [] | [] | [
"c",
"javascript",
"preprocessor",
"python"
] | stackoverflow_0004350764_c_javascript_preprocessor_python.txt |
Q:
Help with a number histogram in python?
I'm trying to make a histogram that will take two lists as values ([x],[y]). The program will then compare the two lists and create a new list [z] where z1 is the number of values in x that are smaller then or equal to y1, zk+1 is the number of values in x that are greater t... | Help with a number histogram in python? | I'm trying to make a histogram that will take two lists as values ([x],[y]). The program will then compare the two lists and create a new list [z] where z1 is the number of values in x that are smaller then or equal to y1, zk+1 is the number of values in x that are greater than yk, zi (for 1 < i < k+1) is the number of... | [
"First step:\ndef howManyIn(x, lo, hi):\n return sum(lo<i<=hi for i in x)\n\nhowManyIn([1,2,3,4,5], 2, 4) # -> 2\n\n"
] | [
0
] | [] | [] | [
"python"
] | stackoverflow_0005319167_python.txt |
Q:
best way to write a python socket server
i want to create a python socket server to send and get data to html5 ,
what is the best way to do it , a python socket lib ? or a simple code ?
thanks
A:
@srgerg's socket documentation is useful, but if you want to handle multiple sockets simultaneously, you'll also n... | best way to write a python socket server | i want to create a python socket server to send and get data to html5 ,
what is the best way to do it , a python socket lib ? or a simple code ?
thanks
| [
"@srgerg's socket documentation is useful, but if you want to handle multiple sockets simultaneously, you'll also need other mechanisms, such as select, epoll, or kqueue (depending upon your platform). (You could also spawn multiple processes using fork, or threads if the python threading implementation meets your ... | [
0
] | [] | [] | [
"python",
"sockets"
] | stackoverflow_0005320396_python_sockets.txt |
Q:
How to remove python assertion when compiling in cython?
so, here is my problem:
I code in python, but I need to improve performance in some part of my code that are too slow. A good(and easy) solution seems to be using cython; I tried it and got good results.
The issue is that I use assert statement in my python ... | How to remove python assertion when compiling in cython? | so, here is my problem:
I code in python, but I need to improve performance in some part of my code that are too slow. A good(and easy) solution seems to be using cython; I tried it and got good results.
The issue is that I use assert statement in my python code. Before using cython, I could compile my python code with... | [
"Cython skips the assertions if you define the C preprocessor macro PYREX_WITHOUT_ASSERTIONS. So pass -DPYREX_WITHOUT_ASSERTIONS to the C compiler when compiling the generated C file. How to to this depends on your build process.\n"
] | [
10
] | [
"Use pypreprocessor\nWhich can also be found on PYPI (Python Package Index) and be fetched using pip.\nHere's the implementation:\nfrom pypreprocessor import pypreprocessor\n\npypreprocessor.parse()\n\n#define debug\n\n#ifdef debug\n...place assert to be removed here...\n#endif\n\nThis essentially works the same as... | [
-1
] | [
"assert",
"cython",
"python"
] | stackoverflow_0004285237_assert_cython_python.txt |
Q:
how to set a python function in a dict
this is my code:
a= {'u':exec("def u(str):return Unicode(str,'utf-8')"),}
print a
but it show error :
SyntaxError: invalid syntax
(mysite)zjm1126@zjm1126-G41MT-S2:~/桌面/test$ python a.py
File "a.py", line 5
a= {'u':exec("def u(str):return Unicode(str,'utf-8')"),}
... | how to set a python function in a dict | this is my code:
a= {'u':exec("def u(str):return Unicode(str,'utf-8')"),}
print a
but it show error :
SyntaxError: invalid syntax
(mysite)zjm1126@zjm1126-G41MT-S2:~/桌面/test$ python a.py
File "a.py", line 5
a= {'u':exec("def u(str):return Unicode(str,'utf-8')"),}
^
SyntaxError: invalid syntax
i wi... | [
"Alternatives would be to store the function instead, or the code as text:\na= {'u': lambda x: Unicode(x,'utf-8')}\n\nor \na= {'u':\"def u(str):return Unicode(str,'utf-8')\",}\n\nand then execute it as\nexec(a['u'])\n\n",
"exec does not return a value; instead, it evaluates some code in the current context (by de... | [
1,
0,
0
] | [] | [] | [
"dictionary",
"python"
] | stackoverflow_0005320774_dictionary_python.txt |
Q:
Dive into Django right after scratching the surface of of Python, good choice?
Little bite background: I joined a software company three years ago after graduated with art degree. It is fair to say I had not touched any code and never thought of that program thing before I joined the software company.
At the soft... | Dive into Django right after scratching the surface of of Python, good choice? | Little bite background: I joined a software company three years ago after graduated with art degree. It is fair to say I had not touched any code and never thought of that program thing before I joined the software company.
At the software company I dabbled into HTML, CSS, JS and SQL, and it turned out learning those ... | [
"It's a great choice. I might even argue it's a great way to learn python, because the documentation for Django is so amazing, and the path to progress so clear-cut and defined, that it keeps things interesting as well as structured.\nI learned python on django, with no python/CS background as well. At first, I cou... | [
4
] | [] | [] | [
"django",
"python"
] | stackoverflow_0005320811_django_python.txt |
Q:
python for loop
so evidently you write for loops in python int he following:
for i in range(1, 5):
print i
but what if I'm actually using i as a counting trick and I specifically wanna do something like:
for (int i = 100; i > 20; i--)
or
for (int i = 0; i < 20 ; i += 2)
do you seriously have to write this ... | python for loop | so evidently you write for loops in python int he following:
for i in range(1, 5):
print i
but what if I'm actually using i as a counting trick and I specifically wanna do something like:
for (int i = 100; i > 20; i--)
or
for (int i = 0; i < 20 ; i += 2)
do you seriously have to write this in the body of the lo... | [
"Different languages use different semantics to say the same thing. You can use the range function in several ways and it has as its arguments:\nrange(start, stop, jump)\n\nSo I can do\nrange(10, 1, -2)\n\nto get a list like:\n[10, 8, 6, 4, 2]\n\nUsing the three arguments of range you can get back to your counting... | [
5,
3,
1
] | [] | [] | [
"for_loop",
"python",
"signature"
] | stackoverflow_0005320846_for_loop_python_signature.txt |
Q:
how to call the method in the same dict using python
this is my code :
a= {'u': lambda x: x*x,'b':self.u(5)}
print a['u'](5)
print a['b']
but it show error :
Traceback (most recent call last):
File "a.py", line 6, in <module>
a= {'u': lambda x: x*x,'b':self.u(5)}
NameError: name 'self' is not defined
so ... | how to call the method in the same dict using python | this is my code :
a= {'u': lambda x: x*x,'b':self.u(5)}
print a['u'](5)
print a['b']
but it show error :
Traceback (most recent call last):
File "a.py", line 6, in <module>
a= {'u': lambda x: x*x,'b':self.u(5)}
NameError: name 'self' is not defined
so how to print a['b']
thanks
| [
"First thought: why aren't you using a class instead?\nclass A:\n def u(x):\n return x*x\n def b():\n return self.u(5)\na = A()\n\nSecond thought: if you really must do it with a dictionary (but really, must you?), try this:\na = {'u': lambda x: x*x}\na['b'] = a['u'](5)\n\nSince you're not imple... | [
5,
0
] | [] | [] | [
"dictionary",
"python"
] | stackoverflow_0005320876_dictionary_python.txt |
Q:
How to quickly sort dict() with a huge number of keys?
TLE always happen in SBANK SPOJ using python. In order to solve it, i have to sort dict(), though dict() has huge number of KEYS(maximum--100000). Use sorted() function in my code takes no effect. Is there any fast solution? Thanks for your help.
My code below... | How to quickly sort dict() with a huge number of keys? | TLE always happen in SBANK SPOJ using python. In order to solve it, i have to sort dict(), though dict() has huge number of KEYS(maximum--100000). Use sorted() function in my code takes no effect. Is there any fast solution? Thanks for your help.
My code below:
for j in range(n): # n is the number of keys
accou... | [
"dicts are not sorted, which is how they are able to provide O(1) insert and get access. (Internally, they are implemented as hash tables, I believe, though I'm not sure this is required by the Python spec).\nIf you want to iterate the keys of a dict in sorted order, you can use:\nfor key in sorted(the_dict.iterkey... | [
2,
1,
0
] | [] | [] | [
"python",
"sorting"
] | stackoverflow_0005320497_python_sorting.txt |
Q:
How to do simple http redirect using Python?
How to do simple http redirect using Python? without using meta.
UPDATE: I am using Python 2.7.1 as a CGI from within the cgi-bin directory of Apache.
A:
To redirect using your current setup (CGI apache):
print("Location:http://newurl.com/foobar")
print # to end the C... | How to do simple http redirect using Python? | How to do simple http redirect using Python? without using meta.
UPDATE: I am using Python 2.7.1 as a CGI from within the cgi-bin directory of Apache.
| [
"To redirect using your current setup (CGI apache):\nprint(\"Location:http://newurl.com/foobar\")\nprint # to end the CGI response headers.\n\n"
] | [
6
] | [] | [] | [
"header",
"http",
"python",
"redirect"
] | stackoverflow_0005320916_header_http_python_redirect.txt |
Q:
Link generator using django or any python module
I want to generate for my users temporary download link.
Is that ok if i use django to generate link using url patterns?
Could it be correct way to do that. Because can happen that I don't understand some processes how it works. And it will overflow my memory or som... | Link generator using django or any python module | I want to generate for my users temporary download link.
Is that ok if i use django to generate link using url patterns?
Could it be correct way to do that. Because can happen that I don't understand some processes how it works. And it will overflow my memory or something else. Some kind of example or tools will be app... | [
"A simple scheme might be to use a hash digest of username and timestamp:\nfrom datetime import datetime\nfrom hashlib import sha1\n\nuser = 'bob'\ntime = datetime.now().isoformat()\nplain = user + '\\0' + time\ntoken = sha1(plain)\nprint token.hexdigest()\n\"1e2c5078bd0de12a79d1a49255a9bff9737aa4a4\"\n\nNext you s... | [
4,
2,
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0005320730_django_python.txt |
Q:
Want to split user name in django-nonrel
In my django-nonrel project,all usernames are joined with '_'(underscore). For example, if username is 'guest_test' then I want to split guest and test seperate.I am trying with the following code:
CurrentUser=request.user
myuser=CurrentUser.split('_')
username=myuser.pop(0... | Want to split user name in django-nonrel | In my django-nonrel project,all usernames are joined with '_'(underscore). For example, if username is 'guest_test' then I want to split guest and test seperate.I am trying with the following code:
CurrentUser=request.user
myuser=CurrentUser.split('_')
username=myuser.pop(0)
institute=myuser.pop(0)
print username
But ... | [
"You're confusing the User object which has lots of attributes with the username which is one of those attributes.\nCurrentUser contains a User object, so you need to get the username of this User to then do the split on. Try:\ninstitute,username = CurrentUser.username.split('_')\n\n",
"You are trying to do a sp... | [
4,
0
] | [] | [] | [
"django_nonrel",
"google_app_engine",
"python"
] | stackoverflow_0005312394_django_nonrel_google_app_engine_python.txt |
Q:
Does the concept of "magic number" change from language to language?
Take the following code in C/C++, for example:
int foo[] = {0, 0, 0, 0};
No magic numbers, right?
Now, the Python "equivalent" of that would be:
foo = [0, 0, 0, 0]
Still no magic numbers.
However, in Python, that same thing can be written like ... | Does the concept of "magic number" change from language to language? | Take the following code in C/C++, for example:
int foo[] = {0, 0, 0, 0};
No magic numbers, right?
Now, the Python "equivalent" of that would be:
foo = [0, 0, 0, 0]
Still no magic numbers.
However, in Python, that same thing can be written like this:
foo = [0] * 4
And now we DO have a magic number. Or do we?
I'm gues... | [
"Not every number is a magic constant. The reason 4 and the four 0 are magic numbers (in any language) is that it's entirely unclear why that number is 4 and not any other number. \nFor example in the context of a game that is played with the well known six-sided die\ndef roll_die():\n return random.randint(1,6)... | [
11,
5,
0,
0
] | [
"All your question shows is that the concept of \"magic numbers\" and rules against using \"magic numbers\" in your program are completely and utterly idiotic. Rules against magic numbers are poor approximations, by people who don't understand what they're doing, of a much saner rule against hard-coding in multiple... | [
-1
] | [
"c",
"c++",
"concept",
"magic_numbers",
"python"
] | stackoverflow_0005319516_c_c++_concept_magic_numbers_python.txt |
Q:
How to check for instantiation of a python class during unit-tests
I for the life of me can not remember how to test for the instination of a python class.
It was something like:
try:
m = MyModel()
except:
...
I can't remember the exception to call or the assert to use.
A:
There is no common exception to u... | How to check for instantiation of a python class during unit-tests | I for the life of me can not remember how to test for the instination of a python class.
It was something like:
try:
m = MyModel()
except:
...
I can't remember the exception to call or the assert to use.
| [
"There is no common exception to use for failed instantiation. The constructor (both __init__ and __new__) can raise any exception it wants. The except statement you have without an explicit exception will catch every type of exception, which may be what you want.\n",
"I'm not exactly sure what you are asking, ... | [
1,
0
] | [] | [] | [
"python",
"unit_testing"
] | stackoverflow_0005321048_python_unit_testing.txt |
Q:
Is this a function decorator?
I've just started playing around with pyglet.
In the first demo, I ran accross code like this:
window = pyglet.window.Window()
@window.event
def on_draw():
window.clear()
label.draw()
I understand that this registers an event handler, but I don't understand how.
How could th... | Is this a function decorator? | I've just started playing around with pyglet.
In the first demo, I ran accross code like this:
window = pyglet.window.Window()
@window.event
def on_draw():
window.clear()
label.draw()
I understand that this registers an event handler, but I don't understand how.
How could this be rewritten without the '@' syn... | [
"It's called an \"event decorator.\" Yes, you could just write\nwindow.on_draw = on_draw\nafter the \"def on_draw()\" definition, without using the decorator; but then if the window already had an on_draw, it would be overwritten. The decorator will \"chain\" multiple event handlers together.\n",
"According to th... | [
3,
0
] | [] | [] | [
"python",
"syntax"
] | stackoverflow_0005321185_python_syntax.txt |
Q:
matplotlib: ugly plots when using markers
I have a little problem. I have a program that will draw wave function for a potential, and it looks fine when I use the option in plot (using pylab) '-' for instance: http://img41.imageshack.us/img41/8798/59138635.png
If I use 'o' i'll get:
http://img16.imageshack.us/img1... | matplotlib: ugly plots when using markers | I have a little problem. I have a program that will draw wave function for a potential, and it looks fine when I use the option in plot (using pylab) '-' for instance: http://img41.imageshack.us/img41/8798/59138635.png
If I use 'o' i'll get:
http://img16.imageshack.us/img16/3741/22378006.png
You see that it looks ugly ... | [
"After investigating further, I have a better (but different) answer. Matplotlib provides a markevery keyword to allow a stride in placing markers. So I would recommend, if you want 20 or so points for visibility, on top of a green line:\nstride = max( int(len(x) / 20), 1)\nplt.plot(x,wave,\"-o\",color='forestgreen... | [
6,
2
] | [] | [] | [
"matplotlib",
"python"
] | stackoverflow_0005318639_matplotlib_python.txt |
Q:
How to convert string timezones in form (Country/city) into datetime.tzinfo
Is there a built-in library or does anyone have available a function to convert a string timezone such as "America/New_York" to a datetime.tzinfo object?
Thanks.
A:
Yes, you need the pytz library:
import datetime, pytz
zoneName = 'Americ... | How to convert string timezones in form (Country/city) into datetime.tzinfo | Is there a built-in library or does anyone have available a function to convert a string timezone such as "America/New_York" to a datetime.tzinfo object?
Thanks.
| [
"Yes, you need the pytz library:\nimport datetime, pytz\nzoneName = 'America/New_York'\nnow = datetime.datetime.now(pytz.timezone(zoneName))\n\nreturns:\ndatetime.datetime(2011, 3, 16, 1, 39, 33, 87375, tzinfo=<DstTzInfo 'America/New_York' EDT-1 day, 20:00:00 DST>)\n\n"
] | [
28
] | [] | [] | [
"datetime",
"parsing",
"python",
"string",
"timezone"
] | stackoverflow_0005321466_datetime_parsing_python_string_timezone.txt |
Q:
Give a different name to the executable other than the name of the executable script
I am using the following setup file to create executable using cx_freeze. Is it possible to generate the exe with a different name other than the name of the executable script?
from cx_Freeze import setup, Executable
import xlrd ... | Give a different name to the executable other than the name of the executable script | I am using the following setup file to create executable using cx_freeze. Is it possible to generate the exe with a different name other than the name of the executable script?
from cx_Freeze import setup, Executable
import xlrd
buildOptions = dict(
compressed = True,
... | [
"Try using the targetName option:\nexecutables = [Executable(targetName=\"myexecutable.exe\")]\n\n"
] | [
8
] | [] | [] | [
"cx_freeze",
"python"
] | stackoverflow_0005321435_cx_freeze_python.txt |
Q:
Using GAE Channel's from a TaskQueue
I have been trying for some days to use the channel.send_message API in GAE (via Python) to send a message to a client when a TaskQueue process has finished. It just WON'T work.
I can use send_message from another request and it works fine and is received. But nothing when send... | Using GAE Channel's from a TaskQueue | I have been trying for some days to use the channel.send_message API in GAE (via Python) to send a message to a client when a TaskQueue process has finished. It just WON'T work.
I can use send_message from another request and it works fine and is received. But nothing when send_message is called from a TaskQueue.
I've... | [
"It works fine for me. Make sure you are publishing using the same client key keyid in both\nchannel.send_message(keyid,message_string)\n\nand\ntoken = channel.create_channel(keyid)\n\ni.e. make sure you are NOT using token as the first parameter in send_message().\nI would log (using logging.info()) the keyid (and... | [
3
] | [] | [] | [
"channel_api",
"google_app_engine",
"python"
] | stackoverflow_0005321662_channel_api_google_app_engine_python.txt |
Q:
different timestamp for a same code
i have written a code which converts date and time into timezone , now the problem is i have tired to run the code in python console and in http function but in spite of having a same code i am getting different output of timestamp
in python console
from datetime import datetime... | different timestamp for a same code | i have written a code which converts date and time into timezone , now the problem is i have tired to run the code in python console and in http function but in spite of having a same code i am getting different output of timestamp
in python console
from datetime import datetime
import time
qdate="08-03-2011 05:00:00"
... | [
"I think this is because your console and web server are running under the different time zone settings.\nTry \nimport time\nprint time.timezone\n\nto check whether time zone of your console and the server is different.\n"
] | [
3
] | [] | [] | [
"datetime",
"python"
] | stackoverflow_0005321767_datetime_python.txt |
Q:
OSError: [Errno 22] Python PHP Problem
I asked a similar question prior but i finally got further along in solving it, but now i am stuck.
I am running python on a webserver on dreamhost. I shell into it using putty and run my python script and it works great. But when i run it from php using exec, it crashes.
U... | OSError: [Errno 22] Python PHP Problem | I asked a similar question prior but i finally got further along in solving it, but now i am stuck.
I am running python on a webserver on dreamhost. I shell into it using putty and run my python script and it works great. But when i run it from php using exec, it crashes.
Using the passthru() function in php i get re... | [
"This previous answer about Errno 22 when using os.getlogin should be enlightening:\n\nFrom the os.getlogin() docs: \"Returns the user logged in to the controlling terminal of the process.\" Your script does not have a controlling terminal when run from cron. The docs go on to suggest: \"For most purposes, it is mo... | [
1
] | [] | [] | [
"exec",
"last.fm",
"php",
"python"
] | stackoverflow_0005321681_exec_last.fm_php_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.