Q_Id
int64 2.93k
49.7M
| CreationDate
stringlengths 23
23
| Users Score
int64 -10
437
| Other
int64 0
1
| Python Basics and Environment
int64 0
1
| System Administration and DevOps
int64 0
1
| DISCREPANCY
int64 0
1
| Tags
stringlengths 6
90
| ERRORS
int64 0
1
| A_Id
int64 2.98k
72.5M
| API_CHANGE
int64 0
1
| AnswerCount
int64 1
42
| REVIEW
int64 0
1
| is_accepted
bool 2
classes | Web Development
int64 0
1
| GUI and Desktop Applications
int64 0
1
| Answer
stringlengths 15
5.1k
| Available Count
int64 1
17
| Q_Score
int64 0
3.67k
| Data Science and Machine Learning
int64 0
1
| DOCUMENTATION
int64 0
1
| Question
stringlengths 25
6.53k
| Title
stringlengths 11
148
| CONCEPTUAL
int64 0
1
| Score
float64 -1
1.2
| API_USAGE
int64 1
1
| Database and SQL
int64 0
1
| Networking and APIs
int64 0
1
| ViewCount
int64 15
3.72M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
16,446,374 | 2013-05-08T17:06:00.000 | 1 | 0 | 1 | 0 | 0 | c++,python,algorithm,permutation | 0 | 16,446,441 | 0 | 3 | 0 | false | 0 | 0 | Treat your permutation as a r-digit number in a n-based numerical system. Start with 000...0 and increase the 'number' by one: 0000, 0001, 0002, 000(r-1), 0010, 0011, ...
The code is quite simple. | 1 | 0 | 0 | 0 | How could we generate all possible permutations of n (given) distinct items taken r at a time where any item can be repeated any number of times?
Combinatorics tell me that there will be n^r of them, just wondering how to generate them with C++/python? | Generating all permutations with repetition | 0 | 0.066568 | 1 | 0 | 0 | 5,032 |
16,452,913 | 2013-05-09T01:29:00.000 | 1 | 1 | 0 | 0 | 1 | python,networking | 0 | 16,453,432 | 0 | 2 | 0 | true | 0 | 0 | There are messaging systems that don't require a central message broker. You might start by looking at ZeroMQ. | 1 | 3 | 0 | 0 | I am not sure if this question belongs here as it may be a little to broad. If so, I apologize. Anyway, I am planning to start a project in python and I am trying to figure out how best to implement it, or if it is even possible in any practical way. The system will consist of several "nodes" that are essentially python scripts that translate other protocols for talking to different kinds of hardware related to i/o, relays to control stuff, inputs to measure things, rfid-readers etc, to a common protocol for my system. I am no programming or network expert, but this part I can handle, I have a module from an old alarm system that uses rs-485 that I can sucessfully control and read. I want to get the nodes talking to eachother over the network so I can distribute them to different locations (on the same subnet for now). The obvious way would be to use a server that they all connect to so they can be polled and get orders to flip outputs or do something else. This should not be too hard using twisted or something like it.
The problem with this is that if this server for some reason stops working, everything else does too. I guess what I would like is some kind of serverless communication, that has no single point of failure besides the network itself. Message brokers all seem to require some kind of server, and I can not really find anything else that seems suitable for this. All nodes must know the status of all other nodes as I will need to be able to make functions based on the status of things connected to other nodes, such as, do not open this door if that door is already open. Maybe this could be done by multicast or broadcast, but that seems a bit insecure and just not right. One way I thought of could be to somehow appoint one of the nodes to accept connections from the other nodes and act as a message router and arrange for some kind of backup so that if this node crashes or goes away, another predetermined node takes over and the other nodes connect to it instead. This seems complicated and I am not sure this is any better than just using a message broker.
As I said, I am not sure this is an appropriate question here but if anyone could give me a hint to how this could be done or if there is something that does something similar to this that I can study. If I am beeing stupid, please let me know that too :) | Serverless communication between network nodes in python | 1 | 1.2 | 1 | 0 | 1 | 438 |
16,471,763 | 2013-05-09T21:51:00.000 | 1 | 0 | 1 | 0 | 0 | python,gaussian | 0 | 16,471,982 | 0 | 6 | 0 | false | 0 | 0 | If you have a small range of integers, you can create a list with a gaussian distribution of the numbers within that range and then make a random choice from it. | 1 | 10 | 1 | 0 | I want to use the gaussian function in python to generate some numbers between a specific range giving the mean and variance
so lets say I have a range between 0 and 10
and I want my mean to be 3 and variance to be 4
mean = 3, variance = 4
how can I do that ? | Generating numbers with Gaussian function in a range using python | 0 | 0.033321 | 1 | 0 | 0 | 36,597 |
16,487,059 | 2013-05-10T16:43:00.000 | 0 | 0 | 0 | 0 | 1 | python,qt,user-interface,pyside | 0 | 16,492,340 | 0 | 1 | 0 | false | 0 | 1 | This may or may not help but when I encountered this the only thing that helped was reinstalling/updating pyside. I thought the fixed that bug a while back however. | 1 | 2 | 0 | 0 | I've been experiencing a really weird bug recently:
Often when I zoom too much on a QGraphicsItem (using scale on the view containing it) that has a QGraphicsDropShadowEffect on it, my app closes with a segmentation fault (core dumped) error.
What's weird is that:
I use Python (with the PySide binding)
If I remove the QGraphicsDropShadowEffect, the bug disappears
I also had to remove the QGraphicsDropShadowEffect on a relatively big item because it got the app so slow to the point it became irresponsive when I zoomed a bit too much.
Do anyone know how I could fix this ? | Qt : Segfault when zooming on QGraphicsDropShadowEffect | 0 | 0 | 1 | 0 | 0 | 150 |
16,487,863 | 2013-05-10T17:34:00.000 | 0 | 0 | 0 | 0 | 0 | python,django | 1 | 16,488,072 | 0 | 2 | 0 | false | 1 | 0 | Are you depending on the garbage collector to close your files? I.E. the handle goes out of scope and even though you've "closed" the file, it won't go away until GC runs. If the object chain never goes out of scope, GC cannot collect it. Also, if GC does not get an opportunity to run, they won't be collected either.
I ran into the same issue with a long running process, and "solved" it by redesigning my system, such that all file access happened inside of a child object. That object got removed from the reference chain after it was done being used, or some error occurred. This allowed the GC to collect the handles. | 1 | 1 | 0 | 0 | I recently got an exception on my server about "Too many open files". I checked lsof, and sure enough, there are a bunch of PDF files that remain open (all in the same directory). This particular file is managed through a Django FileField. I've tried to track down any places in my project that explicitly open the file by name, and there's only one place I can find, and from what I can tell the file is being closed correctly there. There may be other places where the file is remaining open, but I have no idea how to find out what piece of code is actually keeping the file open. I've tried simply grepping for calls to open() and file(), but no luck.
Is there any way to systematically track down what line of code is responsible for leaving the file open?
EDIT: I understand how to properly open/close a file. My question is whether or not there is a way to track down an existing line of code that leaves is leaving a file open. | How can I find out which line of code is leaving a file open? | 1 | 0 | 1 | 0 | 0 | 88 |
16,502,445 | 2013-05-11T22:51:00.000 | 5 | 0 | 0 | 0 | 0 | python,python-2.7,numpy,scipy,scikit-learn | 0 | 16,524,872 | 0 | 1 | 0 | true | 0 | 0 | There is no function for that, as we like to keep the interface very simple.
You can just do
y - rf.predict(X) | 1 | 4 | 1 | 0 | When using RandomForestRegressor from Sklearn, how do you get the residuals of the regression? I would like to plot out these residuals to check the linearity. | Residuals of Random Forest Regression (Python) | 0 | 1.2 | 1 | 0 | 0 | 2,682 |
16,511,231 | 2013-05-12T19:31:00.000 | 0 | 0 | 1 | 0 | 0 | python,pydev | 0 | 16,513,405 | 0 | 1 | 0 | false | 0 | 0 | There is no 'automatic' way for that... But usually in this situation you can just do a find/replace from 2 spaces to 3 spaces (or whatever was the format you had to the expected format).
Sometimes rectangular editing is helpful there too (hint: use alt+shift+A to enter/leave rectangular editing mode). | 1 | 2 | 0 | 0 | I am using PyDev perspective. I get a bad indentation warning in python files.
I just copy code from somewhere else, I cannot make sure how much space others use... so how to automatically format that or how to erase that warning? It looks bad. | Pydev indentation warning in Eclipse | 0 | 0 | 1 | 0 | 0 | 582 |
16,528,178 | 2013-05-13T17:55:00.000 | 3 | 0 | 1 | 0 | 0 | python,file-io | 0 | 16,528,237 | 0 | 2 | 0 | false | 0 | 0 | You write the exact number of characters == bytes, after .seek()-ing back to your start_offset position. These then overwrite the data that was there before.
You can split that up into multiple writes, even writes of one character (byte) at a time if needed. | 1 | 0 | 0 | 0 | I've seen multiple tutorials in python, played around a bit with python file write(), tell(), seek() functions and also os.write(), lseek() functions.
But I still don't get how can I do the following:
What I have:
In a file I know the start_offset and end_offset bytes. And I need to replace the bytes from start_offset to end_offset with a different set of bytes. How do I do this??
ftell() returns me the start_offset and similarly regex + ftell() returns me the end offset
I have the bytes that will overwrite the original ones in the file.
But write() only takes a string to write. Also how do I overwrite from start_pos to end_pos??
appreciate any pointers/suggestions | python overwrite bytes from offset1 to offset2 | 0 | 0.291313 | 1 | 0 | 0 | 561 |
16,536,683 | 2013-05-14T06:42:00.000 | 2 | 0 | 1 | 0 | 0 | python,ipython,pypy | 0 | 67,074,248 | 0 | 4 | 0 | false | 0 | 0 | The "straight forward" way is:
Install pypy3
pypy3 -m pip install ipython
pypy3 -m IPython | 1 | 27 | 0 | 0 | How do I use ipython on top of a pypy interpreter rather than a cpython interpreter? ipython website just says it works, but is scant on the details of how to do it. | How to run ipython with pypy? | 0 | 0.099668 | 1 | 0 | 0 | 6,903 |
16,543,715 | 2013-05-14T12:52:00.000 | 0 | 1 | 0 | 0 | 0 | python,raspberry-pi,schedule | 0 | 16,543,818 | 0 | 3 | 0 | false | 0 | 0 | The easiest way would be to set up a cron job to call a python script every hour. | 1 | 1 | 0 | 0 | I'd like to know how to preform an action every hour in python. My Raspberry Pi should send me information about the temp and so on every hour. Is this possible?
I am new to python and linux, so a detailed explanation would be nice. | How to schedule an action in python? | 1 | 0 | 1 | 0 | 0 | 7,805 |
16,574,746 | 2013-05-15T20:51:00.000 | 0 | 1 | 0 | 0 | 1 | python,twitter,tweepy | 0 | 16,589,445 | 0 | 2 | 0 | false | 0 | 0 | What one could do, is get the last nth tweet from a user, and then get the tweet.id of the relevant tweet. This can be done doing:
latestTweets = api.user_timeline(screen_name = 'user', count = n, include_rts = False)
I, however, doubt that it is the most efficient way. | 1 | 1 | 0 | 0 | I want to check if a certain tweet is a reply to the tweet that I sent. Here is how I think I can do it:
Step1: Post a tweet and store id of posted tweet
Step2: Listen to my handle and collect all the tweets that have my handle in it
Step3: Use tweet.in_reply_to_status_id to see if tweet is reply to the stored id
In this logic, I am not sure how to get the status id of the tweet that I am posting in step 1. Is there a way I can get it? If not, is there another way in which I can solve this problem? | How to get id of the tweet posted in tweepy | 1 | 0 | 1 | 0 | 1 | 1,649 |
16,582,065 | 2013-05-16T08:05:00.000 | 0 | 0 | 1 | 0 | 0 | python,image-processing,wordnet | 0 | 16,582,205 | 0 | 1 | 0 | false | 0 | 0 | Well, I suppose you take a bunch of path to images as strings, you can get them as command line arguments or reading them from stdin. Then you just have to open them or do whatever you want with it.
Is that answering your question? | 1 | 0 | 0 | 0 | I am trying to take a set of tagged images as input and remove noisy tags from each image. I have written a python code which takes a text file as input, each line of which corresponds to tags of an image, and removes the noisy tags from each line. I have used the structure and similarity measures in Wordnet to do so.
But i dunno how to take a set of images as input. Could someone please tell me how to do this. | Using set of images as an input | 0 | 0 | 1 | 0 | 0 | 65 |
16,597,149 | 2013-05-16T20:45:00.000 | 0 | 0 | 0 | 0 | 0 | python,html,jsp,beautifulsoup | 0 | 16,597,278 | 0 | 1 | 0 | false | 1 | 0 | I assume you are talking about web scraping which is pulling information from other websites.
You are not going to be able to do something like this in somebody's browser because it violates Javascript's same origin policy, AND there is no way a browser is going to let you download and execute a script on a client's computer.
You could just write a python script to do this for you and execute it yourself on your machine however.
Just be sure you are not violating web site's terms of service.
EDIT:
In that case I would recommend running the script on the command line, and then using the output of the program in the servlet to generate the responses you want. | 1 | 0 | 0 | 0 | I am trying to invoke a python code for screen scraping (using Beautiful Soup) from my jsp servlet. Or it would also work if it can be directly invoked from the HTML.
Looked through few threads but couldn't get any solution.
What I want is to give the python program some arguments and want it to do some screen scrapping and return the result to jsp somehow. | how to invoke python script in jsp/servlet? | 0 | 0 | 1 | 0 | 0 | 1,132 |
16,597,739 | 2013-05-16T21:23:00.000 | 1 | 0 | 0 | 0 | 0 | python,django,email,django-email | 0 | 16,599,805 | 0 | 1 | 0 | true | 1 | 0 | Are you trying to read from a mailbox and write the information into the database? If so, then you want to:
1) Open a connection to the mail server using poplib or imaplib from the standard library
2) Retrieve messages from the server (again with poplib or imaplib)
3) Parse the messages with the email package from the standard library.
From there, you can populate whatever stuff you want in your database, either using the Django ORM or not. | 1 | 1 | 0 | 0 | How to implement something like this:
If someone send email with file in attachment to [email protected], this file is added automatically to database.
Please general algorithm how to do or suggest existing app | Upload files via email in Django. General algorithm | 1 | 1.2 | 1 | 0 | 0 | 99 |
16,606,906 | 2013-05-17T10:33:00.000 | 1 | 0 | 0 | 0 | 0 | python,hbase,thrift | 0 | 16,608,107 | 0 | 1 | 0 | false | 0 | 0 | HBase provides a scanner interface that allows you to enumerate over a range of keys in an HTable. HappyBase has support for scans and this is documented pretty well in their API.
So this would solve your question if you were asking for a "like 'name%'" type of query which searches for anything that begins with the prefix 'name'. I am assuming name is the row key in your table, otherwise you would need a secondary index which relates the name field to the row key value of the table or go with the sub-awesome approach of scanning the entire table and doing the matching in Python yourself, depending on your usecase...
Edit: HappyBase also supports passing a 'filter' string assuming you are using a recent HBase version. You could use the SubStringComparator or RegexStringComparator to fit your needs. | 1 | 0 | 0 | 0 | I want to do something like
select * from table where name like '%name%'
is there anyway to do this in Hbase ? and if there is a way so how to do that
ps. I use HappyBase to communicate with Hbase | Hbase wildcard support | 1 | 0.197375 | 1 | 1 | 0 | 364 |
16,644,007 | 2013-05-20T06:45:00.000 | -1 | 0 | 0 | 0 | 0 | c++,python,windows,api | 0 | 66,233,621 | 0 | 3 | 1 | false | 0 | 1 | There is an easiest way.
Install VBest Icon groups. ( it is a desktop icon stack )
Then select any stack and add a single button. ( drag and drop any application will get its link and icon in the stack )
Select the stack and in its settings, set transparency equals 0 ( slide to left)
That is it. Now you have a single button with link. | 1 | 0 | 0 | 0 | I've collected many nice wall papers over years.
I know python and c++ (a little MFC eperience).
I want to make a programme that can change my wallpapers.
I want to operate like this:
there is a little icon (half transparent), if i click it, it change my wallpapers to the next picture in my wallpaper collection folder.
I found many infos of changing wallpaper by programme by google.
But can't find out the win7 API for adding a button on desktop.
Please some one tell me how to set a icon-button on the desktop, or it's just there's no such API?
EDIT:
I just find that there are ways to make a window unmovable. So, I think now I need to find ways to make windows out of an icon. Then it'll looks like a button on desktop. And, there are ways to make windows taking some response when it's clicked(once), right?
Closure:
Captain's method may be a better way for people with good understanding of windows.
I know python, but few knowledge of MFC or similar framework with deep relations with the OS itself. This desktop button creation is very hard to implement for me.
Modifying christian's script and a windows shortcut would be a not-good-looking compromise. I'll do it this way. | create an button on desktop | 0 | -0.066568 | 1 | 0 | 0 | 672 |
16,646,135 | 2013-05-20T09:11:00.000 | 1 | 1 | 1 | 0 | 0 | c#,ironpython | 0 | 16,652,356 | 0 | 1 | 0 | true | 0 | 1 | Parts of IronPython's standard library are implemented in C#, mainly because the equivalents in CPython are written in C. You can access those parts directly from a C# (or any other static .NET language) directly, but they're not intended to be used that way and may not be easy to use. | 1 | 0 | 0 | 0 | I've recently discovered IronPython in C# and only tutorials I found were how to use python script in C#, but I've noticed, that IronPython has classes and methods you can use directly in C# like : PythonIterTools.product some_pr = new PythonIterTools.product(); and others, can anyone explain how does this work? | Using IronPython in C# | 0 | 1.2 | 1 | 0 | 0 | 223 |
16,652,406 | 2013-05-20T15:01:00.000 | 0 | 1 | 0 | 0 | 0 | python,cherrypy,nose,nosetests | 0 | 16,652,717 | 0 | 1 | 0 | true | 1 | 0 | With python unit tests, you are basically testing the server. And the correct response from server is the redirect exception and not the redirected page itself. I would recommend you testing this behaviour in two steps:
test if the first page/url throws correctly initialized (code, url) HTTPRedirect exception
test contents of the second page (on which is being redirected)
But of course, if you insist, you can resolve the redirect in Try/Except by yourself by inspecting the exception attributes and calling testing method on target url again. | 1 | 0 | 0 | 0 | I’m writing a cherrypy application that needs to redirect to a particular page and I use HTTPRedirect(‘mynewurl’, status=303) to achieve this. This works inasmuch as the browser (Safari) redirects to ‘mynewurl’ without asking the user. However, when I attempt to unit test using nosetests with assertInBody(), I get a different result; assertInBody reports that ‘This resource can be found at mynewurl’ rather than the actual contents of ‘mynewurl’. My question is how can I get nosetests to behave in the same way as a Safari, that is, redirecting to a page without displaying an ‘ask’ message?
Thanks
Kevin | Unit testing Cherrypy HTTPRedirect. | 0 | 1.2 | 1 | 0 | 1 | 190 |
16,737,386 | 2013-05-24T14:29:00.000 | 0 | 0 | 0 | 1 | 1 | python,google-app-engine,beautifulsoup | 1 | 16,737,623 | 0 | 2 | 0 | false | 1 | 0 | It seems uploading the whole directory where the bs4 module resides in to the GAE app folder would work. | 1 | 0 | 0 | 0 | I am working in python on a GAE app. Beautiful soup, which the app uses, works fine on my dev server locally. When I try and upload it to google's servers however, I get the following error: "Error parsing yaml file: the library "bs4" is not supported".
I am not sure how to fix this. Does anyone have any idea?
Thank you.
File Structure:
app.yaml
main.py
static(DIR)
templates(DIR)
bs4(DIR) | Beautiful Soup "not supported" Google App Engine | 0 | 0 | 1 | 0 | 0 | 1,031 |
16,744,702 | 2013-05-24T22:57:00.000 | 1 | 0 | 0 | 0 | 0 | python,gtk,glade | 0 | 22,049,793 | 0 | 2 | 0 | false | 0 | 1 | Not an answer, but it looks like "another.anon.coward" already answered this in a comment...
If you double click on the tab, then that page is selected for adding content in glade. You can go ahead and add content for that page. As for switching you can use set_current_page to switch to page whose content you want to display. Register for "switch-page" signal to find out which page has been switched to. | 1 | 6 | 0 | 0 | I'm currently developing a small application in Python with the use of GTK+ (and Glade). Everything has been fairly simple to integrate so far, until I came up with the idea to add tabs instead of pop-ups. Note: Still using Python 2.7+
Is there any easy way to implement already existing pages inside a new tab(notebook) like structure? I'm having difficulties to find how to add content per separate tab created in glade.
Perhabs a more 'clear' question: What Notebook function will be required to call a specific V/HBox with every different tab? The current structure looks like (minus Menu / statusbar):
[ mainWindow ] --> (1) mainOverview (gtkVbox) --> (2A) mainContent (gtkHbox) ... other non-related content
The structure I was hoping for would look like:
[ mainWindow ] --> (1) mainOverview --> (2) noteBook --> (3) Tab1 --> (4) mainContent (gtkHbox) -- (3) Tab2 --> (4) secondaryContent (gtkHbox)
The application itself works fine (multithreaded, fully functioning) without the tabs, the mainContent(gtkHbox) contains a file/recursive directory analyzer, a few checkboxes and a general overview. I was hoping for an easy way to display this main window (the gtkHbox) ONLY when having Tab1 selected.
Having difficulties to find good reference pages that display a proper way to call content pages per notebook tab. Any reference-pages or useful links are very much appreciated! Thanks so far! My apologies if this is a rather newbish question, I'm not new to Python coding, but interfaces on the other hand... ;) | Python GTK (Glade) Notebook | 0 | 0.099668 | 1 | 0 | 0 | 1,912 |
16,745,923 | 2013-05-25T02:45:00.000 | 0 | 0 | 1 | 1 | 1 | macos,bash,command-line,terminal,ipython | 0 | 65,625,644 | 0 | 7 | 0 | false | 0 | 0 | For me the only thing that helped was:
python -m pip install --upgrade pip
Upgrading pip did the work and all the installations started working properly!
Give it a try. | 4 | 22 | 0 | 0 | Using Python 2.7 installed via homebrew. I then used pip to install IPython. So, IPython seems to be installed under:
/usr/local/lib/python2.7/site-packages/
I think this is true because there is a IPython directory and ipython egg.
However, when I type ipython in the terminal I get:
-bash: ipython: command not found
I do not understand why this ONLY happens with IPython and not with python? Also, how do I fix this? What path should I add in .bashrc? And how should I add?
Currently, my .bashrc reads:
PATH=$PATH:/usr/local/bin/
Thanks! | IPython command not found Terminal OSX. Pip installed | 1 | 0 | 1 | 0 | 0 | 34,234 |
16,745,923 | 2013-05-25T02:45:00.000 | 25 | 0 | 1 | 1 | 1 | macos,bash,command-line,terminal,ipython | 0 | 22,583,681 | 0 | 7 | 0 | true | 0 | 0 | I had this issue too, the following worked for me and seems like a clean simple solution:
pip uninstall ipython
pip install ipython
I'm running mavericks and latest pip | 4 | 22 | 0 | 0 | Using Python 2.7 installed via homebrew. I then used pip to install IPython. So, IPython seems to be installed under:
/usr/local/lib/python2.7/site-packages/
I think this is true because there is a IPython directory and ipython egg.
However, when I type ipython in the terminal I get:
-bash: ipython: command not found
I do not understand why this ONLY happens with IPython and not with python? Also, how do I fix this? What path should I add in .bashrc? And how should I add?
Currently, my .bashrc reads:
PATH=$PATH:/usr/local/bin/
Thanks! | IPython command not found Terminal OSX. Pip installed | 1 | 1.2 | 1 | 0 | 0 | 34,234 |
16,745,923 | 2013-05-25T02:45:00.000 | 0 | 0 | 1 | 1 | 1 | macos,bash,command-line,terminal,ipython | 0 | 59,742,054 | 0 | 7 | 0 | false | 0 | 0 | After trying to a number of solutions like above with out joy, when I restarted my terminal, Ipython command launched. Don't forgot to restart your terminal after all the fiddling!
P.S. I think the brew install Ipython did it ... but can't be sure. | 4 | 22 | 0 | 0 | Using Python 2.7 installed via homebrew. I then used pip to install IPython. So, IPython seems to be installed under:
/usr/local/lib/python2.7/site-packages/
I think this is true because there is a IPython directory and ipython egg.
However, when I type ipython in the terminal I get:
-bash: ipython: command not found
I do not understand why this ONLY happens with IPython and not with python? Also, how do I fix this? What path should I add in .bashrc? And how should I add?
Currently, my .bashrc reads:
PATH=$PATH:/usr/local/bin/
Thanks! | IPython command not found Terminal OSX. Pip installed | 1 | 0 | 1 | 0 | 0 | 34,234 |
16,745,923 | 2013-05-25T02:45:00.000 | 2 | 0 | 1 | 1 | 1 | macos,bash,command-line,terminal,ipython | 0 | 59,297,333 | 0 | 7 | 0 | false | 0 | 0 | I use pip3 install ipython is OK.
maybe ipython rely on python3 | 4 | 22 | 0 | 0 | Using Python 2.7 installed via homebrew. I then used pip to install IPython. So, IPython seems to be installed under:
/usr/local/lib/python2.7/site-packages/
I think this is true because there is a IPython directory and ipython egg.
However, when I type ipython in the terminal I get:
-bash: ipython: command not found
I do not understand why this ONLY happens with IPython and not with python? Also, how do I fix this? What path should I add in .bashrc? And how should I add?
Currently, my .bashrc reads:
PATH=$PATH:/usr/local/bin/
Thanks! | IPython command not found Terminal OSX. Pip installed | 1 | 0.057081 | 1 | 0 | 0 | 34,234 |
16,747,301 | 2013-05-25T07:06:00.000 | 0 | 1 | 0 | 1 | 0 | apache,webserver,cgi,mod-python,mod-php | 0 | 21,819,195 | 0 | 1 | 0 | false | 0 | 0 | With a modern version of Apache, unless you configure it in prefork mode, it should run threaded (and not fork). mod_python is threadsafe, and doesn't require that each instance of it is forked into its own space. | 1 | 4 | 0 | 0 | I am a dummy in web apps. I have a doubt regaring the functioning of apache web server. My question is mainly centered on "how apache handles each incoming request"
Q: When apache is running in the mod_python/mod_php mode, then does a "fork" happen for each incoming reuest?
If it forks in mod_php/mod_python way, then where is the advantage over CGI mode, except for the fact that the forked process in mod_php way already contains an interpretor instance.
If it doesn't fork each time, how does it actually handle each incoming request in the mod_php/mod_python way. Does it use threads?
PS: Where does FastCGI stands in the above comparison? | Does Apache really "fork" in mod_php/python way for request handling? | 0 | 0 | 1 | 0 | 0 | 459 |
16,771,391 | 2013-05-27T10:42:00.000 | 4 | 0 | 0 | 0 | 1 | python,django,concurrency | 0 | 16,771,514 | 0 | 2 | 0 | true | 1 | 0 | Its webserver specific. If you configure it to run in different process, request will be handled in new process. If you configure to have threads it will be in threads.
Yes. Imagine case when, user1 is viewing/editing a object A (retrieved from DB). user2 deletes that object. And then user1 tries to save it. You need to handle such cases explicitly in your code.
Most likely the issues will be related to DB. So you can use transactions to help in some cases.
In some other cases, you can define strategy. E.g the case mentioned above, when user1 tries to save the object, and its not there in db you can just create one. | 1 | 3 | 0 | 0 | I'm developing a website with Django 1.5.1 and I have two doubts regarding concurrence. Now I'm runing on the development server.
When multiple users access the website at the same time, by default, does Django run each request in a different execution thread? Or must it be configured in the webserver e.g. Apache?
Will I experience issues if more than a user is modifying the same object concurrently? If so, how do you solve this problem? Using locks?
Thanks for your help! | Concurrency doubts in Django | 0 | 1.2 | 1 | 0 | 0 | 1,239 |
16,782,047 | 2013-05-28T00:04:00.000 | 0 | 0 | 1 | 0 | 0 | python | 0 | 16,782,089 | 0 | 7 | 0 | false | 0 | 1 | You can't. In Windows, custom icons can only be assigned to certain types of files (executables and shortcuts, mostly), and Python scripts are not one of those types. | 2 | 7 | 0 | 0 | I am developing a game in Python and was wondering how to give it its own icon. I am using a windows computer and have no extra things installed with Python. Oh also I am using version 3.3 Is this even possible.
P.S I have found other things on Stack Overflow but they are using different Operating Systems like Ubuntu and Macintosh | How To Add An Icon Of My Own To A Python Program | 1 | 0 | 1 | 0 | 0 | 40,170 |
16,782,047 | 2013-05-28T00:04:00.000 | 2 | 0 | 1 | 0 | 0 | python | 0 | 16,782,121 | 0 | 7 | 0 | false | 0 | 1 | If you are trying to change the icon of the shortcut for your program,
then you need to get to the file where ever it is right-click it and go to create a shortcut
then drag that shortcut to your desktop
then right-click that shortcut and click properties
then click on "Change Icon"
then go to where your desire .ico image is saved and set that as the icon
if you do this and you open your program in the corner will be the .ico you selected and on your desktop, it will show the icon instead of the python image.
that is how you change the shortcut icon but there is no way to change the actual window icon in the corner unless you're using something like Tk or Pygame. | 2 | 7 | 0 | 0 | I am developing a game in Python and was wondering how to give it its own icon. I am using a windows computer and have no extra things installed with Python. Oh also I am using version 3.3 Is this even possible.
P.S I have found other things on Stack Overflow but they are using different Operating Systems like Ubuntu and Macintosh | How To Add An Icon Of My Own To A Python Program | 1 | 0.057081 | 1 | 0 | 0 | 40,170 |
16,784,271 | 2013-05-28T05:09:00.000 | 1 | 0 | 0 | 0 | 0 | python,orm,module,openerp | 0 | 16,789,456 | 0 | 1 | 0 | true | 1 | 0 | there is a model called 'ir.sequence'. You can create a sequence type and sequence for your model and then just by calling the code of the sequence you will be able to generate new sequences | 1 | 0 | 0 | 0 | I need a field which adds a counter to a specific item i add in the product section of a custom module.
Like an automatic number generated by the system, for let's say Internal Reference, so every time i save a new product this field will create a number for it in this field, like IN0001, IN0002, IN0003, etc...
I've looked into the internet, searching for some example on how to achieve this in OpenErp but no luck.
Is there any module or already made function in OpenErp which has this behavior?
Thanks in advance | Counter in OpenErp - Python | 0 | 1.2 | 1 | 0 | 0 | 171 |
16,820,895 | 2013-05-29T18:03:00.000 | 1 | 0 | 1 | 1 | 0 | python,pyparsing | 0 | 16,822,978 | 0 | 1 | 0 | false | 0 | 0 | Try Suppress("\r\n") instead of Suppress(LineEnd()) | 1 | 1 | 0 | 0 | I have a simple pyparsing construct for extracting parts of a log message. It looks like this
log_line = timestamp + task_info + Suppress(LineEnd())
This construct parses a log file generated in Linux very well but doesn't parse a similar file generated in windows. I am pretty sure it is because of the new line representation difference. I was wondering if LineEnd() takes care of that? If it doesn't how do I take care of it? | pyparsing not working on windows text file but works on linux text file | 0 | 0.197375 | 1 | 0 | 0 | 147 |
16,820,903 | 2013-05-29T18:04:00.000 | 1 | 0 | 1 | 0 | 1 | python,matplotlib,python-3.3 | 0 | 16,823,062 | 1 | 2 | 0 | true | 0 | 0 | I suspect you need to install python3-matplotlib, python3-numpy, etc. python-matlab is the python2 version. | 1 | 1 | 1 | 0 | Today I upgraded to Xubuntu 13.04 which comes with Python 3.3. Before that, I was working with Pyton 3.2, which was working perfectly fine.
When running my script under Python 3.3, I get an
ImportError: No module named 'pylab'
in import pylab.
Running in Python 3.2, which I reinstalled, throws
ImportError: cannot import name multiarray
in import numpy.
Scipy, numpy and matplotlib are, recording to apt, on the newest version.
I don't have much knowledge about this stuff. Do you have any recommendations on how to get my script to work again, preferably on Python 3.2?
Thanks in advance,
Katrin
Edit:
We solved the problem: Apparently, there where a lot of fragments / pieces of the packages in different paths, as I installed from apt, pip as well as manually. After deleting all packages and installing them only via pip, everything works fine. Thank you very much for the help! | Pylab after upgrading | 0 | 1.2 | 1 | 0 | 0 | 312 |
16,846,391 | 2013-05-30T21:45:00.000 | 3 | 0 | 0 | 0 | 0 | python,django,web-applications | 0 | 16,846,436 | 0 | 4 | 0 | false | 1 | 0 | For this to be meaningful, you likely need to connect to the same database
Why would you need two codebases? You have two copies of a single codebase. | 3 | 2 | 0 | 0 | I have a Django project with several apps. My project is now getting to the point it needs an API. I'm planning to have the API on a different server using tastypie. However, the API will use the same models as the website.
So far I see my only option is as follows...
Copy the apps to the server which means I have two apps using the same models and now have to maintain two code bases --- bad!
So, how do other handle this? What options do I have?
Can my models be shared somehow? | Does a Django site with a Tastypie interface need two codebases? | 0 | 0.148885 | 1 | 0 | 0 | 134 |
16,846,391 | 2013-05-30T21:45:00.000 | 1 | 0 | 0 | 0 | 0 | python,django,web-applications | 0 | 16,846,450 | 0 | 4 | 0 | false | 1 | 0 | Why don't you run the api on the same server on a different port? that will save you a lot of problems to start with. Sharing database connections cross servers will likely require you to think about security, a lot.
Also if you are reusing the same apps in different projects you might want to package and version your apps for comfort. Think about the real problem you are trying to solve and always keep that in mind. There are plenty of solutions for every problem, finding the right one makes a difference. | 3 | 2 | 0 | 0 | I have a Django project with several apps. My project is now getting to the point it needs an API. I'm planning to have the API on a different server using tastypie. However, the API will use the same models as the website.
So far I see my only option is as follows...
Copy the apps to the server which means I have two apps using the same models and now have to maintain two code bases --- bad!
So, how do other handle this? What options do I have?
Can my models be shared somehow? | Does a Django site with a Tastypie interface need two codebases? | 0 | 0.049958 | 1 | 0 | 0 | 134 |
16,846,391 | 2013-05-30T21:45:00.000 | 2 | 0 | 0 | 0 | 0 | python,django,web-applications | 0 | 16,855,093 | 0 | 4 | 0 | true | 1 | 0 | I wouldn't recommend splitting your project like this.
Every time you edit a model you have to edit it on both immediately or risk things getting out of sync. This will get very very painful, instead;
Is the server the bottleneck? Split site and api machines (but using the same models.py) and share the connection to the DB somewhere.
Is the DB the bottleneck? Scale up the DB to a faster machine / cluster and use the same site for to supply web and api.
Either way, One codebase, One set of models, One DB! | 3 | 2 | 0 | 0 | I have a Django project with several apps. My project is now getting to the point it needs an API. I'm planning to have the API on a different server using tastypie. However, the API will use the same models as the website.
So far I see my only option is as follows...
Copy the apps to the server which means I have two apps using the same models and now have to maintain two code bases --- bad!
So, how do other handle this? What options do I have?
Can my models be shared somehow? | Does a Django site with a Tastypie interface need two codebases? | 0 | 1.2 | 1 | 0 | 0 | 134 |
16,846,967 | 2013-05-30T22:37:00.000 | 1 | 0 | 0 | 0 | 0 | android,python,sockets,tcp | 0 | 16,847,185 | 0 | 2 | 0 | false | 0 | 1 | Well, you could have the Android Application save the image to a folder and have the Python file import that image. | 2 | 1 | 0 | 0 | I have an Android application that captures an image and Python code that extracts some features from images. I want to connect them to each other (receive the image in Python from the Android application). I read some things about building a TCP Server, but I don't know how to do it and how to start as it's my first time to do something like that.
Can anyone help? | Connect Android to Python | 0 | 0.099668 | 1 | 0 | 0 | 653 |
16,846,967 | 2013-05-30T22:37:00.000 | -1 | 0 | 0 | 0 | 0 | android,python,sockets,tcp | 0 | 36,057,987 | 0 | 2 | 0 | false | 0 | 1 | You can upload a image to server using any of the database, use python code on server side and you will get the result. | 2 | 1 | 0 | 0 | I have an Android application that captures an image and Python code that extracts some features from images. I want to connect them to each other (receive the image in Python from the Android application). I read some things about building a TCP Server, but I don't know how to do it and how to start as it's my first time to do something like that.
Can anyone help? | Connect Android to Python | 0 | -0.099668 | 1 | 0 | 0 | 653 |
16,867,749 | 2013-06-01T00:15:00.000 | 0 | 0 | 0 | 0 | 0 | android,python,sockets,tcp | 0 | 16,868,676 | 0 | 2 | 0 | false | 0 | 0 | poof's answer is a good overview, but here are some notes on the various options:
Option 1: Have your Android get the picture and do a HTTP POST to a Python application running a framework such as Django. It should be 1 line of code on Android, and only a few lines of code on Python (around your existing code).
The upside is that the low-level "Glue" is written for you, and it scales easily. The downside is that HTTP has some overhead.
Option 2: Have your Android talk a custom TCP protocol to a custom TCP application.
This is more work, so you should avoid it unless you need it. It will be more efficient and have lower latency, especially if you're sending multiple pictures. The response can also be much smaller without HTTP headers.
In either option, you don't have to send a JPEG, you could send any custom format you want (there is a trade-off between compression on Android and size of file).
I thought of using TCP Server, but I am new to socket programming and don't know how and where to start.
Start where everyone else started - by reading a lot and playing a lot. You can find plenty of introductions to Socket programming in Python on the web. Go thru the tutorials, and start modifying them to see how they work. Read up on TCP/IP itself -- there are a lot of dark corners (Nagel, fragmentation, slow start) that can affect how you write the app when you get to a low level. | 1 | 0 | 0 | 0 | I am currently involved in a project where we performed some computer vision object recognition and classification using python. It is necessary to use photos taken from an Android phone (photos should be automatically sent from android to python). I actually don't know how should I connect both applications (android and python) together. I thought of using TCP Server, but I am new to socket programming and don't know how and where to start.
Any one can help? | Tcp/IP socket programming in python | 0 | 0 | 1 | 0 | 1 | 780 |
16,867,823 | 2013-06-01T00:26:00.000 | 3 | 0 | 0 | 0 | 0 | python,mysql,mysql-python | 0 | 16,867,914 | 0 | 4 | 0 | false | 0 | 0 | Yes if you really need unlimited precision then you'll have to use a blob because even strigns are limited.
But really I can almost guarantee that you'll be fine with a NUMERIC/DECIMAL data type. 65 digits means that you can represent numbers in the range (-10^65, 10^65). How large is this? To give you some idea: The number of atoms in the whole universe is estimated to be about 10^80. If you only need positive numbers you can further increase the range by a factor of 2 by subtracting 10^65 -1 beforehand. | 1 | 2 | 0 | 0 | I need to represent instances of Python "Long integer" in MySQL. I wonder what the most appropriate SQL data type I should use.
The Python documentation (v2.7) says (for numbers.Integral):
Long integers
These represent numbers in an unlimited range, subject to available (virtual) memory only. For the purpose of shift and mask operations, a binary representation is assumed, and negative numbers are represented in a variant of 2’s complement which gives the illusion of an infinite string of sign bits extending to the left.
My read of the MySQL documentation suggests that BIGINT is limited to 64 bits. The DECIMAL type seems to be limited to 65 digits. I can, of course, use BLOB.
The application needs to support very large amounts of data, but I don't know yet how big these long integers might get, nor how many of them I'm likely to see.
I'd like to preserve the spirit of the Python long integer definition, which suggests BLOB. I'd also like to avoid re-inventing the wheel, and so I am appealing to the stackoverflow hive-mind.
Suggestions? | What are the options for storing Python long integers in MySQL? | 0 | 0.148885 | 1 | 1 | 0 | 1,333 |
16,874,046 | 2013-06-01T15:04:00.000 | 17 | 0 | 1 | 0 | 0 | python,console,pycharm | 0 | 29,418,064 | 0 | 9 | 0 | false | 0 | 0 | For anyone still having this problem: Go to the Run/Debug menu, choose Edit Configuration, check the box 'Show command line' this will enable you to enter parameters in the console at the >>> prompt and test your function.
Edit: To make this change apply to all your .py files (as this check box only applies to the current file you're working on) go to: Edit configuration, in the pop up you will see a menu tree on the left, select Defaults, then Python, then check the 'Show command line' box, this will make it the default setting whenever you open a .py file, (this feature should really be on by default!) | 2 | 25 | 0 | 0 | I'm new to python and pycharm and I'd like to run a module from the pycharm console in the same way as you can from IDLE, if it's possible.
The idea is to create simple functions and test them "live" using the console.
...how do you do that in pycharm? | Running a module from the pycharm console | 0 | 1 | 1 | 0 | 0 | 69,594 |
16,874,046 | 2013-06-01T15:04:00.000 | 3 | 0 | 1 | 0 | 0 | python,console,pycharm | 0 | 27,771,551 | 0 | 9 | 0 | false | 0 | 0 | Select the script lines that you want to execute and press Shift+Alt+E | 2 | 25 | 0 | 0 | I'm new to python and pycharm and I'd like to run a module from the pycharm console in the same way as you can from IDLE, if it's possible.
The idea is to create simple functions and test them "live" using the console.
...how do you do that in pycharm? | Running a module from the pycharm console | 0 | 0.066568 | 1 | 0 | 0 | 69,594 |
16,877,448 | 2013-06-01T21:29:00.000 | 2 | 0 | 1 | 0 | 1 | python,scikit-learn | 0 | 16,877,799 | 0 | 1 | 0 | true | 0 | 0 | Found it, there's a note on the svm page that if you enable verbose settings multiprocessing may break. Disabling verbose fixed it | 1 | 1 | 1 | 0 | Trying to use gridsearch CV with multiple jobs via the n_jobs argument and I can see using htop that they're all launched and running but they all get stuck/assigned on the same core using 25% each (I'm using a 4 core machine). I'm on Ubuntu 12.10 and I'm running the latest master pulled from github. Anyone know how to fix this?
Thanks! | Scikit-Learn n_jobs Multiprocessing Locked To One Core | 0 | 1.2 | 1 | 0 | 0 | 391 |
16,893,882 | 2013-06-03T09:43:00.000 | 0 | 0 | 1 | 1 | 1 | python,python-module | 1 | 16,894,057 | 0 | 2 | 0 | false | 0 | 0 | You need to change the permissions for the directory the process wants to write to. Find out what directory joblib wants to put things in and change its permissions or use a different directory with the needed permissions for this. In order to be able to give the permissions and to allow Python to write to the filesystem, it must be mounted in a way that allows writing. | 1 | 0 | 0 | 0 | Anyone knows what this error is and how to fix it?
I've already tried to
chmod -R 777 /usr/local/python2.6/dist-packages/joblib but with no luck. | /usr/local/lib/python2.6/dist-packages/joblib/parallel.py:40: UserWarning: [Errno 30] Read-only file system. joblib will operate in serial mode | 0 | 0 | 1 | 0 | 0 | 776 |
16,900,215 | 2013-06-03T15:20:00.000 | 4 | 0 | 0 | 0 | 0 | python,django,javascriptmvc | 0 | 16,900,507 | 0 | 1 | 0 | false | 1 | 0 | If you don't want to render a template, simply don't render it. Django won't render anything unless you specifically call template.render or one of the shortcuts.
If you just want to return an HTML file, you could just open it as a normal file, read it, then return the content as the response.
Alternatively, as suggested in the comment, you can serve it as a static file. | 1 | 2 | 0 | 0 | I'm writing a single view Javascript application with a Django backend that only needs to return the initial index.html and all other templates come from a CDN. My problem is that this first index.html file is parsing out some of my "{{}}" handlebars which I wanted to leave for the JS library to interpret.
I DO NOT want to use 'verbatim' or 'raw' or any additional tags because I don't want any django specific stuff in my static template files.
A possible alternative answer to this would be desmonstrating how to to make your inital index HTML response also come from the CDN but I didn't think that was possible. | Django return .html file directly without parsing for template tags at all | 0 | 0.664037 | 1 | 0 | 0 | 2,717 |
16,915,118 | 2013-06-04T10:09:00.000 | 0 | 1 | 1 | 0 | 0 | python,scripting | 1 | 16,915,630 | 0 | 3 | 0 | false | 0 | 0 | Others have already mentioned documentation and unit-testing as being the main tools here. I want to add a third: the Python shell. One of the huge advantages of a non-compiled language like Python is that you can easily fire up the shell, import your module, and run the code there to see what it does and what it returns.
Linked to this is the Python debugger: just put import pdb;pdb.set_trace() at any point in your code, and when you run it you will be dropped into the interactive debugger where you can inspect the current values of the variables. In fact, the pdb shell is an actual Python shell as well, so you can even change things there. | 2 | 0 | 0 | 0 | Python is a relatively new language for me and I already see some of the trouble areas of maintaining a scripting language based project. I am just wondering how the larger community , with a scenario when one has to maintain a fairly large code base written by people who are not around anymore, deals with the following situations:
Return type of a function/method. Assuming past developers didn't document the code very well, this is turning out to be really annoying as I am basically reading code line by line to figure out what a method/function is suppose to return.
Code refactoring: I figured a lot of code need to be moved around, edited/deleted and etc. But lot of times simple errors, which would otherwise be compile time error in other compiled languages e.g. - wrong number of arguments, wrong type of arguments, method not present and etc, only show up when you run the code and the code reaches the problematic area. Therefore, whether a re-factored code will work at all or not can only be known once you run the code thoroughly. I am using PyLint with PyDev but still I find it very lacking in this respect. | checking/verifying python code | 0 | 0 | 1 | 0 | 0 | 51 |
16,915,118 | 2013-06-04T10:09:00.000 | 0 | 1 | 1 | 0 | 0 | python,scripting | 1 | 16,915,300 | 0 | 3 | 0 | false | 0 | 0 | You are right, that's an issue with dynamically typed interpreted languages.
There are to important things that can help:
Good documentation
Extensive unit-testing.
They apply to other languages as well of course, but here they are especially important. | 2 | 0 | 0 | 0 | Python is a relatively new language for me and I already see some of the trouble areas of maintaining a scripting language based project. I am just wondering how the larger community , with a scenario when one has to maintain a fairly large code base written by people who are not around anymore, deals with the following situations:
Return type of a function/method. Assuming past developers didn't document the code very well, this is turning out to be really annoying as I am basically reading code line by line to figure out what a method/function is suppose to return.
Code refactoring: I figured a lot of code need to be moved around, edited/deleted and etc. But lot of times simple errors, which would otherwise be compile time error in other compiled languages e.g. - wrong number of arguments, wrong type of arguments, method not present and etc, only show up when you run the code and the code reaches the problematic area. Therefore, whether a re-factored code will work at all or not can only be known once you run the code thoroughly. I am using PyLint with PyDev but still I find it very lacking in this respect. | checking/verifying python code | 0 | 0 | 1 | 0 | 0 | 51 |
16,951,821 | 2013-06-06T00:09:00.000 | 1 | 0 | 1 | 0 | 0 | python,gdb | 0 | 16,952,566 | 0 | 1 | 0 | true | 0 | 0 | I think you can use Type.fields to iterate over the fields.
Then, you can look at the field offset and you can compute a pointer to the anonymous field, along the lines of (type *) (((char *) obj) + offset).
This isn't ideal. There is a bug open to implement something better. | 1 | 1 | 0 | 0 | GDB 7.2 python doesn't have gdb.Type.iteritems method. Anyway I can access the members of the anonymous structure (which is within another structure of course) from gdb 7.2 ? The assumption is that I dont know know the name of the members of the anonymous structure or else I could have done gdb.parse_and_eval on them. | GDB 7.2 + python: how to get members of anonymous structure? | 0 | 1.2 | 1 | 0 | 0 | 267 |
16,952,059 | 2013-06-06T00:47:00.000 | 1 | 0 | 0 | 0 | 0 | python,pygame | 0 | 16,952,066 | 0 | 3 | 0 | false | 0 | 1 | On each handle of the input, check if the object's target x position plus its width exceeds the width of the canvas or if it is less than 0. Deny the movement if so.
Repeat for the y coordinate and the height. | 1 | 0 | 0 | 0 | I have made an object controlled with arrow keys. When I move it to the edge of the pygame screen, the object moves off the screen. I was wondering how to keep the object on the screen. Any suggestions? | In pygame how to make an object controlled with arrow keys not move of the edge of the screen | 0 | 0.066568 | 1 | 0 | 0 | 364 |
16,957,276 | 2013-06-06T08:32:00.000 | 0 | 0 | 0 | 0 | 0 | python,multithreading,multiprocessing,scrapy,web-crawler | 0 | 16,961,651 | 0 | 4 | 1 | false | 1 | 0 | Scrapy is still an option.
Speed/performance/efficiency
Scrapy is written with Twisted, a popular event-driven networking
framework for Python. Thus, it’s implemented using a non-blocking (aka
asynchronous) code for concurrency.
Database pipelining
You mentioned that you want your data to be pipelined into the database - as you may know Scrapy has Item Pipelines feature:
After an item has been scraped by a spider, it is sent to the Item
Pipeline which process it through several components that are executed
sequentially.
So, each page can be written to the database immediately after it has been downloaded.
Code organization
Scrapy offers you a nice and clear project structure, there you have settings, spiders, items, pipelines etc separated logically. Even that makes your code clearer and easier to support and understand.
Time to code
Scrapy does a lot of work for you behind the scenes. This makes you focus on the actual code and logic itself and not to think about the "metal" part: creating processes, threads etc.
But, at the same time, Scrapy might be an overhead. Remember that Scrapy was designed (and great at) to crawl, scrape the data from the web page. If you want just to download a bunch of pages without looking into them - then yes, grequests is a good alternative. | 1 | 5 | 0 | 0 | I have a >100,000 urls (different domains) in a list that I want to download and save in a database for further processing and tinkering.
Would it be wise to use scrapy instead of python's multiprocessing / multithreading? If yes, how do I write a standalone script to do the same?
Also, feel free to suggest other awesome approaches that come to your mind. | What is the best way to download number of pages from a list of urls? | 0 | 0 | 1 | 0 | 1 | 1,273 |
16,994,243 | 2013-06-07T23:13:00.000 | 5 | 0 | 1 | 0 | 0 | python,pygame,draw | 0 | 17,000,916 | 0 | 1 | 0 | true | 0 | 1 | The command is pygame.draw.circle(Surface, color, pos, radius, width=0). The last argument of width can be changed to not fill the circle in. If it is zero, the circle is solid and if it is anything else it is with an edge thickness of whatever the parameter is. | 1 | 1 | 0 | 0 | If I want to craw a circle, I use the regualr draw.circle but the problem is that I don't want it filled so I draw a smaller circle inside of it, it makes a circle with thickness.
Everything is good right? no. The background image inside that circle disappeared because the circles are filled.
Now my question is: There is a function that draws a circle (and other shapes[?]) that gets thick and not filling the whole inside of the shape?
EDIT: If you can give me the signature so I know how to use it. | pygame not filled shapes (Python) | 0 | 1.2 | 1 | 0 | 0 | 9,645 |
16,995,007 | 2013-06-08T01:09:00.000 | -2 | 0 | 1 | 0 | 0 | python,counter,urlopen | 0 | 16,995,022 | 0 | 3 | 0 | false | 0 | 0 | i think you can't do it that way.
Delete duplicates in list. | 1 | 0 | 0 | 0 | I'm running a Python code that reads a list of URLs and opens each one of them individually with urlopen. Some URLs are repeated in the list. An example of the list would be something like:
www.example.com/page1
www.example.com/page1
www.example.com/page2
www.example.com/page2
www.example.com/page2
www.example.com/page3
www.example.com/page4
www.example.com/page4
[...]
I would like to know if there's a way to implement a counter that would tell me how many times a unique URL was opened previously by the code. I want to get a counter that would return me what is showed in bold for each of the URLs in the list.
www.example.com/page1 : 0
www.example.com/page1 : 1
www.example.com/page2 : 0
www.example.com/page2 : 1
www.example.com/page2 : 2
www.example.com/page3 : 0
www.example.com/page4 : 0
www.example.com/page4 : 1
Thanks! | How to count the number of time a unique URL is open in python? | 0 | -0.132549 | 1 | 0 | 0 | 1,310 |
17,012,349 | 2013-06-09T17:36:00.000 | 4 | 0 | 0 | 0 | 0 | python,psycopg2 | 0 | 17,012,369 | 0 | 2 | 0 | true | 1 | 0 | Have you looked in to SQLAlchemy at all? It takes care of a lot of the dirty details - it maintains a pool of connections, and reuses/closes them as necessary. | 1 | 4 | 0 | 0 | I've been writing a Python web app (in Flask) for a while now, and I don't believe I fully grasp how database access should work across multiple request/response cycles. Prior to Python my web programming experience was in PHP (several years worth) and I'm afraid that my PHP experience is misleading some of my Python work.
In PHP, each new request creates a brand new DB connection, because nothing is shared across requests. The more requests you have, the more connections you need to support. However, in a Python web app, where there is shared state across requests, DB connections can persist.
So I need to manage those connections, and ensure that I close them. Also, I need to have some kind of connection pool, because if I have just one connection shared across all requests, then requests could block waiting on DB access, if I don't have enough connections available.
Is this a correct understanding? Or have I identified the differences well? In a Python web app, do I need to have a DB connection pool that shares its connections across many requests? And the number of connections in the pool will depend on my application's request load?
I'm using Psycopg2. | Database access strategy for a Python web app | 0 | 1.2 | 1 | 1 | 0 | 351 |
17,013,738 | 2013-06-09T20:13:00.000 | 1 | 0 | 1 | 0 | 0 | python,python-3.x | 0 | 17,013,917 | 0 | 2 | 0 | false | 0 | 0 | You don't necessarily have to create a class in python, but the use of classes would help you wrap up functions and variables into an object. | 1 | 2 | 0 | 0 | I'm creating my own python module that has some functions I want to use. I wanna know how to do these things:
How do I proceed with my python module called module.py, so I import only the functions I want, when calling 'import module.function'? (so I don't have to import the entire module)
Does I always have to create a class for my functions, even if I would never use more than ONE object of that class? (if not, how to create a function that has all the self variables inside, so them don't mess up with global variables from the entire code?) (but without use def fun(self, var1, var2...) because I don't want to call fun("", var1, var2...)
Is it better to 'install' my module or use it like a external file? | Creating my own python module - questions | 0 | 0.099668 | 1 | 0 | 0 | 382 |
17,021,318 | 2013-06-10T10:03:00.000 | 3 | 0 | 0 | 0 | 0 | python,django | 0 | 17,021,455 | 0 | 2 | 1 | true | 1 | 0 | You can do everything web with Django just like with any other webframework/weblibrary.
Probably the easiest way would be to have a user-profile, and as soon as the payment has been working out you add this video to the users "allowed" list. This makes it quite easy to show the users available videos.
The redirection thing after payment really depends on your provider, paypal and others allow you to embed their payment process into your application, and have powerful APIs to check for "incoming" payments. | 2 | 0 | 0 | 0 | Is it possible to implement this in django: In a video site, for every video a user want to watch he/she must pay a fee before watching the video. If it's possible, what's the best way to implement this. And after every successful payment, how can the user be redirected back to the particular video he paid for? | Pay Per Request in Django | 1 | 1.2 | 1 | 0 | 0 | 228 |
17,021,318 | 2013-06-10T10:03:00.000 | 0 | 0 | 0 | 0 | 0 | python,django | 0 | 17,021,565 | 0 | 2 | 1 | false | 1 | 0 | I believe this is possible.
What you can do is have a check on your video page for a certain receipt that you can add as an entry in the UserProfile model that you'll have for your django website.
Now this receipt will only be generated when your user goes through the complete payment path which you can handle by scripts.
And as for redirection, you can have the payment processing service redirect to your receipt token generating django view that handles the addition of the user to your whitelist for that video. | 2 | 0 | 0 | 0 | Is it possible to implement this in django: In a video site, for every video a user want to watch he/she must pay a fee before watching the video. If it's possible, what's the best way to implement this. And after every successful payment, how can the user be redirected back to the particular video he paid for? | Pay Per Request in Django | 1 | 0 | 1 | 0 | 0 | 228 |
17,030,589 | 2013-06-10T18:41:00.000 | 1 | 0 | 1 | 1 | 1 | ipython-notebook | 1 | 17,628,850 | 0 | 1 | 0 | false | 0 | 0 | For those who end up on this page, here's the solution. This is happening because your OS package manager (in my case 12.04) is lagging pypi in python packages - but not in core libraries (like zeromq).
To solve this, my recommended solution is to install python-pandas using your package manager, but also install systemwide "pip". and then run "sudo pip install --upgrade ipython,pandas"
this should get everything back in sync. | 1 | 1 | 0 | 0 | I am using python 2.6, ipython 0.12.1, tornado 3.02, pyzmq 13.1 , I am getting this error when I start ipython notebook.
"Websocket connection cannot be made"
In the ipython console window I get torado.application error , in line 183 in create_shell_stream
shell_stream = self.create_connected_stream(ip.....,zmq.XREQ)
error is "module" object has no attribute 'XREQ'
Do you know what's wrong? and how can I fix this error?
I installed ipython, tornado and pyzmq seperate and not from easy_install or pip. | Ipython - Notebook error: Tornado.application : "Module" object has no attribute 'XREQ' | 0 | 0.197375 | 1 | 0 | 0 | 494 |
17,040,209 | 2013-06-11T09:01:00.000 | 0 | 0 | 0 | 1 | 0 | python,google-app-engine,debugging,ide,breakpoints | 0 | 18,138,699 | 0 | 2 | 1 | false | 0 | 0 | The latest version of PyDev (2.8.1) supports GAE debugging. However, "Edit and Continue Debugging or Interactive Debugging" feature seems to have stopped working. | 1 | 2 | 0 | 0 | I'm developing on GAE-Python 2.7 using Eclipse+PyDev as IDE. Since GAE SDK 1.7.6 (March 2013), where Google "broke" support for breakpoints*, I've been using the old dev server to continue debugging the application I'm working on.
However, Google will drop support of the old dev server as of July 2013 and, since I do not expect a prompt solution for this on PyDev (I've seen no activity so far about this), I would like to look for an alternative IDE to still being able to do debugging.
I know that one of the possible options is to go for PyCharm (initial license of 89€+VAT and 59€+VAT each year to continue receiving upgrades), but I would like to know how other people is (will be) addressing this problem and what are the current alternatives to PyCharm
*I would like to clarify the sentence "Google broke support for breakpoints": In SDK 1.7.6+, Google started using stdin/stdout in the new dev server for doing IPC and this leaves no chances to even do debugging with pdb. Google claims that they have created the hooks for tool vendors to support debugging (as PyCharm did) but, in my opinion, they "broke" debugging by forcing people to move away from the IDE they were initially recommending due to an architectural decision (I'm not an expert, but they could have used the native IPC mechanisms included in Python instead of using stdin/stdout).
EDIT:
I forgot to mention that I'm running Eclipse+Pydev for MacOSX, so please, also mention your OS compatibility in your alternatives/solutions. | Alternative IDE supporting debugging for Google App Engine in Python (Eclipse + PyDev no debug support on SDK 1.7.6+) | 1 | 0 | 1 | 0 | 0 | 927 |
17,046,929 | 2013-06-11T14:41:00.000 | 0 | 0 | 0 | 1 | 0 | python,emacs,command,interpreter | 0 | 17,047,535 | 0 | 2 | 0 | false | 0 | 0 | AFAIS the keys are the same as in M-x shell. See menu In/Out for available keys/commands. | 1 | 12 | 0 | 0 | Inside emacs I am running interpreters for several different languages (python, R, lisp, ...). When I run the interpreters through the terminal in most cases I can use the up arrow to see the last command or line of code that I entered. I no longer have this functionality when I am running the interpreters in emacs. How can I achieve this functionality?
How can I access the command history from the interpreter inside emacs?
Can I do this generally for language X?
At the moment I need to use python, so if anyone knows how to do this specifically with the python interpreter in emacs please let me know! | Command history in interpreters in emacs | 0 | 0 | 1 | 0 | 0 | 1,865 |
17,087,758 | 2013-06-13T13:02:00.000 | -1 | 0 | 1 | 0 | 0 | python | 0 | 17,089,367 | 0 | 3 | 0 | false | 0 | 0 | If your purpose is to not give away code, then just distribute the python-compiled library, rather than the source code for it. No need to manually weed code calls, just distribute the pyc versions of your files. If you're afraid that people will take your code and not give you credit, don't give them code if there is an alternative.
That said, we have licenses for a reason. You put the minimal header and your attribution at the top of every file, and you distribute a LICENSE file with your software that clearly indicates what people are, and are not, allowed to do with your source code. If they violate that, and you catch them, you now have legal recourse. IF you don't trust people to uphold that license: that's the whole reason it's there. If your code is so unique that it needs to be licensed for fear of others passing it off as their own, it will be easy to find infractions. If, however, you treat all your code like this, a small reality check: you are not that good. Almost nothing you write will be original enough that others haven't already also written it, trying to cling to it is not going to benefit you, or anyone else.
Best code protection? Stick it online for everyone to see, so that you can point everyone else to it and go "see? that's my code. And this jerk is using it in their own product without giving me credit". Worse code protection, but still protection: don't distribute code, distribute the compiled libraries. (Worst code protect: distributing gimped code because you're afraid of the world for the wrong reasons) | 2 | 13 | 0 | 0 | I have the following situation: I am working on several projects which make use of library modules that I have written. The library modules contain several classes and functions. In each project, some subset of the code of the libraries is used.
However, when I publish a project for other users, I only want to give away the code that is used by that project rather than the whole modules. This means I would like, for a given project, to remove unused library functions from the library code (i.e. create a new reduced library). Is there any tool that can do this automatically?
EDIT
Some clarifications/replies:
Regarding the "you should not do this in general" replies: The bottom line is that in practice, before I publish a project, I manually go through the library modules and remove unused code. As we are all programmers, we know that there is no reason to do something manually when you could easily explain to a computer how to do it. So practically, writing such a program is possible and should even not be too difficult (yes, it may not be super general). My question was if someone know whether such a tool exists, before I start thinking about implementing it by myself. Also, any thoughts about implementing this are welcome.
I do not want to simply hide all my code. If I would have wanted to do that I would have probably not used Python. In fact, I want to publish the source code, but only the code which is relevant to the project in question.
Regarding the "you are legally protected" comments: In my specific case, the legal/license protection does not help me. Also, the problem here is more general than some stealing the code. For example, it could be for the sake of clarity: if someone needs to use/develop the code, you don't want dozens of irrelevant functions to be included. | Is there a tool that removes functions that are not used in Python? | 1 | -0.066568 | 1 | 0 | 0 | 755 |
17,087,758 | 2013-06-13T13:02:00.000 | 1 | 0 | 1 | 0 | 0 | python | 0 | 17,096,348 | 0 | 3 | 0 | false | 0 | 0 | I agree with @zmo - one way to avoid future problems like this is to plan ahead and make your code as modular as possible. I would have suggested putting the classes and functions in much smaller files. This would mean that for every project you make, you would have to hand-select which of these smaller files to include. I'm not sure if that's feasible with the size of your projects right now. But for future projects it's a practice you may consider. | 2 | 13 | 0 | 0 | I have the following situation: I am working on several projects which make use of library modules that I have written. The library modules contain several classes and functions. In each project, some subset of the code of the libraries is used.
However, when I publish a project for other users, I only want to give away the code that is used by that project rather than the whole modules. This means I would like, for a given project, to remove unused library functions from the library code (i.e. create a new reduced library). Is there any tool that can do this automatically?
EDIT
Some clarifications/replies:
Regarding the "you should not do this in general" replies: The bottom line is that in practice, before I publish a project, I manually go through the library modules and remove unused code. As we are all programmers, we know that there is no reason to do something manually when you could easily explain to a computer how to do it. So practically, writing such a program is possible and should even not be too difficult (yes, it may not be super general). My question was if someone know whether such a tool exists, before I start thinking about implementing it by myself. Also, any thoughts about implementing this are welcome.
I do not want to simply hide all my code. If I would have wanted to do that I would have probably not used Python. In fact, I want to publish the source code, but only the code which is relevant to the project in question.
Regarding the "you are legally protected" comments: In my specific case, the legal/license protection does not help me. Also, the problem here is more general than some stealing the code. For example, it could be for the sake of clarity: if someone needs to use/develop the code, you don't want dozens of irrelevant functions to be included. | Is there a tool that removes functions that are not used in Python? | 1 | 0.066568 | 1 | 0 | 0 | 755 |
17,093,372 | 2013-06-13T17:27:00.000 | 5 | 0 | 0 | 0 | 0 | python,flask,query-string | 0 | 21,792,010 | 0 | 2 | 0 | false | 1 | 0 | request.query_string also seems to work. | 1 | 6 | 0 | 0 | Is there a way to get the raw query string or a list of query string parameters in Flask?
I know how to get query string parameters with request.args.get('key'), but I would like to be able to take in variable query strings and process them myself. Is this possible? | Get raw query string in flask | 1 | 0.462117 | 1 | 0 | 0 | 4,634 |
17,113,591 | 2013-06-14T16:55:00.000 | 0 | 0 | 0 | 0 | 0 | python,cmd,shutdown,minecraft | 0 | 17,114,583 | 0 | 3 | 0 | false | 0 | 0 | I would look at the tools in the os module, it would also help if i had more information about what operating system you are using. | 2 | 0 | 0 | 0 | I have multiple minecraft servers running on the machine. servers are started with bat files that have according titles. My question is that, how can i shut down a certain minecraft server with python? Or how to kill a titled cmd.exe process with python? | How to shut down a minecraft server with python? | 0 | 0 | 1 | 0 | 0 | 1,744 |
17,113,591 | 2013-06-14T16:55:00.000 | 0 | 0 | 0 | 0 | 0 | python,cmd,shutdown,minecraft | 0 | 17,331,529 | 0 | 3 | 0 | false | 0 | 0 | I ended up using autohotkey. launched autohotkey with python and made separate .ahk files for every server. | 2 | 0 | 0 | 0 | I have multiple minecraft servers running on the machine. servers are started with bat files that have according titles. My question is that, how can i shut down a certain minecraft server with python? Or how to kill a titled cmd.exe process with python? | How to shut down a minecraft server with python? | 0 | 0 | 1 | 0 | 0 | 1,744 |
17,113,613 | 2013-06-14T16:55:00.000 | 0 | 0 | 0 | 0 | 0 | python,machine-learning,artificial-intelligence,neural-network | 0 | 17,117,416 | 0 | 2 | 0 | false | 0 | 0 | Assume you have v visible units, and h hidden units, and v < h. The key idea is that once you've fixed all the values for each visible unit, the hidden units are independent.
So you loop through all 2^v subsets of visible unit activations. Then computing the likelihood for the RBM with this particular activated visible subset is tractable, because the hidden units are independent[1]. So then loop through each hidden unit, and add up the probability of it being on and off conditioned on your subset of visible units. Then multiply out all of those summed on/off hidden probabilities to get the probability that particular subset of visible units. Add up all subsets and you are done.
The problem is that this is exponential in v. If v > h, just "transpose" your RBM, pretending the hidden are visible and vice versa.
[1] The hidden units can't influence each other, because you influence would have to go through the visible units (no h to h connections), but you've fixed the visible units. | 1 | 0 | 1 | 0 | I have been researching RBMs for a couple months, using Python along the way, and have read all your papers. I am having a problem, and I thought, what the hey? Why not go to the source? I thought I would at least take the chance you may have time to reply.
My question is regarding the Log-Likelihood in a Restricted Boltzmann Machine. I have read that finding the exact log-likelihood in all but very small models is intractable, hence the introduction of contrastive divergence, PCD, pseudo log-likelihood etc. My question is, how do you find the exact log-likelihood in even a small model?
I have come across several definitions of this formula, and all seem to be different. In Tielemen’s 2008 paper “Training Restricted Boltzmann Machines using Approximations To the Likelihood Gradient”, he performs a log-likelihood version of the test to compare to the other types of approximations, but does not say the formula he used. The closest thing I can find is the probabilities using the energy function over the partition function, but I have not been able to code this, as I don’t completely understand the syntax.
In Bengio et al “Representation Learning: A Review and New Perspectives”, the equation for the log-likelihood is:
sum_t=1 to T (log P(X^T, theta))
which is equal to sum_t=1 to T(log * sum_h in {0,1}^d_h(P(x^(t), h; theta))
where T is training examples. This is (14) on page 11.
The only problem is that none of the other variables are defined. I assume x is the training data instance, but what is the superscript (t)? I also assume theta are the latent variables h, W, v… But how do you translate this into code?
I guess what I’m asking is can you give me a code (Python, pseudo-code, or any language) algorithm for finding the log-likelihood of a given model so I can understand what the variables stand for? That way, in simple cases, I can find the exact log-likelihood and then compare them to my approximations to see how well my approximations really are. | Finding log-likelihood in a restricted boltzmann machine | 0 | 0 | 1 | 0 | 0 | 1,642 |
17,116,718 | 2013-06-14T20:24:00.000 | 1 | 0 | 0 | 1 | 0 | android,python,django,web,localhost | 0 | 17,116,746 | 0 | 9 | 0 | false | 1 | 0 | If both are connected to the same network, all you need to do is provide the IP address of your server (in your network) in your Android app. | 6 | 31 | 0 | 0 | I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home.
i read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions.
I have samsung tab 2 10.1 with android 4.0.4.
appreciate any help, thanks | how to access my 127.0.0.1:8000 from android tablet | 1 | 0.022219 | 1 | 0 | 0 | 33,438 |
17,116,718 | 2013-06-14T20:24:00.000 | 0 | 0 | 0 | 1 | 0 | android,python,django,web,localhost | 0 | 61,816,349 | 0 | 9 | 0 | false | 1 | 0 | Try this
python manage.py runserver
then connect both tablet and system to same wifi and browse in the address
eg: python manage.py runserver 192.168.0.100:8000
In tablet type that url in adress bar | 6 | 31 | 0 | 0 | I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home.
i read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions.
I have samsung tab 2 10.1 with android 4.0.4.
appreciate any help, thanks | how to access my 127.0.0.1:8000 from android tablet | 1 | 0 | 1 | 0 | 0 | 33,438 |
17,116,718 | 2013-06-14T20:24:00.000 | 1 | 0 | 0 | 1 | 0 | android,python,django,web,localhost | 0 | 17,116,796 | 0 | 9 | 0 | false | 1 | 0 | need to know the ip address of your machine ..
Make sure both of your machines (tablet and computer) connected to same network
192.168.0.22 - say your machine address
do this :
192.168.0.22:8000 -- from your tablet
this is it !!! | 6 | 31 | 0 | 0 | I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home.
i read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions.
I have samsung tab 2 10.1 with android 4.0.4.
appreciate any help, thanks | how to access my 127.0.0.1:8000 from android tablet | 1 | 0.022219 | 1 | 0 | 0 | 33,438 |
17,116,718 | 2013-06-14T20:24:00.000 | 16 | 0 | 0 | 1 | 0 | android,python,django,web,localhost | 0 | 17,116,791 | 0 | 9 | 0 | true | 1 | 0 | You can find out what the ip address of your PC is with the ipconfig command in a Windows command prompt. Since you mentioned them being connected over WiFi look for the IP address of the wireless adapter.
Since the tablet is also in this same WiFi network, you can just type that address into your tablet's browser, with the :8000 appended to it and it should pull up the page. | 6 | 31 | 0 | 0 | I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home.
i read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions.
I have samsung tab 2 10.1 with android 4.0.4.
appreciate any help, thanks | how to access my 127.0.0.1:8000 from android tablet | 1 | 1.2 | 1 | 0 | 0 | 33,438 |
17,116,718 | 2013-06-14T20:24:00.000 | 6 | 0 | 0 | 1 | 0 | android,python,django,web,localhost | 0 | 17,116,785 | 0 | 9 | 0 | false | 1 | 0 | 127.0.0.1 is a loopback address that means, roughly, "this device"; your PC and your android tablet are separate devices, so each of them has its own 127.0.0.1. In other words, if you try to go to 127.0.0.1 on your Android tab, it's trying to connect to a webserver on the Android device, which is not what you want.
However, you should be able to connect over the wifi. On your windows box, open a command prompt and execute ipconfig. Somewhere in the output should be your windows box's address, probably 192.168.1.100 or something similar. You tablet should be able to see the Django server at that address. | 6 | 31 | 0 | 0 | I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home.
i read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions.
I have samsung tab 2 10.1 with android 4.0.4.
appreciate any help, thanks | how to access my 127.0.0.1:8000 from android tablet | 1 | 1 | 1 | 0 | 0 | 33,438 |
17,116,718 | 2013-06-14T20:24:00.000 | 23 | 0 | 0 | 1 | 0 | android,python,django,web,localhost | 0 | 48,594,665 | 0 | 9 | 0 | false | 1 | 0 | Though this thread was active quite a long time ago. This is what worked for me on windows 10. Posting it in details. Might be helpful for the newbies like me.
Add ALLOWED_HOSTS = ['*'] in django settings.py file
run django server with python manage.py 0.0.0.0:YOUR_PORT. I used 9595 as my port.
Make firewall to allow access on that port:
Navigate to control panel -> system and Security -> Windows Defender Firewall
Open Advanced Settings, select Inbound Rules then right click on it and then select New Rule
Select Port, hit next, input the port you used (in my case 9595), hit next, select allow the connections
hit next again then give it a name and hit next for the last time.
Now find the ip address of your PC.
Open Command Promt as adminstrator and run ipconfig command.
You may find more than one ip addresses. As I'm connected through wifi I took the one under Wireless LAN adapter WiFi. In my case it was 192.168.0.100
Note that this ip may change when you reconnect to the network. So you need to check it again then.
Now from another device (pc, mobile, tablet etc.) connected to the same network go to ip_address:YOUR_PORT (in my case 192.168.0.100:9595)
Hopefully you'll be good to go ! | 6 | 31 | 0 | 0 | I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home.
i read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions.
I have samsung tab 2 10.1 with android 4.0.4.
appreciate any help, thanks | how to access my 127.0.0.1:8000 from android tablet | 1 | 1 | 1 | 0 | 0 | 33,438 |
17,122,268 | 2013-06-15T09:46:00.000 | 0 | 0 | 1 | 0 | 0 | python,text,curses | 0 | 17,122,309 | 0 | 2 | 0 | false | 0 | 0 | You create static text by putting it in a separate window. Create a window large enough for all the text, and then create a smaller window for the dynamic text. Text is colored by passing the various COLOR_* constants as the text attribute. | 1 | 2 | 0 | 0 | I am creating a text adventure. How could I to add static text to this.
What i mean is some text that always stays on the left side of the window. Even if all the other text is scrolling down. Also how could i make this text red. | (python) How to create static text in curses | 0 | 0 | 1 | 0 | 0 | 2,751 |
17,122,479 | 2013-06-15T10:10:00.000 | 0 | 0 | 0 | 0 | 0 | python,printing | 0 | 17,122,495 | 0 | 2 | 0 | false | 0 | 0 | Wherever you call your printing routine, add a small unique header to printout (module name+line number) to identify the place print was initiated from. | 2 | 1 | 0 | 0 | This application I am working on (GUI based), has well over a dozen modules. On running the application and using it, there is this particular action(clicking a label) upon which I get tons of empty prints in the stdout and because of which I suspect the application's performance is suffering. Now the problem is I am unable to find out exactly which print statement is causing this to happen.
What I have tried as yet:
multi-buffer searches
commented the print statements which I know will be executed and left out the one which I am almost 100% sure will never be executed. period.
What I haven't tried:
pdb(time consuming)
Any ease hack(not too ugly) to corner out this print statement? | how to find out exactly from where print is being executed | 0 | 0 | 1 | 0 | 0 | 79 |
17,122,479 | 2013-06-15T10:10:00.000 | 6 | 0 | 0 | 0 | 0 | python,printing | 0 | 17,122,501 | 0 | 2 | 0 | true | 0 | 0 | Replace sys.stdout with a file-like that will spew out a traceback when its write() method is called. | 2 | 1 | 0 | 0 | This application I am working on (GUI based), has well over a dozen modules. On running the application and using it, there is this particular action(clicking a label) upon which I get tons of empty prints in the stdout and because of which I suspect the application's performance is suffering. Now the problem is I am unable to find out exactly which print statement is causing this to happen.
What I have tried as yet:
multi-buffer searches
commented the print statements which I know will be executed and left out the one which I am almost 100% sure will never be executed. period.
What I haven't tried:
pdb(time consuming)
Any ease hack(not too ugly) to corner out this print statement? | how to find out exactly from where print is being executed | 0 | 1.2 | 1 | 0 | 0 | 79 |
17,136,085 | 2013-06-16T17:51:00.000 | 0 | 0 | 0 | 0 | 0 | python,string,types,type-conversion | 1 | 17,136,094 | 0 | 4 | 0 | false | 0 | 0 | I'm not quite sure what your question is, but print automatically calls str on all of it's arguments ... So if you want the same output as print to be put into your file, then myfile.write(str(whatever)) will put the same text in myfile that print (x) would have put into the file (minus a trailing newline that print puts in there). | 1 | 1 | 0 | 0 | I am using python and XMLBuilder, a module I downloaded off the internet (pypi). It returns an object, that works like a string (I can do print(x)) but when I use file.write(x) it crashes and throws an error in the XMLBuilder module.
I am just wondering how I can convert the object it returns into a string?
I have confirmed that I am writing to the file correctly.
I have already tried for example x = y although, as I thought, it just creates a pointer, and also x=x+" " put I still get an error. It also returns an string like object with "\n".
Any help on the matter would be greatly appreciated. | Converting a string-like object into a string in python | 0 | 0 | 1 | 0 | 1 | 165 |
17,138,389 | 2013-06-16T22:38:00.000 | 1 | 1 | 0 | 0 | 0 | python,.net,ios | 0 | 17,138,453 | 0 | 4 | 0 | false | 0 | 1 | I learned to write iOs apps from the CS 193P iPhone Application Development course on iTunes U. It's fantastic and I highly recommend it if you are sure iOs is what you want to do. | 2 | 0 | 0 | 1 | I really would like to start getting into Objective C coding, specifically so I can write applications for iOS.
My coding background is that I have written C# .NET GUI Windows apps and PHP web scripts for years; I've also become a very good Python coder in the past year. I have written hundreds of useful command-line Python scripts, and also a few GUI apps using wxPython successfully. I also wrote VB6 GUI apps way back in the day, and of course, I cut my teeth on QuickBASIC in DOS. ;-)
I understand OOP concepts: I understand classes, methods, properties and the like. I use OOP a lot in Python, and obviously use it extensively in C#.
I haven't actually taken the time to really get good at C or C++, however I am able to write simple "test" programs to accomplish small tasks. The problem is that I understand the syntax just fine, but the APIs can be very different depending on platform, and accomplishing the same thing in C on Linux at the command line is totally different than accomplishing it in Windows in a GUI.
I've looked over a few books out there for iOS coding but they seem to assume little to no programming knowledge and quickly bore me, and I can't easily find the information I really need buried among all of the "here's what an object is" or "this is called a class and a method" stuff...
I also tried the Stanford lectures on iTunes U, but I found myself struggling with the MVC concepts and the idea of setting up different files for "implementation" and "header" and all of that...
Is there any resources that you guys can think of that would be good for me to get started with iOS?
It's also worth noting I have dabbled with PyObjC a little on Mac and therefore do understand a LITTLE about the NS foundation classes and such, and I've also looked at Apple's reference documentation and I'm sure that once I get the basics down I could put good use to it, but I still don't know how to actually get a functional iOS app that does something useful going. | Best intro to iOS for Python/PHP/C# Coder | 0 | 0.049958 | 1 | 0 | 0 | 166 |
17,138,389 | 2013-06-16T22:38:00.000 | 1 | 1 | 0 | 0 | 0 | python,.net,ios | 0 | 17,140,686 | 0 | 4 | 0 | false | 0 | 1 | I have gotten more from Erica Sadun's books than any of the others, personally. iOS apps use a lot of animation and graphics, by necessity, and her code examples are clean and concise. They aren't beginner's books but you sound as though you're not a beginning coder. They hit on a lot of topics it is hard to find much on.
If you're willing to work through the sample programs, I found iPad iOS 6 Development Essentials to be comprehensive (Neil Smith). However, it tends to focus on the visual IDE of xCode which I think is lousy and chose not to use at all; if you plan to use it, then that would be a good resource imo. Also, I got a book that covered Objective C only (Aaron Hillegass) which I thought was good. The iOS book from the same author was not good for me, because it depended on you working prior chapter examples to proceed to later chapters, which for me was a waste of time, so I bailed out of it quickly. I also got Pro Core Data (Privat and Warner) which I found to be of limited (actually, little) value for the same reason as the Hillegass iOS book -- the examples are too big and not to the point.
And, of course, Google. | 2 | 0 | 0 | 1 | I really would like to start getting into Objective C coding, specifically so I can write applications for iOS.
My coding background is that I have written C# .NET GUI Windows apps and PHP web scripts for years; I've also become a very good Python coder in the past year. I have written hundreds of useful command-line Python scripts, and also a few GUI apps using wxPython successfully. I also wrote VB6 GUI apps way back in the day, and of course, I cut my teeth on QuickBASIC in DOS. ;-)
I understand OOP concepts: I understand classes, methods, properties and the like. I use OOP a lot in Python, and obviously use it extensively in C#.
I haven't actually taken the time to really get good at C or C++, however I am able to write simple "test" programs to accomplish small tasks. The problem is that I understand the syntax just fine, but the APIs can be very different depending on platform, and accomplishing the same thing in C on Linux at the command line is totally different than accomplishing it in Windows in a GUI.
I've looked over a few books out there for iOS coding but they seem to assume little to no programming knowledge and quickly bore me, and I can't easily find the information I really need buried among all of the "here's what an object is" or "this is called a class and a method" stuff...
I also tried the Stanford lectures on iTunes U, but I found myself struggling with the MVC concepts and the idea of setting up different files for "implementation" and "header" and all of that...
Is there any resources that you guys can think of that would be good for me to get started with iOS?
It's also worth noting I have dabbled with PyObjC a little on Mac and therefore do understand a LITTLE about the NS foundation classes and such, and I've also looked at Apple's reference documentation and I'm sure that once I get the basics down I could put good use to it, but I still don't know how to actually get a functional iOS app that does something useful going. | Best intro to iOS for Python/PHP/C# Coder | 0 | 0.049958 | 1 | 0 | 0 | 166 |
17,140,080 | 2013-06-17T03:36:00.000 | 0 | 0 | 0 | 0 | 1 | python-2.7,pandas,xls | 1 | 17,141,432 | 0 | 1 | 0 | false | 0 | 0 | The problem you are facing is that your excel has a character that cannot be decoded to unicode. It was probably working before but maybe you edited this xls file somehow in Excel/Libre. You just need to find this character and either get rid of it or replace it with the one that is acceptable. | 1 | 0 | 1 | 0 | I am trying to export dataframe to .xls file using to_excel() method. But while execution it was throwing an error: "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 892: ordinal not in range(128)". Just few moments back it was working fine.
The code I used is:
:csv2.to_excel("C:\\Users\\shruthi.sundaresan\\Desktop\\csat1.xls",sheet_name='SAC_STORE_DATA',index=False).
csv2 is the dataframe. Why does this kind of error happens and how to avoid this is in the future? | Unable to export pandas dataframe into excel file | 0 | 0 | 1 | 0 | 0 | 474 |
17,141,979 | 2013-06-17T07:00:00.000 | 3 | 0 | 1 | 0 | 0 | python,floating-point,integer,rounding | 0 | 53,398,021 | 0 | 12 | 0 | false | 0 | 0 | Just make round(x-0.5) this will always return the next rounded down Integer value of your Float. You can also easily round up by do round(x+0.5) | 3 | 144 | 0 | 0 | I want to take a floating-point number and round it down to the nearest integer. However, if it's not a whole, I always want to round down the variable, regardless of how close it is to the next integer up. Is there a way to do this? | Round a floating-point number down to the nearest integer? | 0 | 0.049958 | 1 | 0 | 0 | 387,046 |
17,141,979 | 2013-06-17T07:00:00.000 | 1 | 0 | 1 | 0 | 0 | python,floating-point,integer,rounding | 0 | 27,183,740 | 0 | 12 | 0 | false | 0 | 0 | Don't know if you solved this, but I just stumble upon this question. If you want to get rid of decimal points, you could use int(x) and it will eliminate all decimal digits. Theres no need to use round(x). | 3 | 144 | 0 | 0 | I want to take a floating-point number and round it down to the nearest integer. However, if it's not a whole, I always want to round down the variable, regardless of how close it is to the next integer up. Is there a way to do this? | Round a floating-point number down to the nearest integer? | 0 | 0.016665 | 1 | 0 | 0 | 387,046 |
17,141,979 | 2013-06-17T07:00:00.000 | -6 | 0 | 1 | 0 | 0 | python,floating-point,integer,rounding | 0 | 52,981,095 | 0 | 12 | 0 | false | 0 | 0 | I used this code where you subtract 0.5 from the number and when you round it, it is the original number rounded down.
round(a-0.5) | 3 | 144 | 0 | 0 | I want to take a floating-point number and round it down to the nearest integer. However, if it's not a whole, I always want to round down the variable, regardless of how close it is to the next integer up. Is there a way to do this? | Round a floating-point number down to the nearest integer? | 0 | -1 | 1 | 0 | 0 | 387,046 |
17,159,576 | 2013-06-18T02:12:00.000 | 0 | 0 | 0 | 0 | 0 | python,django,ip | 0 | 17,159,679 | 0 | 4 | 0 | false | 1 | 0 | Not in any reliable way, or at least not in Django. The problem is that user IPs are usually dynamic, hence the address is changing every couple of days. Also some ISPs soon will start to use a single IP for big blocks of users (forgot what this is called) since they are running out of IPv4 IP addresses... In other words, all users from that ISP within a whole state or even country will have a single IP address.
So using the IP is not reliable. You could probably figure out the country or region of the user with reasonable accuracy however my recommendation is not to use the IP for anything except logging and permission purposes (e.g. blocking a spam IP).
If you want user locations, you can however use HTML5 location API which will have a much better shot of getting more accurate location since it can utilize other methods such us using a GPS sensor in a phone. | 1 | 0 | 0 | 0 | I have the user registration form made in django.
I want to know the city from which the user is registering.
Is there any way that i get the IP address of the user and then somehow get the city for that IP. using some API or something | Is there any simple way to store the user location while registering in database | 0 | 0 | 1 | 1 | 0 | 163 |
17,171,843 | 2013-06-18T14:42:00.000 | 1 | 1 | 0 | 0 | 0 | python,image,unit-testing,language-agnostic,integration-testing | 0 | 21,843,350 | 0 | 1 | 0 | true | 0 | 0 | Do you write your own library to convert images of you just use existing library? In the latter case you simply do not test it. Author has already tested it somehow. You just need to create an abstraction layer between your code and the image library you use. Then you can simply check if your code calls the library with desired parameters.
If you really insist on testing pictures then you need to make the transformation deterministic (and compare actual result with expected result) or you need to make comparison a bit less strict (from ignoring date fields to OCR recognizing the image).
Testing files is way easier (you do not need probability based OCR).Check if your program placed all files in expected location. | 1 | 1 | 0 | 0 | I'm writing an app that converts different images to JPG. It operates over a complex directory structure. There, a directory may include other directories, image files (JPG, GIF, PNG, TIFF), PDF files, RAR/ZIP archives, which in turn may include anything of the above. The app finds everything that can be converted to an image and places the resulting JPGs into a separate folder.
How do i write integration tests to test the conversion of images? Specifically, how should i fake the complex directory structure with all the files?
Currently i just store a sample directory structure, which i manually assembled out of various image, PDF and archive files, in a tests/ directory. In a setUp method i put this sample directory in place of the actual data and run the code. I had an idea to generate all these sample files myself (generate JPGs via Imagemagick, for example), but it proved hard.
How integration testing on images is usually done? | Integration testing and images | 0 | 1.2 | 1 | 0 | 0 | 271 |
17,183,100 | 2013-06-19T04:51:00.000 | 0 | 0 | 1 | 0 | 0 | python,automation | 0 | 17,183,172 | 0 | 1 | 0 | false | 0 | 0 | If the Info ur looking for is showed by IE you can obtain it by using xpath. If you want to make it automatic you could use selenium which works with webs as well.
If the program doesnt provide an api then its not possible to interact with the program unless you get the output from a browser or you may use programs like Sikuli and obtain the info for example by image processing | 1 | 0 | 0 | 0 | For example, if the program did not provide an API, and I need it to do something from Python script, is this possible to do so? Let's give an example:
I would like to copy the Product ID from the Internet Explorer's product ID everyday and new a text file named in this format: ddmmyyyy, and store on desktop. It is stupid, so, I would like to handle it to the machine to do it. (Yes, it is useless, but just say, it is an example.)
Creating a text file, with a string is easy to implement, but the REAL question is, how can I get the product ID from the program that don't have API provided.
So, the IE didn't provide the API for developer to access the Product ID, and I think the value can be shown on the screen or registry. Assume that I don't know the register location or they simply didn't store it in the registry, what I can get this product ID is manually, click, and check. For this process, is this possible to make it automatic? Thanks. | Is this possible to write a program to inter-act with existing software? | 1 | 0 | 1 | 0 | 0 | 46 |
17,184,244 | 2013-06-19T06:25:00.000 | 0 | 0 | 0 | 1 | 0 | python,celery,celery-task,celeryd | 0 | 61,655,803 | 0 | 5 | 0 | false | 0 | 0 | try to remove the .state file and if you are using a beat worker (celery worker -B) then remove the schedule file as well | 2 | 15 | 0 | 0 | I Have add some wrong task to a celery with redis broker
but now I want to remove the incorrect task and I can't find any way to do this
Is there some commands or some api to do this ? | how to remove task from celery with redis broker? | 0 | 0 | 1 | 0 | 0 | 22,805 |
17,184,244 | 2013-06-19T06:25:00.000 | 3 | 0 | 0 | 1 | 0 | python,celery,celery-task,celeryd | 0 | 61,655,939 | 0 | 5 | 0 | false | 0 | 0 | The simplest way is to use the celery control revoke [id1 [id2 [... [idN]]]] (do not forget to pass the -A project.application flag too). Where id1 to idN are task IDs. However, it is not guaranteed to succeed every time you run it, for valid reasons...
Sure Celery has API for it. Here is an example how to do it from a script: res = app.control.revoke(task_id, terminate=True)
In the example above app is an instance of the Celery application.
In some rare ocasions the control command above will not work, in which case you have to instruct Celery worker to kill the worker process: res = app.control.revoke(task_id, terminate=True, signal='SIGKILL') | 2 | 15 | 0 | 0 | I Have add some wrong task to a celery with redis broker
but now I want to remove the incorrect task and I can't find any way to do this
Is there some commands or some api to do this ? | how to remove task from celery with redis broker? | 0 | 0.119427 | 1 | 0 | 0 | 22,805 |
17,209,762 | 2013-06-20T09:13:00.000 | 0 | 0 | 0 | 0 | 0 | opencv,python-2.7 | 0 | 17,212,232 | 0 | 1 | 0 | false | 0 | 0 | Simplify edge A and B into a line equation (using only the few last pixels)
Get the line equations of the two lines (form y = mx + b)
Get the angle orientations of the two lines θ=atan|1/m|
Subtract the two angles from each other
Make sure to do the special case of infinite slope, and also do some simple math to get Final_Angle = (0;pi) | 1 | 1 | 1 | 0 | i need to find out contact angle between 2 edges in an image using open cv and python so can anybody suggest me how to find it? if not code please let me know algorithm for the same. | to measure Contact Angle between 2 edges in an image | 0 | 0 | 1 | 0 | 0 | 531 |
17,213,515 | 2013-06-20T12:20:00.000 | 0 | 0 | 0 | 0 | 0 | python,scrapy | 0 | 17,213,740 | 0 | 3 | 0 | true | 1 | 0 | Items in a database are have not a special order if you don't impose it. So you should add a timestamp to your table in the database, keep it up-to-date (mysql has a special flag to mark a field as auto-now) and use ORDER BY in your queries. | 2 | 2 | 0 | 0 | I am trying to put the items, scraped by my spider, in a mysql db via a mysql pipeline. Everything is working but i see some odd behaviour. I see that the filling of the database is not in the same order as the website itself. There is like a random order. Probably of the dictionary like list of the items scraped i guess.
My questions are:
how can i get the same order as the items of the website itself.
how can i reverse this order of question 1.
So items on website:
A
B
C
D
E
adding order in my sql:
E
D
C
B
A | Scrapy reversed item ordening for preparing in db | 0 | 1.2 | 1 | 1 | 0 | 201 |
17,213,515 | 2013-06-20T12:20:00.000 | 1 | 0 | 0 | 0 | 0 | python,scrapy | 0 | 17,221,923 | 0 | 3 | 0 | false | 1 | 0 | It's hard to say without the actual code, but in theory..
Scrapy is completely async, you cannot know the order of items that will be parsed and processed through the pipeline.
But, you can control the behavior by "marking" each item with priority key. Add a field priority to your Item class, in the parse_item method of your spider set the priority based on the position on a web page, then in your pipeline you can either write this priority field to the database (in order to have an ability to sort later), or gather all items in a class-wide list, and in close_spider method sort the list and bulk insert it into the database.
Hope that helps. | 2 | 2 | 0 | 0 | I am trying to put the items, scraped by my spider, in a mysql db via a mysql pipeline. Everything is working but i see some odd behaviour. I see that the filling of the database is not in the same order as the website itself. There is like a random order. Probably of the dictionary like list of the items scraped i guess.
My questions are:
how can i get the same order as the items of the website itself.
how can i reverse this order of question 1.
So items on website:
A
B
C
D
E
adding order in my sql:
E
D
C
B
A | Scrapy reversed item ordening for preparing in db | 0 | 0.066568 | 1 | 1 | 0 | 201 |
17,218,051 | 2013-06-20T15:44:00.000 | 0 | 0 | 0 | 0 | 0 | python,indexing,scipy,rotatetransform,correspondence | 0 | 18,653,827 | 0 | 1 | 0 | true | 0 | 0 | After some time of debugging, I realized that depending on the angle - typically under and over n*45 degrees - scipy adds a row and a column to the output image.
a simple test of the angle adding one to the indices solved my problem.
I hope this can help the future reader of this topic. | 1 | 1 | 1 | 0 | I hope this hasn't already been answered but I haven't found this anywhere.
My problem is quite simple : I'm trying to compute an oblic profile of an image using scipy.
One great way to do it is to :
locate the segment along which I want my profile by giving the beginning and the end of my segment,
extract the minimal image containing the segment,
compute the angle from which my image should be rotated to get the desired profile along a nice raw,
extract said raw.
That's the theory.
I'm stuck right now on (4), because my profile should fall in raw number array.shape[0]/2, but rotate seems to add sometimes lines of zeros below the data and columns on the left. The correct raw number can thus be shifted...
Has anyone any idea how to get the right raw number, for example using the correspondence matrix used by scipy ?
Thanks. | finding corresponding pixels before and after scipy.ndimage.interpolate.rotate | 0 | 1.2 | 1 | 0 | 0 | 131 |
17,218,183 | 2013-06-20T15:49:00.000 | 0 | 1 | 0 | 0 | 0 | html,windows,python-2.7,command,command-prompt | 0 | 17,218,531 | 0 | 1 | 0 | false | 1 | 0 | I believe the correct answer is you cannot. Feel free to let me know otherwise if you find out a way to do it. | 1 | 1 | 0 | 0 | I would like to run the command python abc.py in the windows command prompt when the button on html page is clicked.The python file is located at C:/abc.py> I would like to know how to code the html page to do this process.Thank you for the help. | Running the Command on Windows Command prompt using HTML button | 0 | 0 | 1 | 0 | 0 | 6,859 |
17,241,004 | 2013-06-21T17:25:00.000 | 75 | 0 | 0 | 0 | 0 | python,pandas | 0 | 17,241,104 | 0 | 8 | 0 | false | 0 | 0 | You can use df.index to access the index object and then get the values in a list using df.index.tolist(). Similarly, you can use df['col'].tolist() for Series. | 1 | 289 | 1 | 0 | Do you know how to get the index or column of a DataFrame as a NumPy array or python list? | How do I convert a pandas Series or index to a Numpy array? | 0 | 1 | 1 | 0 | 0 | 558,431 |
17,243,749 | 2013-06-21T20:24:00.000 | 0 | 0 | 1 | 1 | 0 | python,wxpython,coderunner | 0 | 17,243,806 | 0 | 4 | 0 | false | 0 | 0 | CodeRunner should work fine with Python 2.7, but you'll have to make sure that a compatible version of wxPython is installed in your site-packages.
To verify that wxPython works correctly, you should start up a python instance in your terminal and run some test code (i.e., import the library and run some of the functions). If this works correctly, then CodeRunner should be able to run that code accordingly (because it uses the same process to run your apps). | 1 | 1 | 0 | 0 | im using a program called CodeRunner to program Python code. I want to install wxpython but how do I figure out what version python im using? when i do python -v in Terminal it says im on 2.7, but is that the same version that CodeRunner is using? Is there a way for me to find out? | Python programming with CodeRunner | 1 | 0 | 1 | 0 | 0 | 1,192 |
17,263,517 | 2013-06-23T17:45:00.000 | -2 | 0 | 0 | 0 | 0 | python,python-2.7,pexpect | 0 | 17,265,035 | 0 | 1 | 0 | false | 0 | 0 | pexpect allows you to specify a list of prompts to match against, so it caters explicitly to your use case. Consult the docstring of pexpect.expect(). | 1 | 0 | 0 | 0 | Script-1 can be run from a shell and will ask the user for 3 prompts, A, B, and C in that order. A or B will appear to the user, and C will always will appear. In other words, when Script-1 is run, the user will be prompted by question A or B. Once answered, the question C will always be prompted last.
I want to write Script-2, which will use logic to answer prompts A, B, and C automatically in Python. Pexpect seems perfect for this, however, how would one use pexpect when there are two different prompts- A or B- that could be presented to it?
Thank you. | Pexpect Multiple, Different Prompts | 1 | -0.379949 | 1 | 0 | 0 | 704 |
17,270,293 | 2013-06-24T07:39:00.000 | 1 | 0 | 1 | 0 | 0 | python,numpy,naming-conventions | 0 | 17,270,654 | 0 | 2 | 0 | false | 0 | 0 | numpy arrays and lists should occupy similar syntactic roles in your code and as such I wouldn't try to distinguish between them by naming conventions. Since everything in python is an object the usual naming conventions are there not to help distinguish type so much as usage. Data, whether represented in a list or a numpy.ndarray has the same usage.
I agree that it's awkward that eg. + means different things for lists and arrays. I implicitly deal with this by never putting anything like numerical data in a list but rather always in an array. That way I know if I want to concatenate blocks of data I should be using numpy.hstack. That said, there are definitely cases where I want to build up a list through concatenation and turn it into a numpy array when I'm done. In those cases the code block is usually short enough that it's clear what's going on. Some comments in the code never hurt. | 2 | 2 | 1 | 0 | PEP8 has naming conventions for e.g. functions (lowercase), classes (CamelCase) and constants (uppercase).
It seems to me that distinguishing between numpy arrays and built-ins such as lists is probably more important as the same operators such as "+" actually mean something totally different.
Does anyone have any naming conventions to help with this? | how do you distinguish numpy arrays from Python's built-in objects | 0 | 0.099668 | 1 | 0 | 0 | 415 |
17,270,293 | 2013-06-24T07:39:00.000 | 2 | 0 | 1 | 0 | 0 | python,numpy,naming-conventions | 0 | 17,270,547 | 0 | 2 | 0 | false | 0 | 0 | You may use a prefix np_ for numpy arrays, thus distinguishing them from other variables. | 2 | 2 | 1 | 0 | PEP8 has naming conventions for e.g. functions (lowercase), classes (CamelCase) and constants (uppercase).
It seems to me that distinguishing between numpy arrays and built-ins such as lists is probably more important as the same operators such as "+" actually mean something totally different.
Does anyone have any naming conventions to help with this? | how do you distinguish numpy arrays from Python's built-in objects | 0 | 0.197375 | 1 | 0 | 0 | 415 |
17,303,998 | 2013-06-25T17:41:00.000 | 0 | 0 | 0 | 0 | 0 | python,python-2.7,audio,tkinter | 0 | 17,304,375 | 0 | 1 | 0 | false | 0 | 1 | Depending on the sound file format, if it is a .wav then you can probably just read it in to a numpy array then plot it, otherwise you are going to have to parse the file format first. | 1 | 0 | 0 | 0 | Does anyone know how to display the waveform of a sound file in a Tkinter window (Python)? | Plot wavewform in Tkinter (Python) | 0 | 0 | 1 | 0 | 0 | 257 |
17,324,670 | 2013-06-26T15:45:00.000 | 1 | 0 | 0 | 0 | 0 | python,scroll,qtablewidget | 0 | 21,234,521 | 0 | 1 | 0 | true | 0 | 1 | This is how I've solved it:
While populating table cells with text, if my text have over 1000 lines (text.count("\n")) I put it in QTextEdit() and then set it with setCellWidget. Reason I didn't put them all in QTextEdit()s is that Windows can show limited number of GUI elements (<20000) and, as I said, I have 10 columns x up to 100000 rows | 1 | 1 | 0 | 0 | Problem: I have QTableWidget cells populated with text (10 columns). I found out that no matter how much rows I have (10 or 100000) scrolling over rows with heigth ~ over 3000 is very slow and not smooth enough (I've used table.verticalHeader().sectionSize(i) to find out heigth of every row).
What I've tried to do: So I've tried to set height of those rows using table.setRowHeight(i,3000), but still when I scroll over those rows I get delay of 1-5 secunds. Also in that case I need to manualy resize height of row in order to see all text in that row (because it was cuted), and that is slow too.
Questions: I need to do table.resizeRowsToContent() for all smaller rows, so I think solution would be to set limit for height of every row in table. There is setMinimumSectionSize() method but I can't find any for max size, so how can I do it? Is it possible to have scrollbars inside every cell where height is >3000 so I can scroll through text inside that cell? Maybe that will speed up scrolling throug table?
Any help would be appreciated | Qtablewidget does not scroll smoothly | 1 | 1.2 | 1 | 0 | 0 | 913 |
17,325,299 | 2013-06-26T16:14:00.000 | 3 | 1 | 0 | 0 | 0 | python-3.x,easygui | 0 | 32,529,223 | 0 | 2 | 0 | false | 0 | 0 | In addition to what @Benjooster answered previously:
Apparently sometimes the font settings are not in easygui.py, but rather in
Python27\Lib\site-packages\easygui\boxes\state.py | 1 | 4 | 0 | 0 | How can you change the font settings for the input boxes and message text in EasyGUI? I know you have to edit a file somewhere, but that's about it. Exactly how to do it and what to edit would be appreciated.
Thanks in advance. | Python EasyGUI module: how to change the font | 0 | 0.291313 | 1 | 0 | 0 | 6,064 |
17,341,034 | 2013-06-27T10:44:00.000 | 0 | 0 | 0 | 0 | 0 | python,eclipse,openerp | 0 | 17,343,886 | 0 | 1 | 0 | false | 1 | 0 | Add a many2many field relating to ir.attachments.Check sent by email button in invoice. It opens a wizard which we can add many attachments and also email body
for example, add a many2many field relating to ir.attachement and in xml line of the field, specify widget="many2many_binary"
I dont know whether it is possible to show images as many2many | 1 | 0 | 0 | 0 | Hi I have created a custom openerp module having several fields . I also have a field for attaching image file . But now I need to have a field that should have the ability to attach multiple image fields. How Can I be able to do this?
Hopes for suggestion | how to add field for multiple image attachment in openerp module | 0 | 0 | 1 | 0 | 0 | 1,243 |
17,344,335 | 2013-06-27T13:20:00.000 | 0 | 0 | 0 | 0 | 0 | java,python,excel,passwords,xls | 0 | 17,344,366 | 0 | 1 | 0 | false | 0 | 0 | If you search there are a number of applications that you can download that will unblock the workbook. | 1 | 0 | 0 | 0 | So I have a password protected XLS file which i've forgotten the password for...I'm aware it's a date within a certain range so i'm trying to write a brute forcer to try various dates of the year. However, I can't find how to use python/java to enter the password for the file. It's protected such that I can't open the xls file unless I have it and it has some very important information on there (so important I kept the password in a safe place that I now can't find lol).
I'm using fedora. Are there any possible suggestions? Thankyou. | How to enter password in XLS files with python? | 0 | 0 | 1 | 1 | 0 | 268 |
17,351,154 | 2013-06-27T18:58:00.000 | 1 | 0 | 1 | 1 | 1 | python,eclipse,pydev | 1 | 20,921,210 | 0 | 1 | 0 | false | 0 | 0 | i had this problem too, it turns out i had used "&" in the path of my eclipse folder. i renamed the folder using just normal characters, and pydev installed fine.
i believe the path statement for the location of the eclipse folder has to be strict unicode without any other characters | 1 | 0 | 0 | 0 | I installed Python 32bit on W7. I then "installed" Eclipse 32bit.
I successfully added PyDev to Eclipse. I then go to PyDev->Interpreter-Python, and click on "new", browse to C:\Python27\python.exe, click ok, and get the following error:
Error getting info on interpreter.
Common reasons include
-Using an unsupported version
-Specifying and invalid interpreter
Reasons:
See error log for details.
Log:
org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 23; The reference to entity "g" must end with the ';' delimiter.
Any ideas how to fix this?
Thanks! | Failing to define the Python interpeter for PyDev in Eclipse | 0 | 0.197375 | 1 | 0 | 0 | 288 |
Subsets and Splits