Q_Id
int64 337
49.3M
| CreationDate
stringlengths 23
23
| Users Score
int64 -42
1.15k
| Other
int64 0
1
| Python Basics and Environment
int64 0
1
| System Administration and DevOps
int64 0
1
| Tags
stringlengths 6
105
| A_Id
int64 518
72.5M
| AnswerCount
int64 1
64
| is_accepted
bool 2
classes | Web Development
int64 0
1
| GUI and Desktop Applications
int64 0
1
| Answer
stringlengths 6
11.6k
| Available Count
int64 1
31
| Q_Score
int64 0
6.79k
| Data Science and Machine Learning
int64 0
1
| Question
stringlengths 15
29k
| Title
stringlengths 11
150
| Score
float64 -1
1.2
| Database and SQL
int64 0
1
| Networking and APIs
int64 0
1
| ViewCount
int64 8
6.81M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
28,100,993 | 2015-01-23T00:13:00.000 | 0 | 0 | 1 | 0 | python | 28,101,077 | 3 | false | 0 | 0 | Don't took it as pure English, r+ means read extended actually, Python!=English. All of the languages has basic rules, and @John Kugelman mentioned, Python stuck with old. | 1 | 22 | 0 | In Python, when opening a file, we use 'r' to indicate read-only and 'w' write-only. Then we use 'r+' to mean "read and write".
Why not use 'rw'? Doesn't 'rw' looks more natural than 'r+'?
Edit on Jan. 25th:
Oh.. I guess my question looks a little confusing.. What I was trying to ask is: 'r' is the first letter of 'read' and 'w' the first letter of 'write' so 'r' and 'w' look natural to map to 'read' and 'write'. However, when it comes to 'read and write', Python uses 'r+' instead of 'rw'.
So the question is actually about the naming rationale instead of the behavior differences between them. | In Python, why is 'r+' but not 'rw' used to mean "read & write"? | 0 | 0 | 0 | 11,276 |
28,101,097 | 2015-01-23T00:25:00.000 | 2 | 0 | 1 | 0 | python | 28,101,159 | 2 | false | 0 | 0 | The two expressions are equivalent, but the first one is more idiomatic, so it's preferred. | 2 | 0 | 0 | In Python 3, is there a difference between using these two expressions?
item not in list
vs.
not item in list | What's the proper way of checking non-inclusion in Python | 0.197375 | 0 | 0 | 47 |
28,101,097 | 2015-01-23T00:25:00.000 | 0 | 0 | 1 | 0 | python | 28,101,158 | 2 | false | 0 | 0 | item not in list is being mentioned in the Python documentation and not item in list is not.
Which means that it is better to use item not in list. | 2 | 0 | 0 | In Python 3, is there a difference between using these two expressions?
item not in list
vs.
not item in list | What's the proper way of checking non-inclusion in Python | 0 | 0 | 0 | 47 |
28,101,995 | 2015-01-23T02:12:00.000 | 2 | 0 | 0 | 1 | python,bash,hadoop,mapreduce,apache-spark | 28,112,455 | 1 | false | 0 | 0 | The main idea why Hadoop Streaming is considered to be slow is that for both mapper and reducer you have to pass arguments via stdin, which means you have to serialize them as a text, and to get the output of both mapper and reducer you have to deserialize them from the text back to Java structures, which usually consumes much time.
If you have a third party compiled application that is capable of reading the input data from stdin and passing data to stdout you don't have much choice but to run it in Hadoop Streaming or in Spark pipe. But of course the native mapreduce application application would be faster as it would eliminate the need for data serialization/deserialization on passing it to the application
But if your application just accepts the filename and reads the file by itself (from NFS, for instance), it would be the same speed as a native one, but of course you should consider that this type of use is not the case neither for Hadoop nor for Spark - these frameworks were developed to process the data with APIs they provide | 1 | 0 | 0 | I have heard from several articles that Hadoop streaming with bash is significantly slower than a compiled code or python. Is this only true for sort commands and the like? My script needs to
-copy file to node
-on node execute a commercial program with file as argument
-pass output back to folder
My intuition is telling me that this should be a similar speed to the compiled versions. Would it be? | Hadoop streaming with Bash - how slow? | 0.379949 | 0 | 0 | 481 |
28,103,374 | 2015-01-23T05:06:00.000 | 0 | 0 | 0 | 0 | python,django,django-forms,django-templates,django-views | 28,103,925 | 1 | false | 1 | 0 | Probably the best way to do that is to use the session:
When the password_change view is valid and before redirecting to the password_change_done view, just set a password_changed session attribute to True, something like this:
request.session['password_changed'] = True
After that, in your password_change_done view, check if password_changed is True and only then actually display the view, something like:
if request.session.get('password_changed'):
# render password_change_done view
else:
# redirect to the password_change view | 1 | 0 | 0 | I require the password_change_done url to be visible only when the password_change view redirects to it (on successful change of password). Otherwise on going to the password_change_done view, it must redirect to the password_change view
How can this be done? | Django password_change_done viewable only on redirect from password_change view (on succesful password change) | 0 | 0 | 0 | 100 |
28,105,364 | 2015-01-23T07:56:00.000 | 0 | 0 | 0 | 1 | python,django,celerybeat | 51,928,073 | 2 | false | 0 | 0 | celery -A your-project beat --detach -l info -f beat.log | 1 | 3 | 0 | I know there is a command for celeryd to run as daemon, i.e; celeryd_detach. But how can I run celery-beat as daemon using any command? Please help me in this.
TIA | How to run celery beat as daemon? | 0 | 0 | 0 | 4,649 |
28,106,854 | 2015-01-23T09:36:00.000 | 2 | 0 | 0 | 0 | python,django,function,session | 28,107,498 | 1 | true | 1 | 0 | You can't.
This question betrays a fundamental misunderstanding of how both sessions and web applications work. Web code is stateless; there is nothing "running" for any user in between the requests that user makes. If a user doesn't make any requests for longer than the session timeout, the only time the server code knows about it is the next time they actually do make a request: at which point the code will compare the last request time with the current time and either treat the session as valid or expired. If the user goes away and never comes back, there is simply no way the server will ever know. | 1 | 0 | 0 | So i'm using the request.session.set_expiry(NUMBER_OF_SECONDS) in order to check if the user of my webpage has been inactive for a number of seconds and clossing the session when it happens. The problem is that i want to call a function for doing some things jsut before the session expires and i don't know how can I do that.
Thanks in advance! | Django: calling a function before session expires | 1.2 | 0 | 0 | 312 |
28,108,106 | 2015-01-23T10:43:00.000 | 2 | 0 | 1 | 0 | python,64-bit,32-bit,anaconda,pythonxy | 28,198,803 | 1 | true | 0 | 0 | You'll need to reinstall everything for the 64-bit Python, but note that Anaconda and conda may already come with everything that you need. | 1 | 2 | 0 | I have some doubts about how to do that, I hope anybody can point me in the correct direction.
My current situation is that I am working with the python package Python(x,y) 32 bits in a Windows machine with 64 bits. And, as many of you know, I am having some problems with the Memory error.
So that I am thinking about changing to 64-bits, let's say with Anaconda for example.
My concern is about what can happen with all the previous job done with python 2.7 with 32 bits. Will it work with Anaconda 64?.
And, if finally I change to Anaconda 64, I really don't think I can still use QtDesigner anymore, if I am not wrong, it only works with python 32, right?.
Sorry If any question sound very basic, I really do not have any idea about that. | from python 32 bits to python 64 bits | 1.2 | 0 | 0 | 5,321 |
28,109,268 | 2015-01-23T11:49:00.000 | 0 | 0 | 1 | 0 | python,windows,numpy | 47,223,192 | 4 | false | 0 | 0 | Wasted a lot of time trying to install on Windows from various binaries and installers, which all seemed to install a broken version, until I found that this worked: navigate to the python install directory and do python .\site-packages\pip install numpy | 1 | 5 | 1 | I am trying to install numpy for python 2.7, I've downloaded the zip, unzipped it and was expecting a Windows download file (.exe), but there isn't one.
Which of these files do I use to install it?
I tried running the setup.py file but don't seem to be getting anywhere.
Thanks!!! | How do I install Numpy for Python 2.7 on Windows? | 0 | 0 | 0 | 21,104 |
28,109,630 | 2015-01-23T12:10:00.000 | 0 | 0 | 0 | 0 | python,browser,client,server | 28,124,355 | 2 | false | 0 | 0 | Answering my question for future reference or other people with similar requests.
All of the requirements for this can be found in the standard module BaseHTTPServer | 1 | 1 | 0 | I have written a python server that does a task depending on the input given by the user through a client. Unfortunately, this requires the user to use the terminal.
I'd like the user to use a browser instead to send the data to the server. How would I go on about this?
Does anyone here have suggestions? Perhaps even an example?
Thank you all in advance, | Python - Server and browser-client | 0 | 0 | 1 | 231 |
28,110,884 | 2015-01-23T13:21:00.000 | 4 | 0 | 1 | 0 | python,operator-overloading,overloading | 28,111,055 | 1 | false | 0 | 0 | No. The only operator overloading that is allowed in Python is changing the runtime semantics of pre-existing operators. The syntax <MyObj1 | MyObj2 > would involve either making < and > into unary operators (one prefix, one postfix) or making them both into a single "circumfix" operator. As they are currently both binary infix operators, such a change cannot be done. | 1 | 1 | 0 | Pretty odd question but is it possible to overload the meaning of certain bracket types e.g. <, >, [, ] and | in Python. For instance if I have some object instances MyObj1 and MyObj2 could I design something whereby <MyObj1 | MyObj2 > was understood as either a method call in MyObj1?
I think it probably can't/shouldn't be done but I thought I'd ask! | Overload angle brackets in Python | 0.664037 | 0 | 0 | 1,245 |
28,114,303 | 2015-01-23T16:26:00.000 | 0 | 0 | 1 | 1 | python | 28,114,840 | 1 | false | 0 | 0 | You can do all necessary imports before os.chroot. | 1 | 0 | 0 | I am writing some Python script and I would like to use os.chroot to execute some code under chroot environment. The problem is after calling os.chroot, paths in sys.path lie outside of the chroot jail, so import won't work. What's the best way to do it? | Python import packages under chroot environment | 0 | 0 | 0 | 133 |
28,115,111 | 2015-01-23T17:10:00.000 | 0 | 0 | 0 | 0 | django,python-2.7 | 28,115,962 | 1 | false | 1 | 0 | Found the answer:
req = urllib2.Request(url=your_url, data=your_data)
req.get_method = lambda: 'PUT' | 1 | 0 | 0 | In my Django app I need to send an HTTP PUT request to a url.
What is the proper syntax for that? | How to send an HTTP PUT request using urllib2 or requests | 0 | 0 | 1 | 831 |
28,121,148 | 2015-01-24T00:59:00.000 | 9 | 0 | 0 | 1 | python,macos | 28,121,167 | 2 | false | 0 | 0 | Solution is to run commands below:
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++ | 1 | 4 | 0 | You may have following issue while compiling python packages on Mac:
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/misaka.c -o build/temp.macosx-10.9-intel-2.7/src/misaka.o
cc: error: unrecognized command line option '-Wshorten-64-to-32'
error: command 'cc' failed with exit status 1 | How to fix "cc: error: unrecognized command line option '-Wshorten-64-to-32'" issue on Mac | 1 | 0 | 0 | 5,118 |
28,121,229 | 2015-01-24T01:10:00.000 | 0 | 0 | 0 | 0 | macos,sqlalchemy,pycharm,osx-yosemite,python-2.x | 28,123,162 | 1 | true | 0 | 0 | Go into Settings -> Project Settings -> Project Interpreter.
Then press configure interpreter, and navigate to the "Paths" tab.
Press the + button in the Paths area. You can put the path to the module you'd like it to recognize. | 1 | 0 | 0 | i installed PyCharm 4 on my Mac Yosemite, then installed SQLAlchemy through easy_install with console, also I have already official python 2.7.9 IDLE. I tried to import SQLAlchemy module in official IDLE and it works, but in PyCharm 4 IDE it doesn't. How can i fix this error?
Traceback (most recent call last): File "/Users/artyom/PycharmProjects/untitled/hella.py", line 1, in import sqlalchemy ImportError: No module named sqlalchemy | SQLAlchemy with Pycharm 4 | 1.2 | 1 | 0 | 664 |
28,121,876 | 2015-01-24T03:07:00.000 | 7 | 0 | 0 | 0 | python,qt,pyqt,qtabwidget | 28,122,425 | 1 | true | 0 | 1 | When a new tab is selected currentChanged(int index) signal of the QTabWidget is emitted. Just connect that signal to some slot and check the index of the newly selected tab which is passed as argument. | 1 | 8 | 0 | I am using PyQt5 to make the user interface. Now I have set up a tab widget, and I want to trigger the event at such a time when a specific tab is selected. In other words, for example, I have tab A and tab B, and I want to execute the function every time user is switching from tab A to tab B. | How to connect event when tab widget is selected? | 1.2 | 0 | 0 | 5,574 |
28,124,450 | 2015-01-24T10:20:00.000 | 2 | 0 | 0 | 0 | python,python-2.7 | 28,124,506 | 1 | true | 0 | 0 | What you could do is choose a min/max interval of how long you want to wait. Keep a note of how many requests have been made in the last 60 minutes and if you're still below the quota, download a document and wait for rand(min, max). This is not very fancy and doesn't distribute the wait times across the whole 60 minutes interval, but it's easy to implement.
Another way would be to randomly choose 100 numbers between 0 and 60*60. These are the seconds on which you make requests. Sort them and as you progress through the array, each time you wait for next - current seconds. (or even use the scheduler module to simplify it a bit) | 1 | 0 | 0 | I am using an API that returns me articles in my language in determined categories. This API limits me in 100 calls for each interval of 60 minutes.
I don't want to make 100 calls straight away and make my script wait until 60 minutes has passed.
I could then shoot an API call every 36 seconds, but I also don't want the API calls to be shot evenly.
What is a feasible way to make my script make 100 API calls at random intervals of time, as long as the 100 fits in 60 minutes?
I thought of making a function that would generate 100 timestamps in this 60 minutes interval, and then at the right time of each timestamp, it would shoot an API call, but I think that'd be overkill, and I'm not sure how I could do that either. | How can I distribute 100 API calls randomly in a 60 minutes time interval? | 1.2 | 0 | 1 | 303 |
28,125,037 | 2015-01-24T11:32:00.000 | 0 | 0 | 0 | 0 | python,django,django-cms | 29,008,788 | 3 | false | 1 | 0 | One more hint: static placeholders are good for this purposes. | 1 | 3 | 0 | I have a few placeholders in my DjangoCMS template (par example, header, contetent and footer). I want to automatically populate any newly-created pages with default items: header placeholder with header plugin and footer placeholder with footer plugin.
How can it be done? | DjangoCMS: how to auto-add default plugins in placeholders | 0 | 0 | 0 | 790 |
28,127,310 | 2015-01-24T16:00:00.000 | 2 | 0 | 1 | 0 | python,python-3.x | 28,127,456 | 3 | false | 0 | 0 | On windows, you can quit the interpreter with CTRL-z and on linux/mac you can quit with CTRL-D. If you type exit, it will tell you exactly what to do.
If you are not running interactively (i.e. by running python your_script.py) the code will just end when it's reached the bottom of the file.
If you actually do need to interact with the interpreter while you are running your code, you can use input (or raw_input, depending on the python version) for fetching information from simple prompts, or the code module for more complex interactions. | 1 | 2 | 0 | I have made a number guessing game and once you have guessed the number it will say well done but idle stays open, how do I get it to close? | how do I get my program to close once finished in python | 0.132549 | 0 | 0 | 4,071 |
28,127,730 | 2015-01-24T16:40:00.000 | 3 | 0 | 1 | 0 | python,pygame,pip,python-3.4 | 28,127,786 | 9 | false | 0 | 1 | 14 y/o? Good for you! You can put the file into your python/scripts folder and run pip install *file* (where *file* is your filename). | 1 | 9 | 0 | So I have this little problem. When I try to install PyGame for Python 3.4 I download a .whl (wheel?) file and don't know how to use it. Some guys told me something about pip but don't know how to use/install it. | How to install PyGame on Python 3.4? | 0.066568 | 0 | 0 | 64,844 |
28,131,654 | 2015-01-24T23:55:00.000 | 1 | 0 | 1 | 1 | python,bash,package | 28,131,853 | 1 | true | 0 | 0 | assuming ubuntu is somewhat like debian.
/etc/profile.d is probably the best way.
Don't edit any files just drop a file into profile.d that checks for bash and that your package is installed and then does whatever it needs. | 1 | 0 | 0 | I'm planning to make a program which should edit the users bashrc.
In the case of python library, I'd like to add a binary to /bin/ automatically. When it is executed, then it should add a function and call it every time when a user is loggd in to bash, so I definitely should change bashrc.
In the case of ubuntu package, it should do same job as desribed above.
However, adding some function to bashrc seems not a proper solution because when it is removed, it should edit bashrc again but if there is any small change of added codes removal of package might make some dummy codes on bashrc.
Is there any neet solution for this? | Proper way to change bashrc when making a ubuntu package or python package | 1.2 | 0 | 0 | 57 |
28,132,156 | 2015-01-25T01:13:00.000 | 0 | 0 | 0 | 0 | python,linux,arduino,pygame,raspberry-pi | 28,132,200 | 1 | true | 0 | 1 | (x + 1.0) / 2.0 where x is whatever you get from the controller should give you a range of 0..1 (the + 1.0 is to get you in the range 0..2) | 1 | 0 | 0 | I am using Pygame 1.9.2 with Python 3.4 to create a control program for a robot. The controller is a new Xbox One controller connected via USB which is working fine with pygame. The problem is that the trigger buttons are considered Axes which give values from -1 to 1 depending on how hard you press. Is there a way to change this to a range from 0 to 1 or any other range that does not include negative numbers?
Thanks | How can I set the range for Xbox One controller Triggers using Pygame? | 1.2 | 0 | 0 | 1,152 |
28,133,177 | 2015-01-25T04:18:00.000 | 3 | 0 | 0 | 0 | python,django | 28,133,201 | 1 | true | 1 | 0 | Properly written django project will work from any directory. The only thing you need to change is the database settings and, may be, some paths in settings.py. | 1 | 0 | 0 | Is it possible to duplicate an entire Django project and rename it?
For example, let's say Client1 asks me for a Django project. I would name the entire project Client1. Client2 now comes and asks for the exact same file. Can I simply copy and paste Client1's project and rename it to Client2, or do I need to rename a few other things?
Thank you in advance for the clarification! | Duplicating an entire Django project | 1.2 | 0 | 0 | 1,706 |
28,135,050 | 2015-01-25T09:40:00.000 | 0 | 0 | 0 | 0 | python,html,django | 28,135,065 | 2 | false | 1 | 0 | Yes. You need to use Context Processor. Google "django context procoessor" it'll come up with many results. | 1 | 0 | 0 | I have a base html file (for which code shouldn't be necessary) that requires some tags in the menu to be filled with id numbers (which are dynamic, and can't be hard coded). It seems to me that writing code to populate the tags for each view violates the DRY principle, and as such there should be some way to provide variables to a base html document. How does one do this, if it's possible? | How to fill data in a base html file Django | 0 | 0 | 0 | 77 |
28,136,063 | 2015-01-25T11:52:00.000 | 1 | 0 | 0 | 0 | ajax,python-3.x,cookies,xmlhttprequest,bottle | 28,137,747 | 2 | false | 1 | 0 | I tried to set_cookies('test', 123, secret='mysecret') under AJAX request, it worked, but still couldn't find previous cookies.
Then I remarked that my previous cookies, called cook1 and cook2, written under 'normal' http request, if they had same domain, had different 'path' (under Chrome ressource explorer). They were set under path '/XXX/dev' and my AJAX request was just under path '/XXX'
So I modified my AJAX request from /XXX/do_stuff to point to '/XXX/dev/do_stuff', and then, surprise ! cook1 and cook2 could be read by my AJAX request.
Not sure if it's a Bottle bug or if such behaviour is designed on purpose (in this case, if someone can explain to me why...), but at least I have my solution. | 1 | 1 | 0 | I use bottle set/get cookie mecanism to track my user_id (with 'secret' param when calling set/get_cookie()
During normal http(s) request everything is fine but when making a xhr request (same domain)user_id = request.get_cookie('user_id', secret='mysecret') returns None.
When checking on client browser, cookie and key/value are still available.
How to deal with it ?
(I've always been told that xhr requests are http requests, so from same domain, cookies should be shared, no ? is problem arrising from Bottle 'secret' handling ?) | Bottle, how to get_cookie during AJAX request (same domain) | 0.099668 | 0 | 0 | 167 |
28,139,507 | 2015-01-25T17:50:00.000 | 0 | 0 | 1 | 0 | ipython | 34,588,036 | 2 | false | 0 | 0 | You can output your history with the commands
%history -f filename
history with lines and sessions
%history -g -f filename | 1 | 3 | 0 | I use vim with a couple of plugins as a python ide. Along with an open vim session, I run an ipython session in a split console. I've found their combination is a great productivity tool for programming data analysis scripts.
What I'm missing is a way to show all current session history in a side panel, so that I could easily do some copy-pasting from there to the vim session to create a script. Something similar to 'tail -f' would do, if only I knew where ipython stores the current session history.
I already know:
ipython has '%history' and 'hist' commands, BUT I'm looking for a way to display the history in a panel outside of the ipython session.
history is stored in a sqlite file under .ipython/(profile), BUT I don't know how to access that file.
I hope I've been clear about my question.
Thanks in advance for all your help. | Where does ipython store the current session history? | 0 | 0 | 0 | 851 |
28,142,420 | 2015-01-25T22:38:00.000 | 6 | 0 | 0 | 0 | python,excel,pandas | 28,254,411 | 6 | false | 0 | 0 | I'm 90% confident the answer to "can pandas do this" is no. Posting a negative is tough, because there always might be something clever that I've missed, but here's a case:
Possible interface engines are xlrd/xlwt/xlutils, openpyxl, and xlsxwriter. None will work for your purposes, as xlrd/wt don't support all formulae, xlsxwriter can't modify existing xlsx files, and openpyxl loses images and charts.
Since I often need to do this, I've taken to only writing simple output to a separate file and then calling the win32api directly to copy the data between the workbooks while preserving all of my colleague's shiny figures. It's annoying, because it means I have to do it under Windows instead of *nix, but it works.
If you're working under Windows, you could do something similar. (I wonder if it makes sense to add a native insert option using this approach to help people in this situation, or if we should simply post a recipe.)
P.S.: This very problem has annoyed me enough from time to time that I've thought of learning enough of the modern Excel format to add support for this to one of the libraries.
P.P.S.: But since ignoring things you're not handling and returning them unmodified seems easy enough, the fact that no one seems to support it makes me think there are some headaches, and where Redmond's involved I'm willing to believe it. @john-machin would know the details, if he's about.. | 1 | 26 | 0 | Many spreadsheets have formulas and formatting that Python tools for reading and writing Excel files cannot faithfully reproduce. That means that any file I want to create programmatically must be something I basically create from scratch, and then other Excel files (with the aforementioned sophistication) have to refer to that file (which creates a variety of other dependency issues).
My understanding of Excel file 'tabs' is that they're actually just a collection of XML files. Well, is it possible to use pandas (or one of the underlying read/write engines such as xlsxwriter or openpyxl to modify just one of the tabs, leaving other tabs (with more wicked stuff in there) intact?
EDIT: I'll try to further articulate the problem with an example.
Excel Sheet test.xlsx has four tabs (aka worksheets): Sheet1, Sheet2, Sheet3, Sheet4
I read Sheet3 into a DataFrame (let's call it df) using pandas.read_excel()
Sheet1 and Sheet2 contain formulas, graphs, and various formatting that neither openpyxl nor xlrd can successfully parse, and Sheet4 contains other data. I don't want to touch those tabs at all.
Sheet2 actually has some references to cells on Sheet3
I make some edits to df and now want to write it back to sheet3, leaving the other sheets untouched (and the references to it from other worksheets in the workbook intact)
Can I do that and, if so, how? | Can Pandas read and modify a single Excel file worksheet (tab) without modifying the rest of the file? | 1 | 1 | 0 | 32,281 |
28,143,334 | 2015-01-26T00:44:00.000 | 1 | 0 | 1 | 1 | python | 28,143,351 | 1 | false | 0 | 0 | The file you're deleting might be in use or requires administrative privileges to remove. You can use a subprocess to call you script as an administrator. | 1 | 1 | 0 | I am using os.remove in a for loop. Sometimes, the process was blocked, like a dead lock, but I'm not using a thread.
I want to know why process was blocked, and what can I do to prevent it? | In python os library, process was blocked | 0.197375 | 0 | 0 | 39 |
28,144,261 | 2015-01-26T03:04:00.000 | 0 | 0 | 0 | 0 | python,turtle-graphics | 28,177,122 | 1 | false | 0 | 1 | I was asked this question by a friend, and re installation solved the problem | 1 | 0 | 0 | I am trying to run a simple Turtle Graphics file, but no drawing shows up and IDLE asks me what background color you want?
What's wrong with my Python? | Drawing not shown using Python Turtle Graphics | 0 | 0 | 0 | 197 |
28,144,352 | 2015-01-26T03:16:00.000 | 13 | 0 | 1 | 0 | python,pycharm | 28,388,454 | 11 | false | 0 | 0 | PyCharm version 4.04 does not allow me to paste text from a source (like a text editor, url, document) into a file open in PyCharm. I can cut and paste between two files open in PyCharm. Reverting back to PyCharm version 4.01 returned the expected paste operation for me.
Running PyCharm on windows 8 | 10 | 21 | 0 | Every time I try to copy and paste a web url into PyCharm, I even tried Paste Simple, I see nothing. Is there any force that could potentially block out people who try to paste information in? I really have no clue what's going on. | How do you copy and Paste in Pycharm? | 1 | 0 | 0 | 16,809 |
28,144,352 | 2015-01-26T03:16:00.000 | 21 | 0 | 1 | 0 | python,pycharm | 47,894,764 | 11 | false | 0 | 0 | Most likely you installed the IdeaVim support when you first installed PyCharm. To un-install the plugin, go to:
File --> Settings --> Plugins
and uncheck the IdeaVim entry.
You will need to restart PyCharm. After I did this, I could easily copy and paste via CTRL + C/X/V from anywhere into PyCharm. | 10 | 21 | 0 | Every time I try to copy and paste a web url into PyCharm, I even tried Paste Simple, I see nothing. Is there any force that could potentially block out people who try to paste information in? I really have no clue what's going on. | How do you copy and Paste in Pycharm? | 1 | 0 | 0 | 16,809 |
28,144,352 | 2015-01-26T03:16:00.000 | 0 | 0 | 1 | 0 | python,pycharm | 47,471,422 | 11 | false | 0 | 0 | I have just learned that using the python browser allows you to paste too the pi only (my experience). not from the desktop to pi. I assume it is because their are two different platforms running on the same screen. when i'm on full screen with the pi on my desktop, i can't (ALT Tab) to the desktop. But i can vice versa. hope this helps. i have only just started to learn pi and programming etc | 10 | 21 | 0 | Every time I try to copy and paste a web url into PyCharm, I even tried Paste Simple, I see nothing. Is there any force that could potentially block out people who try to paste information in? I really have no clue what's going on. | How do you copy and Paste in Pycharm? | 0 | 0 | 0 | 16,809 |
28,144,352 | 2015-01-26T03:16:00.000 | 0 | 0 | 1 | 0 | python,pycharm | 64,817,538 | 11 | false | 0 | 0 | Resolved my issues of copy, paste, inserting after selection.
Go to [Tools] in pychar-menu-bar and uncheck on [Vim Emulator] | 10 | 21 | 0 | Every time I try to copy and paste a web url into PyCharm, I even tried Paste Simple, I see nothing. Is there any force that could potentially block out people who try to paste information in? I really have no clue what's going on. | How do you copy and Paste in Pycharm? | 0 | 0 | 0 | 16,809 |
28,144,352 | 2015-01-26T03:16:00.000 | 0 | 0 | 1 | 0 | python,pycharm | 64,265,383 | 11 | false | 0 | 0 | Go to "View" then goto "quick switch scheme" then set you "keymap" to "windows".
This worked for me.
I did not need to uninstall idealvim. | 10 | 21 | 0 | Every time I try to copy and paste a web url into PyCharm, I even tried Paste Simple, I see nothing. Is there any force that could potentially block out people who try to paste information in? I really have no clue what's going on. | How do you copy and Paste in Pycharm? | 0 | 0 | 0 | 16,809 |
28,144,352 | 2015-01-26T03:16:00.000 | 1 | 0 | 1 | 0 | python,pycharm | 61,390,107 | 11 | false | 0 | 0 | IdeaVim plugin doesnot allow to to use shortcut keys properly as it has different configuration for shortcut keys. So uninstalling IdeaVim and then followed by restarting PyCharm works out well.
To do the above :-
File -> Settings -> Plugins -> (search for IdeaVim) Uninstall it or disable it
It will ask for restart, so restart PyCharm | 10 | 21 | 0 | Every time I try to copy and paste a web url into PyCharm, I even tried Paste Simple, I see nothing. Is there any force that could potentially block out people who try to paste information in? I really have no clue what's going on. | How do you copy and Paste in Pycharm? | 0.01818 | 0 | 0 | 16,809 |
28,144,352 | 2015-01-26T03:16:00.000 | 0 | 0 | 1 | 0 | python,pycharm | 39,496,631 | 11 | false | 0 | 0 | When the copy/ paste shortcuts are failed, I found Execute Selection in Console (alt + shift + E) is useful. | 10 | 21 | 0 | Every time I try to copy and paste a web url into PyCharm, I even tried Paste Simple, I see nothing. Is there any force that could potentially block out people who try to paste information in? I really have no clue what's going on. | How do you copy and Paste in Pycharm? | 0 | 0 | 0 | 16,809 |
28,144,352 | 2015-01-26T03:16:00.000 | 1 | 0 | 1 | 0 | python,pycharm | 36,463,803 | 11 | false | 0 | 0 | Looks like just a bug. I use 2016.1 and restart helps. | 10 | 21 | 0 | Every time I try to copy and paste a web url into PyCharm, I even tried Paste Simple, I see nothing. Is there any force that could potentially block out people who try to paste information in? I really have no clue what's going on. | How do you copy and Paste in Pycharm? | 0.01818 | 0 | 0 | 16,809 |
28,144,352 | 2015-01-26T03:16:00.000 | 0 | 0 | 1 | 0 | python,pycharm | 33,716,038 | 11 | false | 0 | 0 | This happened to me as well, I fixed it after disabling antivirus safe search in the browser and restarted Pycharm. | 10 | 21 | 0 | Every time I try to copy and paste a web url into PyCharm, I even tried Paste Simple, I see nothing. Is there any force that could potentially block out people who try to paste information in? I really have no clue what's going on. | How do you copy and Paste in Pycharm? | 0 | 0 | 0 | 16,809 |
28,144,352 | 2015-01-26T03:16:00.000 | 1 | 0 | 1 | 0 | python,pycharm | 32,481,871 | 11 | false | 0 | 0 | Similar here.. Windows 7, Pycharm community edition 4.5.4. Can copy-paste from pycharm to outside apps. But when doing reverse, there are inconsistent behaviors.
From notepad (or even this editor windows where I am typing this), I can copy to pycharm. However, if I copy any other text (say, an article from wikipedia), I cannot paste in to pycharm. Clicking on paste does absolutely nothing.
So current solution: Copy something ... paste to notepad. Then copy from notepad and paste to pycharm. | 10 | 21 | 0 | Every time I try to copy and paste a web url into PyCharm, I even tried Paste Simple, I see nothing. Is there any force that could potentially block out people who try to paste information in? I really have no clue what's going on. | How do you copy and Paste in Pycharm? | 0.01818 | 0 | 0 | 16,809 |
28,146,773 | 2015-01-26T08:33:00.000 | 4 | 0 | 1 | 0 | python,python-2.7,anaconda,spyder | 28,176,485 | 2 | true | 0 | 0 | The easiest solution here is to use the Spyder that comes with Anaconda. | 1 | 7 | 0 | I installed Spyder IDE before I have installed the Anaconda (on Ubuntu 14.04), on the terminal when I type python I have the anaconda python and I can import all of its packages. But on Spyder I still have the original python and I cannot import the Anaconda packages, how can I setup Spyder to use the Anaconda python? | Setup Spyder to work with Anaconda python on Ubuntu 14.04 | 1.2 | 0 | 0 | 5,940 |
28,150,201 | 2015-01-26T12:32:00.000 | 1 | 0 | 1 | 0 | python,pygame,raspberry-pi | 32,603,009 | 2 | false | 0 | 1 | There is no "solution", only workarounds here.
To have working environment I install system package with pygame (i.e. pacman -S python2-pygame in Arch Linux) then create virtualenv with --system-site-packages switch. Pygame has not been updated for more than 5 years so it's highly unlikely that any changes will come in foreseable future. Later in this virtualenv I can install PygameUI with --no-deps switch to skip dependency checks - Pygame is already installed in required version. | 1 | 2 | 0 | I have a Pythonscript where I want to import pygameui. When I perform:
sudo pip install pygameui
in the terminal, I get the following message:
Downloading/unpacking pygameui Running setup.py egg_info for package
pygameui
Requirement already satisfied (use --upgrade to upgrade): setuptools in
/usr/local/lib/python2.7/dist-packages/setuptools-12.0.4-py2.7.egg
(from pygameui) Downloading/unpacking pygame>=1.9.1 (from pygameui)
Could not find a version that satisfies the requirement pygame>=1.9.1
(from pygameui) (from versions: ) No distributions matching the
version for pygame>=1.9.1 (from pygameui) Storing complete log in
/root/.pip/pip.log
I am struggling to solve this issue. Can somebody help me? | Trouble with PyGameUI - RaspberryPi | 0.099668 | 0 | 0 | 1,630 |
28,151,557 | 2015-01-26T14:01:00.000 | 0 | 1 | 0 | 1 | java,python,ubuntu | 28,151,615 | 2 | false | 0 | 0 | If you put it in ~/.bashrc it will run at the same time you log in | 1 | 0 | 0 | I have made a script in Java and Python that logs in to my internet. I want to run one of it on my Ubuntu 14.10 at boot (before user login). How do I do it? | How to run a script that logs in to the internet at boot (before user login) on ubuntu | 0 | 0 | 0 | 38 |
28,152,579 | 2015-01-26T14:54:00.000 | 0 | 1 | 0 | 0 | python,cisco,pysnmp | 48,458,525 | 1 | false | 0 | 0 | Approach 1 is better from most perspectives.
It uses a little memory on the PC due to running a trap collecting daemon, but the footprint should be reasonably small since it only needs to listen for traps and decode them, not do any complex task.
Existing tools to receive traps include the net-snmp suite which allows you to just configure the daemon (i e you don't have to do any programming if you want to save some time).
Approach 2 has a couple of problems:
No matter what polling interval you choose, you run the risk of missing an alarm that was only active on the router for a short time.
Consumes CPU and network resources even if no faults are occurring.
Depending on the MIB of the router, some types of event may not be stored in any table for later retrieval. For Cisco, I would not expect this problem, but you do need to study the MIB and make sure of this. | 1 | 2 | 0 | Which is the more resource-friendly way to collect SNMP traps from a Cisco router via python:
I could use a manager on a PC running a server, where the Cisco SNMP traps are sent to in case one occurs
I could use an agent to send a GET/GETBULK request every x timeframe to check if any new traps have occurred
I am looking for a way to run the script so that it uses the least resources as possible. Not many traps will occur so the communication will be low mostly, but as soon as one does occur, the PC should know immediately. | Collecting SNMP traps with pySNMP | 0 | 0 | 1 | 2,151 |
28,154,828 | 2015-01-26T16:53:00.000 | 1 | 0 | 0 | 0 | python,video,google-drive-api,html5-video,chromecast | 28,157,049 | 1 | true | 0 | 0 | What you are looking to do is called progressive download, or pseudo-streaming. It is possible with the mp4 container if the moov atom is before the mdat atom. This is sometimes called faststart | 1 | 2 | 0 | I'm using Google Drive's API to download a video from my Drive account. However, I'm using Partial Download, receiving the file by chunks. This is done by a Python script.
If I try to play it using html5 , it won't work as I want because it plays until the size the file had before loading the page and then it stops, without waiting for the next chunk or updating to the current filesize.
Is there a way to play it as if it was streaming?
In the near future I also need to stream this way to chromecast and other devices (android, ps4, etc). | How to play a video being downloaded as if it was a stream? | 1.2 | 0 | 1 | 369 |
28,156,037 | 2015-01-26T18:07:00.000 | 1 | 0 | 1 | 0 | python,pyinstaller,py2app,praw | 30,129,259 | 1 | true | 1 | 0 | I came across this error today - not in the context of py2app, but after a pip upgrade of praw. In case you still have this problem (unlikely :)) and/or in the interest of posterity, here's how I was able to fix it: I noticed that the error was in reading the praw.ini file, which very much exists on my system. The real problem was the owner of the file was root, and the owner only had read privileges. Changing that to have my account read/execute privileges to everything inside praw fixed the issue. | 1 | 0 | 0 | I'm trying to wrap my Python script into an application using py2app, but when I try to run the app I'm getting this PRAW related error:
Exception: Could not find config file in any of: ['/Users/username/CS/Applicationame/dist/applicationname.app/Contents/Resources/lib/python2.7/site-packages.zip/praw/praw.ini', '/Users/username/.config/praw.ini', 'praw.ini']
The strange thing is I navigated to the first path, unzipped site-packages.zip and found praw.ini inside /praw, so I'm not really sure why I'm getting this error. I've also tried using pyinstaller but I get the same error. | Cannot find PRAW config file when wrapping application with py2app | 1.2 | 0 | 0 | 399 |
28,156,422 | 2015-01-26T18:32:00.000 | 0 | 0 | 0 | 0 | python,django,django-deployment | 28,159,360 | 2 | false | 1 | 0 | The built-in development server (that you get by doing python manage.py runserver) will refresh whenever you make a change. Apache will not (by default).
You either need to restart apache, or you need to set maximum-requests=1 in your WSGI config.
The way to go is to run the built-in dev server for development, and then deploy to an apache server for production. | 1 | 1 | 0 | I have a sample Django app which is being hosted on an Apache2 server using mod_wsgi. Currently I am testing it only on the loopback address (127.0.0.1). So this is what I do:
Open a tab and go to the loop back address. And then I work on the Django app.
Now when I start another tab and go to the loopback address, the Django app does not start from scratch. It shows me the exact same thing happening in the other tab.
How do I avoid this situation? Will it be resolved automatically if I run the app on the web? I am very new to this and I have not been able find a solution on google. I can provide any file needed to resolve the issue. | Django app shows the same instance every time I hit the server | 0 | 0 | 0 | 98 |
28,159,111 | 2015-01-26T21:30:00.000 | 0 | 0 | 1 | 0 | python,django | 28,159,200 | 1 | true | 1 | 0 | Make sure your wsgi file points to the right virtualenv! | 1 | 0 | 0 | I installed a django-secure into a virtualenv using pip. The install was normal. The module shows up in the virtualenv pip list and in virtualenvs/dev/lib/python2.7/site-packages. I get the following error when running my code.
ImportError: No module named djangosecure
The folder is in there and there is an init. No install issues. What am I doing wrong and how do I fix it? | Virtualenv installed package not found | 1.2 | 0 | 0 | 196 |
28,161,508 | 2015-01-27T00:53:00.000 | 0 | 0 | 1 | 1 | python,gitpython | 28,179,875 | 1 | false | 0 | 0 | You might not have git.ext in your PATH, but that can easily be tested by executing it yourself.
If you see an error, you can either add it to the PATH, or set the GIT_PYTHON_GIT_EXECUTABLEto the executable git-python should execute for git commandline services. | 1 | 0 | 0 | I am facing an issue while cloning a git repo.
I am using function clone_from from GitPython library
from git import Repo
Repo.clone_from("git://github.com/facebook/buck.git", "D:\sample")
I am getting error
WindowsError: The system cannot find the file specified
Can someone please tell me if this is how to clone a repo using the library? | GitPython - clone_from not working | 0 | 0 | 0 | 1,005 |
28,162,229 | 2015-01-27T02:26:00.000 | 0 | 1 | 0 | 1 | python,linux,bash,ssh | 28,223,316 | 2 | true | 0 | 0 | The solution to my problem is to use PATH=/cygdrive/c/WINDOWS/system32:/bin cmd /c in front of the script call, sth like: ssh user@host "PATH=/cygdrive/c/WINDOWS/system32:/bin cmd /c script" .This will run the script using in Windows env.
In my case the problem was that the script was run under cygwin env and I wanted to be run in a Windows env. | 1 | 1 | 0 | I know I can find multiple answers to this question but I have a problem with the result.
I have a Windows PC with a script on it and a Linux PC that has to start the script using ssh.
The problem I am seeing is that for some reason it's using the Linux environment to run the script and not the Windows env. Is this expected and if yes how can I start a remote script (From Linux) and still use the Windows env?
Linux: Python 2.7
Windows: Python 3.4
My example:
I am running:ssh user@host "WINDOWS_PYTHON_PATH Script.py arg1 arg2 arg3" and it fails internally at a copy command
I can't run ssh user@host "Script.py arg1 arg2 arg3" because then it will fail to run the script because of the python version.
The way I run the command in Windows is using the same syntax "Script.py arg1 arg2 arg3" and it works.
It looks like it's using the Linux env to run the script. I would like to run the script on Windows no matter who triggers it. How can I achieve this? | How to execute a remote script using ssh | 1.2 | 0 | 0 | 865 |
28,163,981 | 2015-01-27T05:43:00.000 | 0 | 0 | 1 | 0 | python,python-2.7,logging,elasticsearch,logstash | 39,983,169 | 1 | false | 0 | 0 | As the question have been about "how can I push a specific file to the elasticsearch via logstash with python", I'd suggest to:
Observe a directory for *.log with filebeat or logstash directly.
Create symlinks for files you need to push. | 1 | 0 | 0 | My requirement is to read from Logstash based log files, and index them into Elasticsearch.
For now, I have configured the Logstash and started the daemon to do so.
But what I need to know is if there is any existing Python2.x API for Logstash for the mentioned use-case. | Logstash Python API to read from files | 0 | 0 | 0 | 620 |
28,167,648 | 2015-01-27T10:00:00.000 | 10 | 0 | 0 | 0 | python,optimization,scipy | 28,249,829 | 4 | true | 0 | 0 | There is actually no need to see your code to explain what is happening. I will answer point by point quoting you.
My problem is, when I start the minimization, the value printed decreases
untill it reaches a certain point (the value 46700222.800). There it
continues to decrease by very small bites, e.g.,
46700222.797,46700222.765,46700222.745,46700222.699,46700222.688,46700222.678
Notice that the difference between the last 2 values is -0.009999997913837433, i.e. about 1e-2. In the convention of minimization algorithm, what you call values is usually labelled x. The algorithm stops if these 2 conditions are respected AT THE SAME TIME at the n-th iteration:
convergence on x: the absolute value of the difference between x[n] and the next iteration x[n+1] is smaller than xtol
convergence on f(x): the absolute value of the difference between f[n] and f[n+1] is smaller than ftol.
Moreover, the algorithm stops also if the maximum number of iterations is reached.
Now notice that xtol defaults to a value of 1e-4, about 100 times smaller than the value 1e-2 that appears for your case. The algorithm then does not stop, because the first condition on xtol is not respected, until it reaches the maximum number of iterations.
I read that the options ftol could be used but it has absolutely no
effect on my code. In fact, I don't even know what value to put for
ftol. I tried everything from 0.00001 to 10000 and there is still no
convergence.
This helped you respecting the second condition on ftol, but again the first condition was never reached.
To reach your aim, increase also xtol.
The following methods will also help you more in general when debugging the convergence of an optimization routine.
inside the function you want to minimize, print the value of x and the value of f(x) before returning it. Then run the optimization routine. From these prints you can decide sensible values for xtol and ftol.
consider nondimensionalizing the problem. There is a reason if ftol and xtol default both to 1e-4. They expect you to formulate the problem so that x and f(x) are of order O(1) or O(10), say numbers between -100 and +100. If you carry out the nondimensionalization you handle a simpler problem, in the way that you often know what values to expect and what tolerances you are after.
if you are interested just in a rough calculation and can't estimate typical values for xtol and ftol, and you know (or you hope) that your problem is well behaved, i.e. that it will converge, you can run fmin in a try block, pass to fmin only maxiter=20 (say), and catch the error regarding the Maximum number of function evaluations has been exceeded. | 2 | 6 | 1 | I have a function I want to minimize with scipy.optimize.fmin. Note that I force a print when my function is evaluated.
My problem is, when I start the minimization, the value printed decreases untill it reaches a certain point (the value 46700222.800). There it continues to decrease by very small bites, e.g., 46700222.797,46700222.765,46700222.745,46700222.699,46700222.688,46700222.678
So intuitively, I feel I have reached the minimum, since the length of each step are minus then 1. But the algorithm keeps running untill I get a "Maximum number of function evaluations has been exceeded" error.
My question is: how can I force my algorithm to accept the value of the parameter when the function evaluation reaches a value from where it does not really evolve anymore (let say, I don't gain more than 1 after an iteration). I read that the options ftol could be used but it has absolutely no effect on my code. In fact, I don't even know what value to put for ftol. I tried everything from 0.00001 to 10000 and there is still no convergence. | seeking convergence with optimize.fmin on scipy | 1.2 | 0 | 0 | 13,104 |
28,167,648 | 2015-01-27T10:00:00.000 | 0 | 0 | 0 | 0 | python,optimization,scipy | 28,219,470 | 4 | false | 0 | 0 | Your question is a bit ambiguous. Are you printing the value of your function, or the point where it is evaluated?
My understanding of xtol and ftol is as follows. The iteration stops
when the change in the value of the function between iterations is less than ftol
AND
when the change in x between successive iterations is less than xtol
When you say "...accept the value of the parameter...", this suggests you should change xtol. | 2 | 6 | 1 | I have a function I want to minimize with scipy.optimize.fmin. Note that I force a print when my function is evaluated.
My problem is, when I start the minimization, the value printed decreases untill it reaches a certain point (the value 46700222.800). There it continues to decrease by very small bites, e.g., 46700222.797,46700222.765,46700222.745,46700222.699,46700222.688,46700222.678
So intuitively, I feel I have reached the minimum, since the length of each step are minus then 1. But the algorithm keeps running untill I get a "Maximum number of function evaluations has been exceeded" error.
My question is: how can I force my algorithm to accept the value of the parameter when the function evaluation reaches a value from where it does not really evolve anymore (let say, I don't gain more than 1 after an iteration). I read that the options ftol could be used but it has absolutely no effect on my code. In fact, I don't even know what value to put for ftol. I tried everything from 0.00001 to 10000 and there is still no convergence. | seeking convergence with optimize.fmin on scipy | 0 | 0 | 0 | 13,104 |
28,170,340 | 2015-01-27T12:16:00.000 | 2 | 0 | 0 | 0 | javascript,python,lua,freeswitch | 28,245,548 | 2 | true | 0 | 0 | Using the EventSocket or simply a shell script calling fscli -x "reloadxml" | 1 | 0 | 0 | After adding a user,
how can I reload the Dial-plan XML dynamical using script. | In freeswitch is there any possibility to reload xml using script | 1.2 | 0 | 1 | 864 |
28,172,741 | 2015-01-27T14:22:00.000 | 0 | 0 | 0 | 1 | python,shell,input,ksh | 28,246,101 | 2 | false | 0 | 0 | You can save your parameters in Python and give them on the commandline each time you call the script.
Your script can store them in a file (or database, service, ..) and read them when started again. | 1 | 0 | 0 | I'm using Python to run a .ksh script, using subprocess.call().
This script requires the user to enter text at certain points - whatever the equivalent of Python's input() is in KSH I guess.
The problem I'm having is that I have to run the script ~200 times, and I don't want to have to enter this information each time. Is there anyway that I can set it up so that these requests for user input are automatically given some value each time without the user even needing to do anything?
I'm pretty new to using Python at the shell in this way, so apologies if this question doesn't make sense. Happy to take any feedback. I haven't found this question asked previously - mostly people ask about passing arguments to the script - but I may have missed something as I was having trouble finding the key search terms.
The Python version is 2.7, and it's a UNIX environment. | Passing values to KSH scripts from Python | 0 | 0 | 0 | 1,004 |
28,173,716 | 2015-01-27T15:12:00.000 | 0 | 0 | 1 | 0 | python-multithreading | 28,207,425 | 1 | true | 0 | 0 | How about you create a list of 101 elements, 0 through 100. Then store the output from processing file x into list element x. When all processing is complete, write the data in the list elements from 0 to 100 to the file. | 1 | 0 | 0 | I am using Python threading to process multiple files and I want output of each of the files 0 through 100 being processed to be written in a file in orderly fashion
Currently I am saving output of all the thread as they get executed and hence the order is not maintained.
How can I achieve this? | Python threading how get output of multiprocess in sequence | 1.2 | 0 | 0 | 109 |
28,174,487 | 2015-01-27T15:50:00.000 | 3 | 0 | 0 | 0 | python,sockets,ethernet | 28,174,528 | 1 | false | 0 | 0 | Unplug one and if it stops working - you found the right one.
If it does not stop working it is the other one. | 1 | 1 | 0 | I have an embedded system connected with an ethernet port to one of my 2 ethernet interfaces, but I have the problem that my python code for the socket connection does not know where to connect to the embedded.
I mean, sometimes I get the connection and sometimes I just don't (and I have to change the cable to the other interface), because I don't know how the socket functionality is getting the right ethernet port in which it has to connect.
is there anything I can do on my python code to know the correct ethernet port in which the embedded is connected? (in order to know every time I connect it without changing the cable to another interface) | I have 2 ethernet interfaces on the same PC, how to know which interface is connected in python? | 0.53705 | 0 | 1 | 172 |
28,174,683 | 2015-01-27T15:59:00.000 | 3 | 0 | 1 | 0 | python,python-2.7,tkinter,tkinter-canvas | 28,174,950 | 1 | true | 0 | 1 | All Tkinter classes in python 2.x are old style classes. | 1 | 1 | 0 | I would like to know if Tkinter.Canvas is a classic or modern Python class, because super does not work as expected (for me). | Is Tkinter.Canvas a classic class? | 1.2 | 0 | 0 | 58 |
28,175,349 | 2015-01-27T16:34:00.000 | 2 | 0 | 1 | 0 | python,anaconda,canopy,spyder,libtiff | 28,198,230 | 2 | false | 0 | 0 | Conda's libtiff package is the C library, not the Python library. The easiest way to get it would be to use conda to install the dependencies (like libtiff, numpy), and then use pip to install libtiff (pip install libtiff). | 1 | 2 | 0 | I have played around with Python a little but never have I had to install my own packages. I am currently trying to write a program that reads in 'tiff' files so I'm trying to install the 'libtiff' package and I'm having a nightmare!
First, I was using the Anaconda distribution and the phrase 'conda install libtiff' which would tell me the install was successful. However then I was never able to find libtiff in the Spyder IDE or ipython console.
Having used Canopy in the past, I uninstalled Anaconda and gave Canopy another shot using 'pip install libtiff', however I receive an error saying it failed with error code 1 and I don't know what this is.
I must be missing something fairly crucial but installing this module is proving almost impossible! | Installing Python modules with Anaconda or Canopy | 0.197375 | 0 | 0 | 2,924 |
28,177,807 | 2015-01-27T18:49:00.000 | 1 | 0 | 0 | 0 | python,user-interface,tkinter | 28,177,945 | 1 | true | 0 | 0 | As long as you clearly separate your GUI logic from your processing logic, it shouldn't. As is the case with all optimization though, the best approach is to make the thing work first, then profile and optimize if it isn't performing fast enough for you.
I would suggest you first create your web crawler and forget the GUI. Profile and optimize it if you think it's too slow. Build it with the goal of it being an importable library. Once that works from the command line, then create your GUI front-end and bind your web crawling library functions and classes to the buttons and fields in your GUI. That clear separation should ensure that the GUI logic doesn't interfere with the performance of the web crawling. In particular, try to avoid updating the GUI with status information in the middle of the web crawling. | 1 | 0 | 0 | Hi I want to make a web crawler that checks URL for data, If i make a simple Gui that would make the script easier to look for variables in that data, Would adding code for the gui make my web crawler less efficient ?
I need the crawler to be as efficient as possible, to be able to process data as fast as possible. Would making a gui for this Python script, hinder the performance of the web crawler ? | If I make a simple gui for my python script, would it affect its efficiency? | 1.2 | 0 | 1 | 150 |
28,177,983 | 2015-01-27T18:59:00.000 | 1 | 0 | 1 | 0 | python | 28,178,022 | 4 | false | 0 | 0 | The "W" means that you are opening the file called filename with the purpose of writing to it(hence the "W" for write.) | 1 | 0 | 0 | I'm reading Exercise 16 of "Learn Python The Hard way" and I'm confused about open(filename, "w") -- what does the "w" mean? | What does the "w" mean in open(filename, "w")? | 0.049958 | 0 | 0 | 21,567 |
28,178,161 | 2015-01-27T19:10:00.000 | 1 | 0 | 1 | 0 | python,python-3.x | 28,178,223 | 2 | false | 0 | 0 | The constructor is optional. However, if you specify one, it must be named __init__; it cannot be named anything else (otherwise, how would Python know which function is the constructor?).
One, called __init__ (though it can call out to other functions).
No, but using a name other than self will make your code harder to read by others, who expect the name self by convention. | 1 | 0 | 0 | Do you always have to use __init__ as constructor?
How many constructors can you use it in one class?
Do you need to have 'self' as first argument or you can use any other name like 'shapes' instead of 'self'? | Do you always have to use __init__ as constructor? | 0.099668 | 0 | 0 | 79 |
28,179,883 | 2015-01-27T20:59:00.000 | 0 | 1 | 1 | 1 | python,windows,multithreading | 28,252,408 | 1 | false | 0 | 0 | My solution is place testing code in exe file. Now i can kill all python scripts, as previously. Maybe someone will offer another solution? | 1 | 0 | 0 | I need to kill all python scripts except one. Unfortunattely, all scripts have similar name "pythonw.exe". Difference in PID only.
First time, i don't need to leave one script alive, thats why i just kill all python scripts in system by taskkill /F /T /IM "python*" command.
But now, i have one script, that automates all other scripts. The script is my simple "testing system". It rewrite object script, start, stop and restart.
But my problem is multithreading in objective script (10 - 20 threads).
I don't know, how to kill all python threads, except automates one.
P.S.
I tried to get tasklist and PID of automates script, and killed all scripts, except that one, but it doesn't work (i don't know why)
P.P.S
OS: Windows XP
Python 2.7.8 | Python kill scripts | 0 | 0 | 0 | 207 |
28,180,013 | 2015-01-27T21:07:00.000 | 1 | 1 | 0 | 0 | python,git,timeout | 29,615,466 | 2 | true | 0 | 0 | No you can't, you need to timeout the command using a wrapper. | 1 | 1 | 0 | I have some git commands scripted in python and occasionally git fetch can hang for hours if there is no connectivity. Is there a way to time it out and report a failure instead? | Can you specify a timeout to git fetch? | 1.2 | 0 | 1 | 2,127 |
28,180,074 | 2015-01-27T21:11:00.000 | 1 | 0 | 0 | 0 | python,django,django-views | 28,180,194 | 1 | true | 1 | 0 | I think the flow would look more like:
Question_Page -> Post Data View (processes the data from the question page) -> redirect to Output page (based upon data results).
The only page someone would "see" is the "Question Page" and "Output page"... now if processing takes a long time, they could click submit again on the "Question Page". There are lots of ways to deal with that in javascript. | 1 | 0 | 0 | I have a generic set up where you take an assessment which kicks you to a processing page which massages the data, stores it, and then funnels you to the correct output page. You never actually see the processing page it runs and sorts you to the results. I'm concerned this could be exploited. Is there a way to hide this completely without losing my flexibility?
Current flow
Question_Page -> Processing Page -> Output Page (depends upon what you took as determined by the processing page)
I'd like to keep this as some sort of function within a view if possible. | Django Hide Processing Page | 1.2 | 0 | 0 | 34 |
28,182,566 | 2015-01-28T00:22:00.000 | 0 | 0 | 1 | 0 | python,spyder | 54,209,443 | 3 | false | 0 | 0 | A simple way to help you:
use right shift key as End+Enter
First : sudo apt-get install xdotool
In settings, open keyboard and add a custom shortcut
name : New_line
command : xdotool key End KP_Enter
then click the 'disabled' and type R_shift key
Now you can use right shift to achieve what you want ! | 1 | 1 | 0 | When using other editors, most of them have a function about "new line".
For example, the Sublime Text, use
Ctrl + enter
to enter new line directly whatever cursor is at end of line or not.
After checked all the setting about spyder, have no idea about this.
Thus i want to add new feature about "new line" with
Ctrl + enter
To enter a new line without the cursor need to move to tail
Would you have some ideas to share me ? Thank you. | How to add "new line" keyboard shortcuts in spyder | 0 | 0 | 0 | 7,437 |
28,183,527 | 2015-01-28T02:18:00.000 | 0 | 1 | 0 | 0 | python,email,gmail | 28,184,142 | 2 | false | 0 | 0 | Unfortunately the categories are not exposed to IMAP. You can work around that by using filters in Gmail to apply normal user labels. (Filter on, e.g., category:social.) | 2 | 0 | 0 | I am trying to extract mails from gmail using python. I noticed that I can get mails from "[Gmail]/All Mail", "[Gmail]/Drafts","[Gmail]/Spam" and so on. However, is there any method to retrieve mails that are labeled with "Primary", "Social", "Promotions" etc.? These tags are under the "categories" label, and I don't know how to access it.
By the way, I am using imaplib in python. Do I need to access the "categories" with some pop library? | How to extract mail in "categories" label in gmail? | 0 | 0 | 1 | 596 |
28,183,527 | 2015-01-28T02:18:00.000 | 0 | 1 | 0 | 0 | python,email,gmail | 28,218,594 | 2 | false | 0 | 0 | Yes, categories are not available in IMAP. However, rather than filters, I found that gmail api is more favorable for me to get mail by category. | 2 | 0 | 0 | I am trying to extract mails from gmail using python. I noticed that I can get mails from "[Gmail]/All Mail", "[Gmail]/Drafts","[Gmail]/Spam" and so on. However, is there any method to retrieve mails that are labeled with "Primary", "Social", "Promotions" etc.? These tags are under the "categories" label, and I don't know how to access it.
By the way, I am using imaplib in python. Do I need to access the "categories" with some pop library? | How to extract mail in "categories" label in gmail? | 0 | 0 | 1 | 596 |
28,185,311 | 2015-01-28T05:32:00.000 | 0 | 0 | 1 | 0 | python,algorithm,list,moving-average | 28,185,443 | 2 | false | 0 | 0 | Here is an answer that retains floating point for keeping a running total - I think a weighted average requires only two running totals:
Allocate an array to store your numbers in, so that inserting a number means finding an empty space in the array and setting it to that value and deleting a number means setting its value in the array to zero and declaring that space empty - you can use a linked list of free entries to find empty entries in time O(1)
Now you need to work out the sum of an array of size N. Treat the array as a full binary tree, as in heapsort, so offset 0 is the root, 1 and 2 are its children, 3 and 4 are the children of 1, 5 and 6 are the children of 2, and so on - the children of i are at 2i+1 and 2i+2.
For each internal node, keep the sum of all entries at or below that node in the tree. Now when you modify an entry you can recalculate the sum of the values in the array by working your way from that entry up to the root of the tree, correcting the partial sums as you go - this costs you O(log N) where N is the length of the array. | 2 | 2 | 0 | I'm constantly adding/removing tuples to a list in Python and am interested in the weighted average (not the list itself). Since this part is computationally quite expensive compared to the rest, I want to optimise it. What's the best way of keeping track of the weighted average? I can think of two methods:
keeping the list and calculating the weighted average every time it gets accessed/changed (my current approach)
just keep track of current weighted average and the sum of all weights and change weight and current weighted average for every add/remove action
I would prefer the 2nd option, but I am worried about "floating point errors" induced by constant addition/subtraction. What's the best way of dealing with this? | "Running" weighted average | 0 | 0 | 0 | 627 |
28,185,311 | 2015-01-28T05:32:00.000 | 1 | 0 | 1 | 0 | python,algorithm,list,moving-average | 28,185,734 | 2 | false | 0 | 0 | Try doing it in integers? Python bignums should make a rational argument for rational numbers (sorry, It's late... really sorry actually).
It really depends on how many terms you are using and what your weighting coefficient is as to weather you will experience much floating point drift. You only get 53 bits of precision, you might not need that much.
If your weighting factor is less than 1, then your error should be bounded since you are constantly decreasing it. Let's say your weight is 0.6 (horrible, because you cannot represent that in binary). That is 0.00110011... represented as 0.0011001100110011001101 (rounded in the last bit). So any error you introduce from that rounding, will be then decreased after you multiply again. The error in the most current term will dominate.
Don't do the final division until you need to. Once again given 0.6 as your weight and 10 terms, your term weights will be 99.22903012752124 for the first term all the way down to 1 for the last term (0.6**-t). Multiply your new term by 99.22..., add it to your running sum and subtract the trailing term out, then divide by 246.5725753188031 (sum([0.6**-x for x in range(0,10)])
If you really want to adjust for that, you can add a ULP to the term you are about to remove, but this will just underestimate intentionally, I think. | 2 | 2 | 0 | I'm constantly adding/removing tuples to a list in Python and am interested in the weighted average (not the list itself). Since this part is computationally quite expensive compared to the rest, I want to optimise it. What's the best way of keeping track of the weighted average? I can think of two methods:
keeping the list and calculating the weighted average every time it gets accessed/changed (my current approach)
just keep track of current weighted average and the sum of all weights and change weight and current weighted average for every add/remove action
I would prefer the 2nd option, but I am worried about "floating point errors" induced by constant addition/subtraction. What's the best way of dealing with this? | "Running" weighted average | 0.099668 | 0 | 0 | 627 |
28,187,233 | 2015-01-28T07:56:00.000 | 2 | 0 | 0 | 0 | python,matlab,curve-fitting,least-squares,surface | 28,189,659 | 2 | false | 0 | 0 | Dont use any toolboxes, GUIs or special functions for this problem. Your problem is very common and the equation you provided may be solved in a very straight-forward manner. The solution to the linear least squares problem can be outlined as:
The basis of the vector space is x^2, y^2, z^2, xy, yz, zx, x, y, z, 1. Therefore your vector has 10 dimensions.
Your problem may be expressed as Ap=b, where p = [A B C D E F G H I J K L]^T is the vector containing your parameters. The right hand side b should be all zeros, but will contain some residual due to model errors, uncertainty in the data or for numerical reasons. This residual has to be minimized.
The matrix A has a dimension of N by 10, where N denotes the number of known points on surface of the parabola.
A = [x(1)^2 y(1)^2 ... y(1) z(1) 1
...
x(N)^2 y(N)^2 ... y(N) z(N) 1]
Solve the overdetermined system of linear equations by computing p = A\b. | 2 | 0 | 1 | I have a set of experimentally determined (x, y, z) points which correspond to a parabola. Unfortunately, the data is not aligned along any particular axis, and hence corresponds to a rotated parabola.
I have the following general surface:
Ax^2 + By^2 + Cz^2 + Dxy + Gyz + Hzx + Ix + Jy + Kz + L = 0
I need to produce a model that can represent the parabola accurately using (I'm assuming) least squares fitting. I cannot seem to figure out how this works. I have though of rotating the parabola until its central axis lines up with z-axis but I do not know what this axis is. Matlab's cftool only seems to fit equations of the form z = f(x, y) and I am not aware of anything in python that can solve this.
I also tried solving for the parameters numerically. When I tried making this into a matrix equation and solving by least squares, the matrix turned out to be invertible and hence my parameters were just all zero. I also am stuck on this and any help would be appreciated. I don't really mind the method as I am familiar with matlab, python and linear algebra if need be.
Thanks | Rotated Paraboloid Surface Fitting | 0.197375 | 0 | 0 | 1,508 |
28,187,233 | 2015-01-28T07:56:00.000 | 0 | 0 | 0 | 0 | python,matlab,curve-fitting,least-squares,surface | 28,188,683 | 2 | false | 0 | 0 | Do you have enough data points to fit all 10 parameters - you will need at least 10?
I also suspect that 10 parameters are to many to describe a general paraboloid, meaning that some of the parameters are dependent. My fealing is that a translated and rotated paraboloid needs 7 parameters (although I'm not really sure) | 2 | 0 | 1 | I have a set of experimentally determined (x, y, z) points which correspond to a parabola. Unfortunately, the data is not aligned along any particular axis, and hence corresponds to a rotated parabola.
I have the following general surface:
Ax^2 + By^2 + Cz^2 + Dxy + Gyz + Hzx + Ix + Jy + Kz + L = 0
I need to produce a model that can represent the parabola accurately using (I'm assuming) least squares fitting. I cannot seem to figure out how this works. I have though of rotating the parabola until its central axis lines up with z-axis but I do not know what this axis is. Matlab's cftool only seems to fit equations of the form z = f(x, y) and I am not aware of anything in python that can solve this.
I also tried solving for the parameters numerically. When I tried making this into a matrix equation and solving by least squares, the matrix turned out to be invertible and hence my parameters were just all zero. I also am stuck on this and any help would be appreciated. I don't really mind the method as I am familiar with matlab, python and linear algebra if need be.
Thanks | Rotated Paraboloid Surface Fitting | 0 | 0 | 0 | 1,508 |
28,187,661 | 2015-01-28T08:28:00.000 | 1 | 0 | 1 | 0 | python,bytecode,vm-implementation | 33,724,808 | 2 | false | 0 | 0 | I know this answer is like 11 months out of date but from my tinkering it seems the following is happening
To access co_names in bytecode, one uses LOAD_GLOBAL(co names index) and this pushes a reference to the desired co_names onto the stack, eg its indirect
To access co_consts in bytecode, one uses LOAD_CONST(co consts index) and this pushes the actual value stored at the desired co_consts onto the stack, eg its direct
I'm not sure it has any direct bearing at a python level, but at a bytecode level its a profound difference | 1 | 5 | 0 | A code object generated by Python compiler contains a tuple of constants used in the instructions (named co_consts) and also a tuple containing names (named co_names).
Why having two distinct lists? Wouldn't be simpler to just use co_consts for names too? | Why does python VM have co_names instead of just using co_consts? | 0.099668 | 0 | 0 | 581 |
28,188,783 | 2015-01-28T09:34:00.000 | 1 | 0 | 0 | 1 | java,c#,python,ide,desktop-application | 28,188,969 | 2 | false | 1 | 0 | You need a web application.Now this web application when loads send request to backend code that backend code will do SSH to remote machine and read the file from specific location.Now that read stream will be send back in response and displayed on web based UI. In these type of application few thinks matters.
1) Like if you whole file at once then it will take time to display that content to user.Better idea will be read around 100 lines at once and when user scroll down then again send request to web server to read next 100 lines in this way you can decrease response time and better user experience. | 1 | 0 | 0 | I have a simple cloud IDE,I want to make it able to build and run applications remotely, the target application's source files will be in a remote server in isolated virtual machine (e.g Windows 8.1,or Ubuntu 14.04). It's not difficult to build that application but how to run it and view its output to users ?
What if it's a desktop application (suppose it's written in C# or Java or Python)?
Note: users access there applications only using browsers (e.g Firefox,Chrome,...)
Edit: desktop application may contains GUI stuff not only console ;) | View running application output in the browser, how? | 0.099668 | 0 | 0 | 1,186 |
28,189,763 | 2015-01-28T10:23:00.000 | 24 | 0 | 1 | 0 | python,pycharm | 28,190,671 | 3 | true | 0 | 0 | There isn't a way to do so. You can extract certain parts of code, but you cannot have pycharm generate getters and setters for you. There is no need either, since all variables are public, and the _var values, even though are treated as private variables can be altered as well.
EDIT (Change in question):
If you want to write less code when making getters and setters, then just use the props or the propsdsnippet in PyCharm. | 1 | 24 | 0 | I wonder whether there is some way of using Pycharm to automatically generate getter(@property) or setter for all my variables in a class.
If there is a way, can someone point it out ?
thanks! Actually I meant to generate (@property) and (@x.setter) automatically. | Pycharm (@property) and (@x.setter) autogeneration | 1.2 | 0 | 0 | 18,235 |
28,190,568 | 2015-01-28T11:01:00.000 | 1 | 0 | 0 | 0 | python,svg,warnings | 32,072,588 | 2 | false | 0 | 0 | contributors are working on refactoring those parts of code where scribus blocks the scripts with popups.
patches have already been applied to the 1.5svn development version to better manage them.
my hint to you:
use the stable version for creating your documents
but -- as long as the new stable 1.6 is not out -- use scribus 1.5 for running your scripts unattended, using the documents you created with 1.4
and if you then hit further stoppers report them to the scribus issues tracker (or make a patch and submit it there!) | 1 | 1 | 0 | When importing a svg file to the DTP programme "Scribus" it shows a warning message (with just one OK-button), that has to be confirmed to go on. This stops my Python Script from working.
So I need a possibility to either confirm the message or - even better - to stop Scribus from showing this message. (something like the "Application.DisplayAlerts = False" in Excel VBA)
A possible solution would be to send an "Enter" command using sendkeys, but I don't like that because the command could miss the target. | Disable warning message in scribus | 0.099668 | 0 | 0 | 108 |
28,195,547 | 2015-01-28T15:05:00.000 | 0 | 0 | 0 | 0 | python,django,angularjs,api | 28,196,456 | 1 | false | 1 | 0 | Depending from your needs you should think about storing the token in the session storage in the local storage or in a cookie(in this case the cookie is used as a storage mechanism and not as an authentication mechanism). | 1 | 0 | 0 | I'm developing my first AngularJS application with Django as backend.
My overall architecture is composed of:
Public API json-rpc server (from which I must retrive data previous authentication process (the client send a user/password with a POST request, and then, the server response with a token string).
Django framework, I use this because I need to have some models and MySQL db for additional data; and because the Public API server doesn't support CORS (is a old version) and I've created an API Proxy with one view of Django.
Angular JS App that it served by Django.
Now, when the client first send user/password with AngularJS -> Django -> API server, the server respond with token, and henceforward the Client use token to make next requests.
My question is: What's the right approach to retain the token on the client (AngularJS) (or on Django if required) after the user did login??
Do you have any suggestion on my architecture?
Thanks in advance... and... sorry for my English :) | Right Auth with AngularJS, Django and external API service | 0 | 0 | 0 | 246 |
28,196,645 | 2015-01-28T15:54:00.000 | -2 | 0 | 1 | 0 | python,windows,installation,pygame,pip | 28,196,768 | 3 | false | 0 | 0 | The best solution to all pip problems is that you newly install python 2.7.9 and then run it. Otherwise, your exact problem can be very hard to track down. | 1 | 6 | 0 | I have installed pip, and I have moved my directory in cmd to C:\Python27\Scripts. I try this code:
'pip install whatever.whl'
It says at the bottom of random code(looks like python):
'ImportError: No module named commands.install'
What is happening? | Why does pip say "No module named commands.install"? | -0.132549 | 0 | 0 | 11,839 |
28,197,444 | 2015-01-28T16:31:00.000 | 3 | 0 | 0 | 0 | python,machine-learning,scikit-learn | 28,198,700 | 2 | true | 0 | 0 | Column 0 corresponds to the class 0, column 1 corresponds to the class 1. | 2 | 1 | 1 | Suppose my labeled data has two classes 1 and 0. When I run predict_proba on the test set it returns an array with two columns. Which column corresponds to which class ? | Python predict_proba class identification | 1.2 | 0 | 0 | 655 |
28,197,444 | 2015-01-28T16:31:00.000 | 0 | 0 | 0 | 0 | python,machine-learning,scikit-learn | 56,207,791 | 2 | false | 0 | 0 | You can check that by printing the classes with print(estimator.classes_). The array will have the same order like the output. | 2 | 1 | 1 | Suppose my labeled data has two classes 1 and 0. When I run predict_proba on the test set it returns an array with two columns. Which column corresponds to which class ? | Python predict_proba class identification | 0 | 0 | 0 | 655 |
28,197,813 | 2015-01-28T16:50:00.000 | 2 | 0 | 0 | 0 | python,statsmodels | 28,202,075 | 1 | true | 0 | 0 | Inference for parameters is the same across models and is mostly inherited from the base classes.
Quantile regression has a model specific covariance matrix of the parameters.
tvalues, pvalues, confidence intervals, t_test and wald_test are all based on the assumption of an asymptotic normal distribution of the estimated parameters with the given covariance, and are "generic".
Linear models like OLS and WLS, and optionally some other models can use the t and F distribution instead of normal and chisquare distribution for the Wald test based inference.
specifically conf_int is defined in statsmodels.base.models.LikelihoodModelResults
partial correction:
QuantReg uses t and F distributions for inference, since it is currently treated as a linear regression model, and not normal and chisquare distributions as the related M-estimators, RLM, in statsmodels.robust.
Most models have now a use_t option to choose the inference distributions, but it hasn't been added to QuantReg. | 1 | 2 | 1 | I am using the statsmodels.formulas.api.quantreg() for quantile regression in Python. I see that when fitting the quantile regression model, there is an option to specify the significance level for confidence intervals of the regression coefficients, and the confidence interval result appears in the summary of the fit.
What statistical method is being used to generate confidence intervals about the regression coefficients? It does not appear to be documented and I've dug through the source code for quantile_regression.py and summary.py to find this with no luck. Can anyone shed some light on this? | statsmodels: Method used to generate condifence intervals for quantile regression coefficients? | 1.2 | 0 | 0 | 843 |
28,200,366 | 2015-01-28T19:05:00.000 | 16 | 1 | 1 | 0 | python-3.x,stringio,cstringio | 50,033,540 | 3 | false | 0 | 0 | I had the same issue because my file was called email.py. I renamed the file and the issue disappeared. | 2 | 97 | 0 | How do I solve an ImportError: No module named 'cStringIO' under Python 3.x? | python 3.x ImportError: No module named 'cStringIO' | 1 | 0 | 0 | 138,242 |
28,200,366 | 2015-01-28T19:05:00.000 | 0 | 1 | 1 | 0 | python-3.x,stringio,cstringio | 68,349,549 | 3 | false | 0 | 0 | I had the issue because my directory was called email. I renamed the directory to emails and the issue was gone. | 2 | 97 | 0 | How do I solve an ImportError: No module named 'cStringIO' under Python 3.x? | python 3.x ImportError: No module named 'cStringIO' | 0 | 0 | 0 | 138,242 |
28,201,859 | 2015-01-28T20:32:00.000 | 2 | 0 | 0 | 0 | python,django | 28,201,899 | 2 | false | 1 | 0 | Migrations are not required. They can be useful for creating and tracking database changes via code, but Django applications will run properly without them. | 2 | 2 | 0 | I want to use Django with nothing but legacy databases. Lots of them. I want to use raw SQL in my model(s).
Do I need migration to make Django function properly? I don't want to use migration because I don't want Django to do anything with or to my databases. I prefer to use SQL and return data. | Is migration required in a Django application? | 0.197375 | 0 | 0 | 228 |
28,201,859 | 2015-01-28T20:32:00.000 | 2 | 0 | 0 | 0 | python,django | 28,201,926 | 2 | true | 1 | 0 | No, you don't need to use migrations.
(Also, it may be relevant to note that you can use raw SQL, but Django will still set up some things for you so you can use its ORM, even with legacy databases. But migrations are not one of these things it does for you.) | 2 | 2 | 0 | I want to use Django with nothing but legacy databases. Lots of them. I want to use raw SQL in my model(s).
Do I need migration to make Django function properly? I don't want to use migration because I don't want Django to do anything with or to my databases. I prefer to use SQL and return data. | Is migration required in a Django application? | 1.2 | 0 | 0 | 228 |
28,202,854 | 2015-01-28T21:35:00.000 | 1 | 0 | 1 | 1 | python-3.x,pip | 28,203,008 | 2 | false | 0 | 0 | In Python 3 the program will be installed as pip3.
So you should be able to find it using which pip3. | 1 | 0 | 0 | Cannot locate PIP in a newly-installed Python3.4 (redhat linux 4) environment.
$ python -V
Python 3.4.1
$ which pip
/usr/bin/which: no pip in (/usr/
$ python -m pip install requests
/usr/local/bin/python3.4: No module named pip
I installed this as an alternate installation and am able to successfully create and run python3.4 scripts. Our other implementation is python 2.3 with no pip.
Any help is greatly appreciated. | Cannot find PIP in a newly-installed Python3.4 (redhat linux 4) environment | 0.099668 | 0 | 0 | 752 |
28,204,071 | 2015-01-28T23:01:00.000 | 23 | 0 | 0 | 0 | python,flask,python-decorators,flask-login | 28,204,335 | 4 | true | 1 | 0 | While there probably won't be any problem in this case no matter what the order, you probably want login_required to execute first so that you don't make queries and paginate results that will just get thrown away.
Decorators wrap the original function bottom to top, so when the function is called the wrapper added by each decorator executes top to bottom. @login_required should be below any other decorators that assume the user is logged in so that its condition is evaluated before those others.
@app.route() must always be the top, outermost decorator. Otherwise the route will be registered for a function that does not represent all the decorators.
The broader answer is that it depends on what each of the decorators are doing. You need to think about the flow of your program and whether it would make logical sense for one to come before the other. | 1 | 15 | 0 | I'm using the login_required decorator and another decorator which paginates output data. Is it important which one comes first? | Does the order of decorators matter on a Flask view? | 1.2 | 0 | 0 | 3,907 |
28,205,527 | 2015-01-29T01:25:00.000 | 2 | 0 | 0 | 1 | python,sockets,http,webserver | 28,205,847 | 1 | false | 0 | 0 | Found it! It is "self.request"!! Confusing style of naming. | 1 | 1 | 0 | In C socket programming at the server-side, after a connection is accepted we can get a handle of the new socket (who is transmitting the data) by "connfd" which is the return value of "accept".
Now I'm trying to implement a web server with Python, I have a handler based on BaseHttpRequestHandler, who handles the requests with the do-Get method.
How can I get ahold of the socket that is transmitting data now (the socket created after the accept and not the one created after bind)?
The reason I need the socket is that I need to read TCP_info from getsockopt with it.
Thanks! | where's the equivalent of connfd (created socket in C) in python's BaseHTTPRequestHandler | 0.379949 | 0 | 1 | 141 |
28,207,166 | 2015-01-29T04:45:00.000 | -2 | 0 | 1 | 0 | list,python-3.x,append | 70,091,548 | 4 | false | 0 | 0 | y = []
[y.append(i) for i in range(10)]
print(y)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | 1 | 7 | 0 | I am trying to append numbers from a generator to an empty list using a single line for loop but it returns None. I understand it can be done using a for loop with 2 lines but I was wondering what I am missing. i.e.,
>>> [].append(i) for i in range(10)
[None, None, None, None, None, None, None, None, None, None]
I was hoping to create this in one line:
>>> [].append(i) for i in range(10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Thank you. | Append to an empty list using a single line for-loop python | -0.099668 | 0 | 0 | 22,106 |
28,215,153 | 2015-01-29T12:46:00.000 | 3 | 0 | 0 | 0 | python | 28,215,366 | 2 | false | 1 | 0 | If you are using Windows i would suggest using Windows Task Scheduler, it's quite simple thanks to the UI and from there Trigger your Python code.
For a server environment like Linux you could set up a Cron task. | 1 | 3 | 0 | I am having a simple python script scraping some data from html page and writing out results to a csv file. How can I automate the scraping, i.e. kick it off every five minutes under Windows.
Thanks
Peter | Run python script every 5 minutes under Windows | 0.291313 | 0 | 1 | 11,625 |
28,215,502 | 2015-01-29T13:05:00.000 | 2 | 0 | 0 | 1 | python,svn,externals | 28,215,771 | 1 | true | 0 | 0 | First of all, don't use sed. Use Python's string methods or the re module.
Second, I recommend to run svn propget ... first, to fetch the old value. Then, you manipulate it (within Python, no need to run sed). Finally, you run svn propset.
Alternatively, you could run a second Python script as editor for svn propedit. Here, too, you don't need sed if you already have Python. | 1 | 0 | 0 | I am currently writing a python script which needs to run a sed command to replace stuff from the svn:externals data.
I tried to run sed on "svn propedit svn:externals ." but the outcome is not the one expected.
Does anyone know how to do this ? | Run replace command on svn:externals (python) | 1.2 | 0 | 0 | 153 |
28,216,315 | 2015-01-29T13:46:00.000 | 0 | 1 | 1 | 0 | php,python,wordpress,amazon-web-services | 28,217,518 | 2 | false | 1 | 0 | If you can run it on the same physical server, you can run it on an EC2 server the same way. There is no difference as far as that is concerned. | 1 | 0 | 0 | I'm running a Python-based application on an AWS instance but now I want to install a Wordpress (PHP) blog as a sub-domain or as a sub-folder as an addition in the application. Is it technically possible to run two different stack applications on a single cloud instance? Currently getting an inscrutable error installing the Wordpress package with the Yum installer. | Running different stacks on same cloud instance | 0 | 0 | 0 | 31 |
28,216,549 | 2015-01-29T13:58:00.000 | 1 | 0 | 0 | 0 | python,django,angularjs,heroku | 28,218,300 | 2 | false | 1 | 0 | There's nothing particularly special about this setup. Angular code is just static files, and can be served from whatever point you want; then the Ajax calls to the REST backend go to the endpoint you determined. | 1 | 5 | 0 | I have a project consisting of the Django Rest Backend and AngularJS frontend. The project root directory contains two folders: backend and frontend, in the first one there is placed the whole Django app and in the second one the Angular frontend app.
Is it possible to deploy such a structure to Heroku in one subdomain. To be precise, I want to have urls like this:
myapp.heroku.com - which will load the whole Angular project frontend
myapp.heroku.com/backend - which will be the Rest API endpoint
How to deploy both apps on Heroku to obtain such a solution? Or maybe you have any other suggestions concerning the project structure and deployment? | Django + Angular deployment on Heroku | 0.099668 | 0 | 0 | 2,836 |
28,222,797 | 2015-01-29T19:17:00.000 | 1 | 0 | 0 | 0 | python,rest,twilio | 28,222,877 | 2 | false | 0 | 1 | This is where Twilio gets tricky. Technically the call is picked up instantly, so there is no timeout to let it ring.
What you can do, is initialize the phone call with a timeout, and using the Play verb, use an MP3 recording of the standard ring before letting the program do it's thing. | 1 | 0 | 0 | I have just started using twillio. Im not sure if its the right tool for what I am trying.
Currently if I dial my number, there is no ring, it just picks up straight away. The reason I am mentioning this is because I would like it to first ring before it picks up. So my user can actually put down the phone before the call is connected and the person is billed.
Is this possible? My number is new, nothing has been setup or done to it. | Letting twillio ring before it picks up | 0.099668 | 0 | 0 | 91 |
28,225,600 | 2015-01-29T22:10:00.000 | 3 | 0 | 0 | 0 | python,image,image-processing,matplotlib,scipy | 28,225,707 | 1 | true | 0 | 0 | I think I've figured out why. By convention, floats in skimage are supposed to be in the range [0, 1]. | 1 | 1 | 1 | I have an array of graysale image read in from a color one. If I use matplotlib to imshow the grayscale image, it looks just fine. But when I io.imsave it, it's ruined (by an outrageous amount of noise). However, if I numpy.around it first before io.imsave-ing, then it's significantly better, but black and white are still all swapped (dark regions appear white, and bright regions appear dark)
scipy.misc.imsave, on the other hand, works perfectly.
Thank you. | skimage.io.imsave "destroys" grayscale image? | 1.2 | 0 | 0 | 998 |
28,226,283 | 2015-01-29T22:58:00.000 | -3 | 0 | 1 | 0 | python,deployment | 28,262,034 | 2 | false | 0 | 0 | So the question is how do I solve this?
You have not solve this problem anyhow. There is no any method to describe external dependencies outside of python ecosystem in setup.py. Just provide it in a README. | 1 | 7 | 0 | For python applications that install with pip, how can you handle their C extension requirements automatically?
For example, the mysqlclient module requires development libs of MySQL installed on the system. When you initially install an application requiring that module it'll fail if the MySQL development libraries are not on the system. So the question is how do I solve this?
Is there a way to solve this with setup.py already that I do not know about?
If not am I supposed to use a pure python module implementation?
Note; I'm not looking for answers like "just use py2exe". | How to handle C extensions for python apps with pip? | -0.291313 | 0 | 0 | 371 |
28,228,383 | 2015-01-30T02:41:00.000 | 17 | 0 | 1 | 0 | python,utf-8 | 28,228,471 | 2 | true | 0 | 0 | "\n" is the class Unix/linux style for new line.
"\r\n" is the default Windows style for line separator.
"\r" is classic Mac style for line separator.
I think "\n" is better, because this also looks good on windows, but some "\r\n" may not looks so good in some editor under linux, such as eclipse or notepad++.
If you are handling some protocols, the "\r\n" is usually required. | 1 | 14 | 0 | I have a script that sometimes prints a newline as \n and sometimes uses \r\n. What is the difference between the two, and is one preferable over the other? | Difference between \n and \r\n in python | 1.2 | 0 | 0 | 46,931 |
28,228,431 | 2015-01-30T02:48:00.000 | 0 | 0 | 0 | 0 | python,pygame,collision | 28,228,513 | 1 | true | 0 | 1 | What you are looking for is functionality usually provided by a so-called physics engine. For very basic shapes, it is simple enough to code the basic functionality yourself. (The simplest case for 2D shapes is the collision detection between circles).
Collision detection gets pretty hard pretty quickly, especially if you want to do it at a reasonably fast rate (such as you would need for the sort of project you are describing) and also especially if you are dealing with arbitrary, non-regular shapes (which your description seems to indicate). So, unless you are interested in learning how to code an optimized collision detection system, I suggest you google for python physics engines. I have never used any, so I can't personally recommend one.
Good luck! | 1 | 0 | 0 | I have a pygame program where there's a face in the center. What I want the program to do is have a bunch of objects on the screen, all irregular. Some would be circles, others would be cut-out pictures of objects like surf boards, chairs, bananas, etc. The user would be able to drag the objects around, and they'd collide with each other and the face in the center, and so be unable to pass through them. Could anyone show me how I would do this? Thanks!
-EDIT- And by not be able to pass through, I mean they'd move along the edge of the object, trying to follow the mouse. | Pygame image collision | 1.2 | 0 | 0 | 123 |
28,229,010 | 2015-01-30T03:57:00.000 | 5 | 0 | 1 | 0 | python-2.7,logging,ide,anaconda,spyder | 28,279,767 | 2 | false | 0 | 0 | (Spyder dev here) Well, there is a way to save the output shown in our consoles but not after each execution. You have to do it manually, like this:
For our Python consoles, you need to do a right mouse click over any console and select the option Save history log.
For our IPython consoles, you need to do a right mouse click over any console and select the option Save as HTML/XML | 2 | 5 | 0 | I use Spyder as my Python IDE. In most of what I do I use the editor to write code and execute portions of the program one at a time. I typically go back and forth, change things, add pieces, execute portions... you get it. Is there a way to save to file what Spyder shows in the console portion of the IDE after each portion of code is executed? | How can save to file the on screen output of a Python IDE? | 0.462117 | 0 | 0 | 10,295 |
28,229,010 | 2015-01-30T03:57:00.000 | 0 | 0 | 1 | 0 | python-2.7,logging,ide,anaconda,spyder | 39,460,738 | 2 | false | 0 | 0 | One way to capture entire console output of Sypder IDE:
1. Go to "Profile" (Shortcut: F10) under "Run" Tab.
2. On Right hand side, you can see Run, Stop and Output buttons.
3. Click on Run and the entire console session is captured under Output.
Hope, this helps. Kindly correct me if I am wrong. | 2 | 5 | 0 | I use Spyder as my Python IDE. In most of what I do I use the editor to write code and execute portions of the program one at a time. I typically go back and forth, change things, add pieces, execute portions... you get it. Is there a way to save to file what Spyder shows in the console portion of the IDE after each portion of code is executed? | How can save to file the on screen output of a Python IDE? | 0 | 0 | 0 | 10,295 |
28,230,528 | 2015-01-30T06:40:00.000 | 0 | 0 | 1 | 1 | python,python-2.7,cygwin | 28,230,732 | 2 | false | 0 | 0 | No, you don't need to do so. In fact, CYGWIN will inherit the PC's PATH, plus with virtual PATH, you can input "echo $PATH" in CYGWIN and input "PATH" and the windows console, you could find that CYGWIN has more PATH setting than the windows. However, as you already overwrite the bash_profile, so it might not looks as what I said.
Besides, the most significant difference is that most of the CYGWIN executable files depends on CYGWIN.dll, while the typically windows files don't. | 1 | 0 | 0 | I would like to know the difference in
installing Python, Paramiko packages in Cygwin and
Python is already installed in my Windows PC. I have installed Cygwin too (but without Python package) and in Cygwin terminal I do the following:
$echo "PATH=\$PATH:/cygdrive/c/Python27" >> .bash_profile
then,
source .bash_profile (after doing this I am able to run a Python script from cygwin terminal).
If the steps in point number 2 works good, then still do I need to install python packages from a Cygwin mirror site ? If I have not done it, then what I might miss while running Python through Cygwin ?
Thanks for your help. | Python in Cygwin | 0 | 0 | 0 | 1,910 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.