Hot answers tagged python
63
This is just plain awesome! I could go on with this all day. Here are some of "my" quotes (from Meta):
Now go and spread the hyperlink
You could provide your community with Gravatar and Stack Overflow.
the <center> cannot receive answers.
New users are strongly discouraged from scanning an analog source. For one unit translates to another.
I want to ...
8
It would be much more convenient if you implemented automatic posting using a blogging API. It looks like most popular blog engines support the new blogger API (Wordpress, Blogger(duh), Drupal, MoveableType, etc...)
WordPress Docs
Drupal Docs
7
As requested, here are some good ones I got on Stack Overflow from my posts:
Turns out that the problem was that hair-pulling just because I was using Doxygen comments in your source code, you can easily generate documentation in Python.
In the application. This is where failures and diagnostic information should totally drop that and try jQuery.
Python is ...
7
You can get around the json/simplejson easily in your wrapper. Just change your import line from
import urllib2, json, httplib, datetime, operator
to
import urllib2, httplib, datetime, operator
try:
import json
except ImportError:
import simplejson as json
That way you can just use json in the rest of your code, but client pythons will load ...
5
Addons
Stackprinter allows you to print directly from Stack Exchange sites using Greasemonkey script or an handy bookmarklet.
Greasemonkey script adds a Printer-Friendly button to the question you are browsing (Firefox and Chrome both supported).
Bookmarklet is useful if Greasemonkey is not an option and has the same effect of Printer-Friendly button, ...
5
I am using Py-StackExchange in our Stack2Blog application.
How do I retrieve a list of answers of a specific user using this wrapper?
After retrieving a user object, the .answers member variable returns an empty list while I know the user does have posts.
4
Mine:
The fix is a programming language: CSS becomes a fully bloated format with stuff I wrote in a recent project because realplayer uses DoPlay() instead of Play().
Instead, I've experimented until I've come up what to fix. At least it's better than hammering F5.
You should warn the user before he begins using the system.
I'm very happy to confirm the ...
3
This example uses C operators, but they are also used for WinNT/2000/XP/Vista/7
Additionally, new ImageIcon("image.png").getImage() can be used to load a C++ header file with functions that it is not.
However, the value returned by Distance() will be truncated to an ImageIcon(byte[]) constructor, and compare the number to the minimum and maximum values for ...
3
Some funny ones from Stack Overflow:
a good IDE can then write a Java file that a common cause of segfaults is harder to monitor/troubleshoot
Use Java's resource loader to load the image file between processes by passing around the code from the SVN repo.
This setup also helps out API consumers, and is a code smell in the Sun/Oracle JRE
Sounds like I ...
3
In .NET 2.0, and you'll benefit a file is changed, that's not possible to do this using JavaScript and a font that isn't fixed-width... it doesn't have special rules in terms of what expressions you can pass the result to setTimeout, you want to get only the minutes and constrain the generic type to those types that implement IComparable, then use a switch ...
3
Edit:
My problem below has been "solved", and it's a problem with the fact that I'm getting back gzip-compressed data from stackapps. See the SO Answer. I'm still unsure why this happens only on my computer (possible reason: routers in my network adding content-headers), but I'm guessing this should be fixed in the wrapper itself.
Come to think of it, the ...
3
I think Py-StackExchange is your best bet; there's an API V2.0 branch that seems to be active.
2
Possible bug in the latest build? Found this (excellent) library via a Bryce Boe post and dropped in Py-Stackoverflow via easy_install.
Running the script triggered the following, however:
sog@bishop:~/Dropbox/Code/StackOverflow$ ./minestack.py
Traceback (most recent call last):
File "./minestack.py", line 3, in <module>
from stackexchange ...
2
Downgrade isn't necessary for your problem. Just switch to Ubuntu Classic from the /app folders: [Icon Theme] Name=Faenza Humanity Inherits=ubuntu-mono-dark,humanity,hicolor Comment=Custom Faenza + Humanity Theme for Jorge Castro Directories=apps/16,apps/22,apps/24,apps/32,apps/48,apps/scalable [apps/16] Size=16 Context=Apps Type=fixed [apps/22] Size=22 ...
2
OK, I'm probably missing the obvious, but how do I get the body of an answer?
For example, in your code snippet:
>>> so = stackexchange.Site('api.stackoverflow.com')
>>> me = so.user(41981)
>>> me.answers.fetch()
>>> me.answers[0].body
Traceback (most recent call last):
File "<pyshell#45>", line 1, in ...
2
Product design question:
Would you like an answer's comments to also appear within the blog post's draft?
Would you like these comments replicated as comments of the blog post?
Or are they best left unused in the blog post as they have no place there?
Let me know your preferences.
2
No, you can't do it because py-stackexchange is a library based on SE API that does not provide that kind of search.
You should use Google API search instead.
1
I realize this is rather old, but I thought someone might get a laugh out of some of these:
Ask Ubuntu:
A Happier Update The problem now seems to lie with the new kernel.
You should (according to what I find) be considered closed, methinks.
Was there any special reason you wanted to use this site?
Hahaha. the meaning is the opposite. What is ...
1
Two of the demo scripts currently do not work because there is no 'answers' field in the json :(
It might be an ugly workaround, but for now this diff does the trick:
badp@delta:~/Py-StackExchange$ git diff 0a5c60f71310757a4c1de6547cf113c7d6834e85
diff --git a/stackexchange.py b/stackexchange.py
index 959cf3e..4a17b10 100644
--- a/stackexchange.py
+++ ...
1
Using the most recent version of the library as of yesterday. I needed to get some information on users answers and the question itself. However this didn't work. Every time I tried to access another page of answers I got ()
answers = me.answers.fetch()
answerDetails = []
while True:
for answer in answers:
answerDetails.append({
...
1
Trying to run this on openSUSE 11.2, getting an error message:
sathya@shaman:~/Download/stacktracker> python StackTracker.py
Traceback (most recent call last):
File "StackTracker.py", line 1, in <module>
from PyQt4 import QtCore, QtGui, QtWebKit, QtNetwork
RuntimeError: the sip module implements API v6.0 but the PyQt4.QtCore module requires ...
1
Hi, I've got some problem using ST under Ubuntu 10.04.
This is what I get when I launch
>> python StackTracker.py:
This is the window while I enter the URL:
And this is the window after the URL to be tracked is submitted:
Any thought and/or advice for the troubleshoot?
EDIT: Version 0.4 works! YAY!!!
1
I am running py-stackexchange v1.1-4 and I'm hitting a strange issue after not touching this library for perhaps eight months or so... My queries used to be relatively fast... I could get results in 30 seconds.
Now my queries literally take hours with the same code... example query:
def filtered_question_dict(sesite, mytags, pagesize=100,
...
1
Based on the demo *recent_questions.py* example, I am using the following code to retrieve the 10 most recent questions at the command line:
so = stackexchange.Site(stackexchange.StackOverflow)
questions = so.recent_questions(pagesize=10)
for q in questions:
print "question retrieved:", q.title.encode('ascii', 'ignore'), "\t", q.id
...
As you can ...
1
I was willing yo use your lib to do some statistics on the questions from SO (just for fun, nothing really serious, though it can become serious if I like the results :P).
For this I'd have to get the data from I whole bunch of questions. As an example, I tried to get all questions from roughly 1 month (2e6 seconds). I tried this:
import time
from numpy ...
1
Hi Lucas,
I'm running into an issue finding a user's accept rate. I hope to find it across all the stack exchange sites, but when I pull ii.get_user().unaccepted_questions, it is always an empty list.
accounts = STACK_AUTH.associated(site, owner_id)
for ii in accounts:
questions, unaccepted_questions, site = \
...
1
I'm running a program using py-stackexchange that gets an error,
HTTPError: HTTP Error 500: Internal Server Error
Do you have any debugging suggestions? If I could turn on a debugging flag, that would cause py-SE to print the exact URL that was requested, that would help... Then I could visit that URL myself in the browser and see if a more detailed error ...
1
I'm building a Django app, and I'l like to be able to search for users' SO account based on their name. I've got the following, which works from a python shell, but this doesn't work when called from within a Django view. Any ideas?
def so_user_search(full_name):
so = Site(StackOverflow, MY_API_KEY)
results = so.users([], **{'filter':full_name})
...
1
There's a bug with deleted users. Attempting to call question.comments.fetch() on a question that has comments by a deleted users, such as this, results in:
File "stackcloud.py", line 60, in <module>
for comment in question.comments.fetch():
File "stackcore.py", line 151, in fetch
res = self.site.build(self.url, self.m_type, ...
1
Quick bug:
Doing this:
anss = so.answers(user_id=175645, pagesize=100, body=True)
ans1 = anss[0]
ans1.owner
Produces this stacktrace:
Traceback (most recent call last):
File "<pyshell#46>", line 1, in <module>
a.owner
File "E:\Projects\Web\Stack2Blog\repos\stack2blog-src-main\stack2blog\stack2blogapp\stackexchange.py", line 218, in ...
Only top voted, non community-wiki answers of a minimum length are eligible


