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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
30,204,877 | 2015-05-13T02:58:00.000 | 1 | 0 | 0 | 0 | python,opencv,svm | 30,208,490 | 1 | false | 0 | 0 | The classic SVM does part the n-dimensional feature space with planes. That means every point in space is in one of the partitions and therefore belongs to one of the trained classes. there is no outlier detection.
However there is also the concept of a one-class SVM that tries to encapsulate the "known" space and classifies into "known" and "unknown". The libSVM package also has probabilities, you could try to analyse if that helps. You could also try other classification concepts to detect outliers like nearest neighbour | 1 | 0 | 1 | I try to make classification multiclass with SVM on OpenCV (I use openCV for python). Let's say if I have 5 class and training it well. I have been test it, and got good result.
The problem appear when object from 6th class come to this classification. Althought I haven't train this class before, why I got result this object (that come from 6th class) recognize as object from one of the class that I have been train before (It classified as member of 1st,or 2nd, ect class). While machine should say didn't know it from what class. SVM at OpenCV didn't return the probability, it just return the label of the class.
I have an idea to make it 2 times classification. First with biner classification, with all of the sample as the training set. Second I classify it to multiclass.
But the problem, how should I find the negative sample for the first classification while I didn't know the other object (let's say that come from 6th or 7th class). Anybody can help me, what should I do? Which samples that should I use as Negative Sample? It is the great idea or stupid idea? Is there other way to solve this problem? | SVM find member of outside training set | 0.197375 | 0 | 0 | 87 |
30,207,296 | 2015-05-13T06:33:00.000 | 1 | 0 | 1 | 0 | python,ipython,anaconda,pythonpath,sys.path | 30,208,369 | 1 | false | 0 | 0 | .bashrc is read by "interactive" shells (when you start your terminal containing bash). Running Anaconda Spyder's Ipython doesn't start any interactive shell.
You have to setup your PYTHONPATH on "login" by specifying it in your .profile (you'll have to logout/login to make chages effective). | 1 | 1 | 0 | There are some modules I want to be able to import when I use IPython. I use IPython from the command line sometimes, and I also use IPython from Anaconda Spyder sometimes. I appended the PYTHONPATH environment variable in my .bashrc file to include the directory that contains the modules I want to import.
Now, when I start IPython at the command line, everything works fine. If I import sys, and type sys.path, the new directory I included is there.
However, when I do the same thing in Anaconda Spyder's Ipython, the sys.path is slightly different (has some extra directories) and does not contain the newly added directory with my modules.
Why is this? | Difference between Spyder IPython and "normal" IPython sys.path | 0.197375 | 0 | 0 | 1,951 |
30,207,646 | 2015-05-13T06:53:00.000 | 1 | 1 | 1 | 0 | python,unit-testing,testing,pytest | 30,207,881 | 1 | true | 0 | 0 | Testing helper functions makes a lot of sense - in this context, these helper functions are the basic building blocks (read: units) for your application. Having tests that prove that they function properly will allow you to easily change their implementation without worrying about whether you're breaking something else or not. The other direction is also true - suppose you did break one of the helper functions. You'd want a simple test to show you the mistake you made, without having to dig through the complicated implementation of the "public" functions to understand why their tests have been broken. | 1 | 1 | 0 | I am writing a small command line tool in python, which has two subcommands (like: git init or git clone). Those subcommands use a few helper functions, which are not exposed on the command line. When writing tests with py.test, does it make sense to test every helper function separately or only test the two functions for the subcommands (they call all the helpers multiple times). | Should I test helper functions or only the main function? | 1.2 | 0 | 0 | 1,214 |
30,208,421 | 2015-05-13T07:31:00.000 | 0 | 0 | 0 | 1 | python,web2py | 30,356,551 | 1 | false | 1 | 0 | Just use the file system.
GUI:
Copy your application folder to your new instance of web2py (/web2py/applications).
Command line:
scp -r /home/username/oldarea/web2py/application/myApp /home/username/newarea/web2py/applications | 1 | 2 | 0 | I am new to web2py I have web2py application in my local system i want to upload this application into web2py environment throught admin interface option present in web2py Upload & install packed application and do some modifications and run the application but i am unable to uploded the app please give the suggesations how to do this
Thanks in advance | how to upload the existing app in to web2py environment | 0 | 0 | 0 | 724 |
30,211,422 | 2015-05-13T09:57:00.000 | 1 | 0 | 0 | 0 | python,date,datetime,time,timezone | 30,234,068 | 1 | true | 0 | 0 | You should either convert the time to the time zone of the client, or show the time zone. I e, for a client in Warsaw show
"2015-05-14 11:40" or "2015-05-14 09:40 GMT" or similar.
Which one you want depends a lot on what data it is you are showing.
How to figure out the client timezone is a long topic that probably is covered elsewhere here, and that again depends on the application. You can convert it with Javascript, or have a setting, or make a guess based on countr and IP address, etc. Loads of options. | 1 | 1 | 0 | I'm using time and datetime modules in server and in client scripts. When I am receiving data that contains date from server - it is wrong and different to client because of wrong timezone and wrong time on server.
How to deal with it and what is the best way to deal with it?
Thanks | Server and client are python scripts, are there a way to synchronize server to client time without changing system dates anywere? | 1.2 | 0 | 1 | 197 |
30,213,356 | 2015-05-13T11:22:00.000 | 3 | 0 | 0 | 1 | python,concurrency,celery | 30,216,495 | 1 | true | 0 | 0 | To put it simply concurrency is the number of jobs running on a worker. Prefetch is the number of job sitting in a queue on a worker itself. You have 1 of 2 options here. The first is to set the prefetch multiplier down to 1. This will mean the worker will only keep, in your case, 8 additional jobs in it's queue. The second which I would recommend would be to create 2 different queues one for your short running tasks and another for your long running tasks. | 1 | 3 | 0 | In an environment with 8 cores, celery should be able to process 8 incoming tasks in parallel by default. But sometimes when new tasks are received celery place them behind a long running process.
I played around with default configuration, letting one worker consume from one queue.
celery -A proj worker --loglevel=INFO --concurrency=8
Is my understanding wrong, that one worker with a concurrency of 8 is able to process 8 tasks from one queue in parallel?
How is the preferred way to setup celery to prevent such behaviour described above? | how to configure celery executing tasks concurrently from on queue | 1.2 | 0 | 0 | 1,110 |
30,215,568 | 2015-05-13T13:00:00.000 | 0 | 0 | 0 | 0 | python,xml,django,curl | 30,215,688 | 1 | true | 1 | 0 | request.body should contain the XML as string.
I tried using curl, but the data I get on the Django side becomes a
dictionary
Can you please share the code blocks to receive/print the data? | 1 | 0 | 0 | How can I send an xml file to a Django app server from a command line interface?
I tried using curl, but the data I get on the Django side becomes a dictionary and doesn't look like xml. In addition to that I need some basic authorization mechanism. I tried curl examples, but to no avail. Maybe I am expecting the wrong thing. Can someone guide me to the right tutorial or examples. | Send a XML file with authorization to a django app | 1.2 | 0 | 1 | 238 |
30,218,802 | 2015-05-13T15:07:00.000 | 0 | 0 | 1 | 0 | python,sys,sys.path | 55,073,298 | 9 | false | 0 | 0 | You can simply use../your_script_name.py
For example suppose the path to your python script is trading system/trading strategies/ts1.py. To refer to volume.csv located in trading system/data/. You simply need to refer to it as ../data/volume.csv | 1 | 76 | 0 | I want to get the parent of current directory from Python script. For example I launch the script from /home/kristina/desire-directory/scripts the desire path in this case is /home/kristina/desire-directory
I know sys.path[0] from sys. But I don't want to parse sys.path[0] resulting string. Is there any another way to get parent of current directory in Python? | Get parent of current directory from Python script | 0 | 0 | 0 | 163,627 |
30,219,148 | 2015-05-13T15:23:00.000 | 2 | 0 | 1 | 0 | python,ipython,ipython-magic | 69,082,644 | 2 | false | 0 | 0 | %reset_selective accepts RegEx.
If you have variables named as: glob_x, glob_y, glob_z which you don't want to reset, you can use: %reset_selective -f ^(?!glob_).*$ | 1 | 7 | 0 | I'm aware of the %reset and %reset_selective commands in IPython. However, let's say you have many variables and you want to clear all variables except x, y, z. Is there a concise way to accomplish this?
Say a %reset_all_except x,y,z? | Clear all except for a few specific variables in IPython | 0.197375 | 0 | 0 | 2,642 |
30,221,772 | 2015-05-13T17:39:00.000 | 0 | 0 | 0 | 0 | python,websocket,server,capacity | 30,222,997 | 2 | false | 1 | 0 | One of solutions could be Pyramid, sockjs, gunicorn, and gevent. Nginx probably better suits to be a frontend than Apache, but of course if you do not have any lengthy processing on the backend, any decent asynchronous Python server with websocket and sockjs support (not sure about socket.io as an alternative) will work for you out of the box.
Lenghty processing should be offloaded to some queue workers anyway, so asynchronous server will fit the bill.
Just check whether all used datastore/database adapters are compatible with your server solution be it asynchronous or multi-threading. | 1 | 0 | 0 | I am new at Server side,
but I have gotten a chance to design and implement a server that will cover around 2000~3000 client.
And I am thinking that I will use Python and Websocket, though I don't know this choice is appropriate.
In this point, I am curious on how to design the server.
I think there must be some architecture normally in use depending on capacity that server handles.
Otherwise, Could I use a Websocket server offered by some python package like Tornado or Django?
I hope that I can get any information on this.
Any advice? | Server architecture depending on the capacity | 0 | 0 | 1 | 117 |
30,222,389 | 2015-05-13T18:15:00.000 | 0 | 0 | 0 | 0 | python,xlsx,xlsxwriter | 30,227,506 | 1 | false | 0 | 0 | But is there any way of calculating the sum value in memory.
Not with XlsxWriter since it doesn't have a calculation engine like Excel.
However, if you only need to do a sum then you could do that in Python. | 1 | 1 | 0 | I have a scenario in which I am writing formula for calculating the sum of values of different cells in xlsx. After calculating the sum I write it into different cell. I am doing this in python and for xlsx writing I am using xlsxwriter.
For writing values I am using inmemory option for xlsxwritter and then I am reading it using xlrd by passing in memory string buffer to its constructor but when I am accessing the cell in which sum is written I am getting 0. I understand why this is happening. But is there any way of calculating the sum value in memory. So that when I read it I get the calculated sum using formula. | How to trigger calculation of formula in xlsx while writing value cell | 0 | 1 | 0 | 505 |
30,223,012 | 2015-05-13T18:50:00.000 | 0 | 0 | 1 | 1 | python,macos,keyboard | 66,572,892 | 3 | false | 0 | 0 | Calling xkbswitch from python using subprocess would probably be easier than the other solutions you find here. | 1 | 2 | 0 | I wrote python software that requires both german and english input. Currently, I am using the Mac shortcut cmd-space to quickly change keyboard layouts, but I need to do this hundreds of times, which slows things down. Since I know exactly when English vs German input is needed, is there a way to programmatically change the keyboard language in python?
I am using Mac OS X Yosemite. | python changing keyboard language in Mac OS X | 0 | 0 | 0 | 765 |
30,225,539 | 2015-05-13T21:33:00.000 | 0 | 0 | 0 | 0 | python,numpy,matrix | 30,227,232 | 3 | false | 0 | 0 | C = A[:,:,0]*(B==0) + A[:,:,1]*(B==1) should work. You can generalize this as np.sum([A[:,:,k]*(B==k) for k in np.arange(A.shape[-1])], axis=0) if you need to index more planes. | 1 | 3 | 1 | I have a tensor A such that A.shape = (32, 19, 2) and a binary matrix B such that B.shape = (32, 19). Is there a one-line operation I can perform to get a matrix C, where C.shape = (32, 19) and C(i,j) = A[i, j, B[i,j]]?
Essentially, I want to use B as an indexing matrix, where if B[i,j] = 1 I take A[i,j,1] to form C(i,j). | Indexing tensor with binary matrix in numpy | 0 | 0 | 0 | 338 |
30,231,345 | 2015-05-14T07:06:00.000 | 0 | 1 | 0 | 1 | python,debian,raspberry-pi | 30,232,512 | 2 | false | 0 | 0 | you can not do this.
font size is determined by terminal emulator not program output. | 1 | 0 | 0 | How do I set font size for Python console application?
I'm running Debian Wheezy on a Raspberry Pi.
When the program is exited return to default size. | debian wheezy console application set font size | 0 | 0 | 0 | 153 |
30,233,406 | 2015-05-14T09:09:00.000 | -1 | 0 | 0 | 0 | python-2.7,caching,python-requests | 30,299,626 | 2 | true | 0 | 0 | For anyone else searching, the module that does the job is called "vcrpy". | 1 | 2 | 0 | Is there a way to "cache" the requests I make with the python "requests" module in a way that even if I go offline the module still returns the webpage as if I was online? How can I achieve something like this? Currently I only found caching libraries that just cache the webpage but you still have to be online... | Caching python web requests for offline use | 1.2 | 0 | 1 | 568 |
30,234,706 | 2015-05-14T10:14:00.000 | 0 | 0 | 0 | 0 | python,mysql,flask,sqlalchemy | 30,238,066 | 1 | false | 0 | 0 | If I understand correctly your from_date and to_date are just dates. If you set them to python datetime objects with the date/times you want your results between, it should work. | 1 | 0 | 0 | I am using sqlalchemy to query memory logs off a MySql database. I am using:
session.query(Memory).filter(Memmory.timestamp.between(from_date, to_date))
but the results after using the time window are still too many.
Now I want to query for results withing the time window, but filtered down by asking for entries logged every X minutes/hours and skipping the ones between, but cannot find a simple way to do it.
To further elaborate, lets say the 'l's are all the results from a query in a given timewindow:
lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
To dilute them, I am looking for a query that will return only the 'l's every X minutes/hours so that I am not overwhelmed:
l......l......l.....l......l......l......l.....l.....l.....l.
I could get everything and then write a function that does this, but that beats the purpose of avoiding choking with results in the first place.
Sidenote:
Worse comes to worse, I can ask for a row after skipping a predifined number of rows, using mod on the row id column. But it would be great to avoid that since there is a timestamp (DateTime type of sqlalchemy).
Edit:
There could be some value using group by on timestamp and then somehow selecting a row from every group, but still not sure how to do this in a useful manner with sqlalchemy. | How to query rows with a minute/hour step interval in SqlAlchemy? | 0 | 1 | 0 | 587 |
30,235,427 | 2015-05-14T10:49:00.000 | 0 | 0 | 1 | 1 | python,command-prompt,prompt | 30,237,541 | 2 | false | 0 | 0 | There are multiple ways to go about this. As Sir_FZ pointed out, the executables are already named python2.7, etc, so what you want already exists. If for some really odd reason you have more than one python2.7 in your $PATH, you can explicitly call /my/other/python2.7 etc. If you're lazy, you can even create alias's alias p2=/my/other/python2.7 and then you can call p2 setup.py install
If you're going to be doing this for more than a day, I'd suggest following one of Sagar's links. | 1 | 0 | 0 | I have several python versions installed (and working properly on my machines). Isn't there a way to execute a specific version of python from the command line.
Say I want to use python 3.1. I am after something a SIMPLE COMMAND such as python3.1 or python31 that would be used as follows :python3.1 setup.py install, for instance.
[pip has pip3.1 to install a library with the version 3.1 of python, specifically] | Select python version to execute from prompt | 0 | 0 | 0 | 79 |
30,238,648 | 2015-05-14T13:29:00.000 | 0 | 0 | 1 | 0 | python,multithreading | 30,239,341 | 1 | false | 0 | 0 | Because you can't be sure, when scheduler will switch threads. Consider SMP machine. It will always process one thread at a time. But nevertheless multithreaded code should use semaphores, mutexes, critical sections and other synchronization primitives.
Although CPython have GIL and can't execute more then one thread at a time, there can be other implementation without such a limitation. Also, even with GIL present, from thread POV all your threads are running simultaneously. You can't write piece of code that will prove opposite (yes, you can ask OS about this, but it is a cheating).
Strictly speaking, semaphore is used not for sending signals to other threads, but to protect access to a limited number of resources. For example, you can have 5 printers and 10 threads that want to print. You will have one Semaphore initialized with value 5 and it will protect access to your printers. So at any moment no more than 5 threads will print something.
Another example is connection pool. For example you have pool of N connections to DB. This means that no more than N threads can simultaneously execute queries to DB. In this case you will have Semaphore initialized with N. (N+1)'th thread will block on Semaphore and will wait for free connection. | 1 | 1 | 0 | Python threading module do not realize true parallel programming. Threads were switched one another. Then, is Semaphore necessary? Semaphore is for sending signal to other threads that should be processed at the same time. I think it is only useful in multiprocessing. Why is the Semaphore Class in threading module? | The need of semaphore in python threading module | 0 | 0 | 0 | 431 |
30,239,152 | 2015-05-14T13:51:00.000 | 36 | 0 | 1 | 0 | python,git,pip | 45,532,721 | 4 | false | 0 | 0 | Important to notice: you should not have whitespaces around or within brackets. I.e. this will work: -e ".[extra1,extra2]" but this won't: -e ". [extra1, extra2]" - and even as a row in requirements.txt file, where it is not so obvious. The worst thing about it is that when you have whitespace, extras are just silently ignored. | 1 | 94 | 0 | How can one manage to install extras_requires with pip when installing from a git repository ?
I know that you can do pip install project[extra] when the project is on pypi.
And you have to do pip install -e git+https://github.com/user/project.git#egg=project for a git repo but I didn't manage to find how to link these two options together. | Specify extras_require with pip install -e | 1 | 0 | 0 | 27,417 |
30,242,603 | 2015-05-14T16:36:00.000 | 0 | 0 | 0 | 0 | python,pandas | 30,242,748 | 1 | true | 0 | 0 | I believe the file you are loading is far to large reference what your computer can handle. Unless you need to load all the data at once, I would try to load the data based on what you need at that time e.g., load data based on a specific criteria then run your program over those specifics. This should help with the two things. First, you will be able to load your data and run your program. Second, your program will run faster as it is only working on subsets of data at a time. | 1 | 0 | 1 | I am reading a 5 G file on my 8G memory MacBook : pd.read_csv(filepath).
I see the memory usage going to 12 G (orange, then red), and then suddenly the memory usage drops back to 6G, and then slowly goes back up.... And my script doesn't deliver anything, not even an exit error....
What can happen ? Seems like python is completely blocked (ventilator are very silencious...) | Pandas is blocking python when it reads big file | 1.2 | 0 | 0 | 54 |
30,244,222 | 2015-05-14T18:02:00.000 | 1 | 1 | 1 | 0 | python,vim,python-import | 30,245,587 | 1 | true | 0 | 0 | Vim does not automatically search the current script's directory for imports, only some configured ones (cp. :help python-_get_paths), and the current working directory.
So, you either need to configure the current script's path, or simply :cd %:h to it (alternatively automatically via :set autochdir). | 1 | 1 | 0 | I am using gVim with Windows 7.
I am trying to run a python script using the pyfile % command, but every time I do so, I get ImportError: No module named libtcodpy
Checking the location of the libtcodpy, it is indeed in the same folder as the script I am trying to run. Furthermore, running the program with the python IDE works fine.
What am I doing wrong? | gVim ImportErrror: module not found, even though module is in same folder as script | 1.2 | 0 | 0 | 62 |
30,249,063 | 2015-05-14T23:22:00.000 | 0 | 1 | 0 | 0 | python,linux,performance,ubuntu,analytics | 30,249,116 | 2 | false | 0 | 0 | If you just want to know how long a process takes to run the time command is pretty handy. Just run time <command> and it will report how much time it took to run with it counted in a few categories, like wall clock time, system/kernel time and user space time. This won't tell you anything about which parts of the system are taking up the amount of time. You can always look at a profiler if you want/need that type of information.
That said, as Barmar said, if you aren't doing much processing of the sites you are grabbing, the laptop is probably not going to be a limiting factor. | 2 | 0 | 0 | I created a python script that grabs some info from various websites, is it possible to analyze how long does it take to download the data and how long does it take to write it on a file?
I am interested in knowing how much it could improve running it on a better PC (it is currently running on a crappy old laptop. | Is it possible to see what a Python process is doing? | 0 | 0 | 0 | 238 |
30,249,063 | 2015-05-14T23:22:00.000 | 0 | 1 | 0 | 0 | python,linux,performance,ubuntu,analytics | 30,249,196 | 2 | false | 0 | 0 | You can always store the system time in a variable before a block of code that you want to test, do it again after then compare them. | 2 | 0 | 0 | I created a python script that grabs some info from various websites, is it possible to analyze how long does it take to download the data and how long does it take to write it on a file?
I am interested in knowing how much it could improve running it on a better PC (it is currently running on a crappy old laptop. | Is it possible to see what a Python process is doing? | 0 | 0 | 0 | 238 |
30,250,032 | 2015-05-15T01:19:00.000 | 0 | 0 | 0 | 0 | python,django,superuser | 71,642,770 | 3 | false | 1 | 0 | The password is usually hidden in your IDE so it is not showing up when you're typing it out.
Just type the password press enter and re-enter the same thing.
Hope this solves the problem. | 2 | 1 | 0 | I am learning django, and I have a mysite folder. When I synced the database it prompted me to create a superuser. I typed yes, and got halfway through the forms but I couldn't enter any characters when it wanted a password. I searched google and found:
python manage.py createsuperuser
The same thing happened, I could not enter a password. I am using django 1.5 and python 2.7 in case you need to know. | Django createsuperuser cannot enter password | 0 | 0 | 0 | 3,933 |
30,250,032 | 2015-05-15T01:19:00.000 | -1 | 0 | 0 | 0 | python,django,superuser | 70,849,579 | 3 | false | 1 | 0 | Operations to perform:
Apply all migrations: admin, admin_interface, auth, contenttypes, myapp, sessions
Running migrations:
Applying myapp.0002_alter_student_id... | 2 | 1 | 0 | I am learning django, and I have a mysite folder. When I synced the database it prompted me to create a superuser. I typed yes, and got halfway through the forms but I couldn't enter any characters when it wanted a password. I searched google and found:
python manage.py createsuperuser
The same thing happened, I could not enter a password. I am using django 1.5 and python 2.7 in case you need to know. | Django createsuperuser cannot enter password | -0.066568 | 0 | 0 | 3,933 |
30,250,282 | 2015-05-15T01:52:00.000 | 18 | 0 | 1 | 0 | python,object,collections,attributes,member | 30,250,337 | 4 | false | 0 | 0 | . is used for accessing attributes (including methods). [] is used for accessing what are called "items", which typically are the contents of various kinds of container objects.
JavaScript does not distinguish these two things, but Python does. You are correct that [] is used for accessing the data in a list or dict. . is used, for instance, for accessing methods like list.append and dict.update. It is also used for accessing other data on other kinds of objects; for instance, compiled regular expression objects have a pattern attribute holding the regex pattern (you would access it with rx.pattern).
In general, the convention is that [] is used for "open-ended" data storage where you don't know ahead of time how much or what sorts of data the object will hold; . is more commonly used for specific data that the object has "by nature" and which is accessed with a predefined name. For instance, just knowing that something as a list doesn't tell you what's in it (for which you use []), but it does tell you that you can append to it (and to access the append method you use .).
The other major difference between Python and JavaScript in this regard is that in Python, the behavior of both . and [] can be customized by the object. So obj.foo or obj[foo] may do something special if obj is an object that defines its own behavior for them. There are various custom types that make use of this for their own purposes. | 1 | 59 | 0 | I come from a Javascript background (where properties can be accessed through both . and [] notation), so please forgive me, but what, exactly, is the difference between the two in Python?
From my experimentation it seeems that [] should always be used, both to get the index of a list or set and to get the value from a certain key in a dictionary. Is this correct, and, if not, when do you use a . in Python? | What's the difference between the square bracket and dot notations in Python? | 1 | 0 | 0 | 28,003 |
30,252,726 | 2015-05-15T06:14:00.000 | 1 | 0 | 0 | 0 | python,django,pdf,pisa | 30,345,810 | 2 | false | 1 | 0 | I did few changes in html which results pisa.createPDF works fast for me.
I am using html of almost 2 MB, contains single table with almost more than 10,000 rows. So I break them into multiple tables and tried again. Its surprised me, initially with single table it took almost 40 minutes (2590 seconds) to generate PDF and with multiple tables it has taken only 80 Seconds. | 1 | 2 | 0 | I am generating pdf using html template with python pisa.CreatePDF API,
It works well with small html, but in case of huge html it takes lot of time. Is there any alternative ? | pisa.CreatePDF hangs with huge html file | 0.099668 | 0 | 0 | 1,230 |
30,252,859 | 2015-05-15T06:24:00.000 | 1 | 0 | 1 | 0 | python,multithreading,greenlets | 31,060,865 | 1 | false | 0 | 0 | Greenlets stay within a single thread in Python. They cannot jump into another thread. So if your code is properly thread-safe, it will be greenlet safe.
Another way to look at it is that greenlets execute only one at a time, so you have very little issues like you have with threads. | 1 | 0 | 0 | The situation I have in mind is using a python extension module that can call back into python, so that there may be a mixture of python and non-python stack frames at the point when a greenlet yields.
I assume that if a module uses thread-local storage it is likely to misbehave with greenlets.
Is there any other reason why a thread-safe module might not be greenlet-safe?
Edit: what I really want to know is whether there is any difference between the way context switches are implemented for greenlets vs. regular threads. Do greenlets take any shortcuts that might work for python but break for some kinds of extension module? | Does thread-safe generally imply greenlet-safe in Python? | 0.197375 | 0 | 0 | 610 |
30,253,976 | 2015-05-15T07:32:00.000 | 0 | 0 | 0 | 0 | python,csv,pandas,pickle | 30,254,159 | 4 | false | 0 | 0 | Dont load 800MB file to memory. It will increase your loading time. Pickle objects too takes more time to load. Instead store the csv file as a sqlite3 (which comes along with python) table. And then query the table every time depending upon your need. | 1 | 5 | 1 | I am reading a 800 Mb CSV file with pandas.read_csv, and then use the original Python pickle.dump(datfarame) to save it. The result is a 4 Gb pkl file, so the CSV size is multiplied by 5.
I expected pickle to compress data rather than extend it. Also because I can do a gzip on the CSV file which compress it to 200 Mb, dividing it by 4.
I am willing to accelerate the loading time of my program, and thought that pickling would help, but considering disk access is the main bottleneck I am understanding that I would rather have to compress the files and then use the compression option from pandas.read_csv to speed up the loading time.
Is that correct?
Is it normal that pickling pandas dataframe extend the data size?
How do you speed up loading time usually?
What are the data-size limit would you load with pandas? | Pickling pandas dataframe multiplies by 5 the file size | 0 | 0 | 0 | 7,611 |
30,255,307 | 2015-05-15T08:51:00.000 | 2 | 0 | 1 | 0 | python | 30,255,380 | 2 | false | 0 | 0 | To quote the documentation:
Return the size of an object in bytes. The object can be any type of object. All built-in objects will return correct results, but this does not have to hold true for third-party extensions as it is implementation specific.
Built in strings are not simple character sequences - they are full fledged objects, with garbage collection overhead, which probably explains the size discrepancy you're noticing. | 1 | 2 | 0 | What does sys.getsizeof return for a standard string? I am noticing that this value is much higher than what len returns. | What does python sys getsizeof for string return? | 0.197375 | 0 | 0 | 5,866 |
30,261,689 | 2015-05-15T14:12:00.000 | 2 | 0 | 1 | 0 | python,spyder | 30,276,162 | 1 | false | 0 | 0 | The consoles both python and ipython, when executing code have a stop button in the top right corner of the panes.
The debug button has no business with that as you rightly said it is for debugging, so unless you are debugging you should not expect it to stop a non debugging session. | 1 | 4 | 0 | I'd like to stop code while running in Spyder, but ctrlc/ ctrlz nor cmdc/ cmdz does not work for me, even the blue stop button (normally used for debug).
I work under Yosemite 10.10.3 and am using Spyder 2.3.4 and Python 2.7
Has someone encountered the same issue? | Stopping running code | 0.379949 | 0 | 0 | 17,571 |
30,261,701 | 2015-05-15T14:12:00.000 | 1 | 1 | 0 | 0 | python,unix,path | 30,261,822 | 2 | true | 0 | 0 | Python doesn't share its own path with the general $PATH, so to be able to do what you're looking for, you must add your scripts in the $PYTHONPATH instead. | 1 | 0 | 0 | I have a collection of python scripts that import from each other. If I want to use these in a location where the scripts are not physically present, how can I do this. I tried adding the path of the dir with the scripts to my $PATH but got no joy. Any help appreciated, thanks. | Calling python scripts from anywehre | 1.2 | 0 | 0 | 52 |
30,264,100 | 2015-05-15T16:10:00.000 | 0 | 0 | 1 | 0 | python,virtualenv,zipline | 45,375,832 | 3 | false | 0 | 0 | These are the Requirements/ Steps to Make Zipline Work:
Install Microsoft Visual C++ 2010 Express
Download and install python 3.4
Download zipline from github and Extract in C:/
Set Anaconda as project interpreter
Since zipline is compatible with Python 3.4, you need to create an environment with Python 3.4
Run this command in console of IDE:
$conda create -n python34 python=3.4 anaconda(replace py34 with the location of python34 folder)
Now run this command in console:
$activate python34 #Activates the python 3.4 environment
$pip install -e C:\GitHub\zipline (Directory where you extracted zipline)
Ingest data from quandl with below command
$zipline ingest
Hope this helps others who visit this page! | 2 | 3 | 0 | I installed zipline package via Enthought Cantopy. Now I try to run a script using it in command prompt, but get error ImportError: No module named zipline.
I also tried to run the same code using IPython, with the same output.
I think it is related to python virtual environments, but don't know how to fix that. | zipline error. No module named zipline | 0 | 0 | 0 | 2,894 |
30,264,100 | 2015-05-15T16:10:00.000 | 2 | 0 | 1 | 0 | python,virtualenv,zipline | 30,345,896 | 3 | true | 0 | 0 | I figured it out. The problem was in the version of python I have. I have 32-bit python and Enthought Cantopy with 64 bit python, installed zipline package was under 64 bit python while command prompt was using 32 bit version. Installing 64 bit python fixed the issue. | 2 | 3 | 0 | I installed zipline package via Enthought Cantopy. Now I try to run a script using it in command prompt, but get error ImportError: No module named zipline.
I also tried to run the same code using IPython, with the same output.
I think it is related to python virtual environments, but don't know how to fix that. | zipline error. No module named zipline | 1.2 | 0 | 0 | 2,894 |
30,265,151 | 2015-05-15T17:12:00.000 | 0 | 0 | 1 | 0 | python,matplotlib,six | 30,265,202 | 1 | false | 0 | 0 | You can install the package by running pip install six-1.9.0.tar.gz which requires you to copy six-1.9.0.tar.gz to the machine somehow. | 1 | 0 | 0 | I am trying to install matplotlib on my lab computer that does not have internet access. Since it requires six for its full implementation, I am unable to run the scripts that has matplotlib module.
I know how to install six by using pip but am stuck when there is no internet access.
Thanks in advance! | is there a way to install six if I do not have access to internet? | 0 | 0 | 0 | 237 |
30,267,236 | 2015-05-15T19:21:00.000 | 1 | 0 | 0 | 1 | python,django,celery | 30,300,802 | 1 | true | 1 | 0 | If you want to run chains at once you will need to run more than one worker. | 1 | 0 | 0 | I have Celery tasks chain that I call with apply_async. Each task in chain depends on the result from previous task.
Basically the worklof looks like this:
Fetch data from DB.
For each fetched row run chain with tasks.
Behaviour that I want to achieve is to run multiple chains at one time. But it seems like it runs them in a row, not simultaneously. How to fix this issue? | Run multiple Celery chains at the same time | 1.2 | 0 | 0 | 678 |
30,270,075 | 2015-05-15T23:10:00.000 | 0 | 0 | 0 | 0 | python-2.7 | 35,987,562 | 1 | false | 0 | 0 | Observing the error: 'Failed to connect to localhost port 4000: Connection timed out'). Are you sure the domains/url you are trying to connect is not including localhost or a domain that resolves to localhost (i.e. 127.0.0.1)? Also port 4000 is not the typical port you will find a web server listening on. | 1 | 0 | 0 | I'm making several requests using threads and I am not interested in the delay required to get the responses.
The most important thing for me is the reception of the response.
I put these values (all the bigger ones return errors):
c.setopt (pycurl.CONNECTTIMEOUT ,3600000000000000000)
c.setopt (pycurl.TIMEOUT,3600000000000000000)
But I got the same error just after receiving some responses.
error: (7, 'Failed to connect to localhost port 4000: Connection timed out')
Please can some one help me .
Thank you very much. | Connection timed out (pycurl) | 0 | 0 | 1 | 259 |
30,270,229 | 2015-05-15T23:36:00.000 | 3 | 0 | 1 | 0 | python,copy-on-write | 30,270,254 | 2 | true | 0 | 0 | Python has only 1 copy of each immutable object, no matter how many variables you have referring to it. When using said string as an argument to another function, you're only passing that reference to it. When you say "modify" what happens is python just changes that reference (also creating the new string if it wasn't used arleady, and eventually deleting the old one it's not referenced anywhere else). | 1 | 1 | 0 | When I pass a string to a function, does python copy the whole string to a new memory location or does it wait until I try to modify the string from inside the function?
Thanks :) | Does python use copy-on-write when passing an immutable variable to a function? | 1.2 | 0 | 0 | 321 |
30,272,764 | 2015-05-16T06:58:00.000 | 0 | 1 | 0 | 0 | python,sendkeys | 31,356,253 | 1 | true | 0 | 0 | It is possible using ctypes.
It can be implemented in win32 apis | 1 | 0 | 0 | In python, I'm using SendKey module to perform "key down"
My curiosity starts with pressing speed.
When using SendKey, it presses with machine speed. I want to program it to slow down like human speed. Is it possible in Python? | How to program "key down"s speed programmatically?(Python) | 1.2 | 0 | 0 | 86 |
30,278,054 | 2015-05-16T16:26:00.000 | 1 | 0 | 0 | 1 | python,redis,rabbitmq,celery,message-queue | 30,282,486 | 3 | false | 1 | 0 | Can your tasks in stage 2 check whether the work has already been done and, if it has, then not do the work again? That way, even though your task list will grow, the amount of work you need to do won't.
I haven't come across a solution re the sets / lists, and I'd think there were lots of other ways of getting around this issue. | 1 | 8 | 0 | I'm wondering if there's a way to set up RabbitMQ or Redis to work with Celery so that when I send a task to the queue, it doesn't go into a list of tasks, but rather into a Set of tasks keyed based on the payload of my task, in order to avoid duplicates.
Here's my setup for more context:
Python + Celery. I've tried RabbitMQ as a backend, now I'm using Redis as a backend because I don't need the 100% reliability, easier to use, small memory footprint, etc.
I have roughly 1000 ids that need work done repeatedly. Stage 1 of my data pipeline is triggered by a scheduler and it outputs tasks for stage 2. The tasks contain just the id for which work needs to be done and the actual data is stored in the database. I can run any combination or sequence of stage 1 and stage 2 tasks without harm.
If stage 2 doesn't have enough processing power to deal with the volume of tasks output by stage 1, my task queue grows and grows. This wouldn't have to be the case if the task queue used sets as the underlying data structure instead of lists.
Is there an off-the-shelf solution for switching from lists to sets as distributed task queues? Is Celery capable of this? I recently saw that Redis has just released an alpha version of a queue system, so that's not ready for production use just yet.
Should I architect my pipeline differently? | Distributed Task Queue Based on Sets as a Data Structure instead of Lists | 0.066568 | 0 | 0 | 656 |
30,278,630 | 2015-05-16T17:22:00.000 | 0 | 0 | 0 | 0 | python,csv | 30,278,960 | 1 | false | 0 | 0 | It turns out there was just a problem in the csv file. What happened was that I was running the same file, which caused another header row to be entered. When there is more then one header row, the script tries to convert something like "ind_sharpe" into a float which obviously will not work, and breaks the program.
The solution, overwrite header rows, don't stack them. | 1 | 0 | 1 | I have a Python script that writes and reads multiple CSV files. On OS X, in order to perform any calculations on any values in the CSV file, I have to float the value float(d['var_returns']). This works perfectly fine on OS X and the entire script works as performed.
However, using the exact same code on Windows, I get:
ValueError: could not convert string to float: var_returns
I was wondering why this is happening, and how I can fix it? The typical value in var_returns would be 0.050244079 | Python reads CSV on OS X differently then Windows? | 0 | 0 | 0 | 32 |
30,279,549 | 2015-05-16T18:53:00.000 | 0 | 0 | 1 | 0 | python,binary-tree,min-heap | 30,279,570 | 3 | false | 0 | 0 | Yes, None is considered a mean-heap tree. | 2 | 1 | 0 | I need to write a recursion for a min-heap binary tree to check if this tree is min-heap. One of the test cases is just NONE.
Is None considered a min-heap tree and returns True, or None is False?
The reason I am asking is that I will reach leaves at some point and their nodes are None and if base case is True then it will return True. | Is binary tree that is just None can be considered a min-heap tree? | 0 | 0 | 0 | 267 |
30,279,549 | 2015-05-16T18:53:00.000 | 1 | 0 | 1 | 0 | python,binary-tree,min-heap | 30,279,572 | 3 | false | 0 | 0 | I believe that a none type will be vacuously true as it does not violate the definition of a min-heap tree. | 2 | 1 | 0 | I need to write a recursion for a min-heap binary tree to check if this tree is min-heap. One of the test cases is just NONE.
Is None considered a min-heap tree and returns True, or None is False?
The reason I am asking is that I will reach leaves at some point and their nodes are None and if base case is True then it will return True. | Is binary tree that is just None can be considered a min-heap tree? | 0.066568 | 0 | 0 | 267 |
30,279,783 | 2015-05-16T19:19:00.000 | 4 | 0 | 0 | 0 | python,python-3.x,apache-spark | 30,279,862 | 5 | false | 0 | 0 | Have a look into the file. The shebang line is probably pointed to the 'env' binary which searches the path for the first compatible executable.
You can change python to python3. Change the env to directly use hardcoded the python3 binary. Or execute the binary directly with python3 and omit the shebang line. | 3 | 99 | 1 | I built Spark 1.4 from the GH development master, and the build went through fine. But when I do a bin/pyspark I get the Python 2.7.9 version. How can I change this? | Apache Spark: How to use pyspark with Python 3 | 0.158649 | 0 | 0 | 93,816 |
30,279,783 | 2015-05-16T19:19:00.000 | 155 | 0 | 0 | 0 | python,python-3.x,apache-spark | 32,094,874 | 5 | false | 0 | 0 | Just set the environment variable:
export PYSPARK_PYTHON=python3
in case you want this to be a permanent change add this line to pyspark script. | 3 | 99 | 1 | I built Spark 1.4 from the GH development master, and the build went through fine. But when I do a bin/pyspark I get the Python 2.7.9 version. How can I change this? | Apache Spark: How to use pyspark with Python 3 | 1 | 0 | 0 | 93,816 |
30,279,783 | 2015-05-16T19:19:00.000 | 9 | 0 | 0 | 0 | python,python-3.x,apache-spark | 38,938,668 | 5 | false | 0 | 0 | 1,edit profile :vim ~/.profile
2,add the code into the file: export PYSPARK_PYTHON=python3
3, execute command : source ~/.profile
4, ./bin/pyspark | 3 | 99 | 1 | I built Spark 1.4 from the GH development master, and the build went through fine. But when I do a bin/pyspark I get the Python 2.7.9 version. How can I change this? | Apache Spark: How to use pyspark with Python 3 | 1 | 0 | 0 | 93,816 |
30,280,460 | 2015-05-16T20:32:00.000 | 2 | 1 | 0 | 1 | python,google-app-engine,google-cloud-storage | 30,280,609 | 2 | false | 1 | 0 | A cron job in GAE has to hit a URL, there's no other way to do it. That's just how the system is designed.
But since you have control over app.yaml anyway, you can easily assign your script to a URL there. | 1 | 0 | 0 | my end goal is to update Google cloud storage with some json data and I would rather it run a script rather than hitting a url endpoint. What would be the proper configuration of cron.yaml if, let's say the script were to sit right next to app.yaml? | Is there a way to run a Google App engine cron task without hitting an endpoint but rather pointing cron.yaml at a python script? | 0.197375 | 0 | 0 | 622 |
30,280,774 | 2015-05-16T21:06:00.000 | 0 | 0 | 0 | 0 | python,linux,multithreading,gtk,pox | 30,397,459 | 1 | false | 0 | 1 | I was able to solve the problem by spawning separate threads for both GTK and the POX controller. With this done, everything's working fine simultaneously. | 1 | 0 | 0 | I'm trying to create a simple Python application for Linux and I'm using GTK to generate a UI for it. I've only begun exploring GTK but from what I can tell, the moment you call GTK.main() the program goes into that function wherever and only responds to user interactions with the UI. The thing is, I'm running an SDN controller (POX) alongside, and I want the events associated with instances of POX objects to also be able to run (which currently isn't happening since the program gets stuck in 'GTK.main()' forever).
I've considered creating a new thread and calling GTK.main() from there, but then I'll have to worry about thread safety. Isn't there some way where the events for both the UI as well as the objects instantiated in the rest of the program fire alongside? | Keep background events active when using GTK | 0 | 0 | 0 | 69 |
30,281,349 | 2015-05-16T22:19:00.000 | 0 | 0 | 0 | 0 | python,urllib2 | 30,281,634 | 1 | true | 0 | 0 | The problem seemed to be solved by a combination of Ajay's comment:
Try after installing this pip install pyopenssl ndg-httpsclient pyasn1 if you are using python2
and the OS X Yosemite version of DNS cache flushing:
sudo discoveryutil mdnsflushcache | 1 | 0 | 0 | I'm querying the Mixpanel API pretty consistently, but every so often, the request does not go through and I am given this error:
urllib2.URLError: <urlopen error [Errno 8] nodename nor servname provided, or not known>
I did some searching and there might be some caching issues, so I tried this in terminal:
dscacheutil -flushcache
I tried the above last night and it worked, but now when I am greeted with the same error and I try to flush the cache, I am still given the same error.
There haven't been any code changes that would have given me this error.
Any thoughts why this is happening?
P.S. Yes, I know urllib2 blows. I would prefer to be using requests, but the urllib2 calls are in a mixpanel client and I'd prefer not to mess around with it. | urllib2 request randomly stops working without code changes | 1.2 | 0 | 1 | 126 |
30,286,986 | 2015-05-17T12:43:00.000 | 1 | 0 | 0 | 0 | python,pydoc | 30,287,331 | 2 | true | 1 | 0 | I ended up just switching to epydoc, which is much more featureful than pydoc. Sphinx is another alternative. | 1 | 0 | 0 | In javadoc, you can have tags like @author, @return, @deprecated which are handled specially when making java documentation. Is there an equivalent functionality in pydoc or am I limited to just a verbatim copy of the method's docstring? | Equivalent of javadoc's tags in pydoc | 1.2 | 0 | 0 | 1,176 |
30,289,423 | 2015-05-17T16:45:00.000 | 0 | 0 | 0 | 0 | python,django,django-messages | 30,289,765 | 1 | true | 1 | 0 | It depends. You could save your messages in the database if you need the classical approach to messages. This would best work for messages sent in e-mail or bulletin board "style".
If however you need real-time behavior and lots of messages, having a database inbetween might slow things down a bit. You could use node.js for a real-time chat.
If you are intending to use Django-Messages as a means to communicate between users, it wasn't meant for this. It is simply used for displaying flash notifications for users when they navigate through pages in your app. They are normally stored in the session and used only for the following page, afterwards being deleted.
I cannot give more details because your question is quite vague. Firstly you need to find which are your plans, how do you intend to use the "chatting between users". | 1 | 0 | 0 | I want to make my own on Django-app. The app must have an messages-application not only for notification but for chatting between users.
So, for example I've write a model for messages, so where I have to save the messages? In the database, or maybe it is not a good style of coding and bad for work speed? | Where to save messages in Django app? | 1.2 | 0 | 0 | 435 |
30,292,625 | 2015-05-17T22:03:00.000 | 0 | 0 | 0 | 0 | python,css,django,pdf,weasyprint | 30,314,963 | 1 | true | 1 | 0 | Found the solution. It was a CSS problem. The class used to style the body was not at the beginning of the css file and that caused erratic behavior with other styles declared before it. | 1 | 0 | 0 | I'm using Weasyprint to print an HTML template to PDF, and I keep getting a gap of 10cm on the right side.
I'm using @page:(size:letter;) as only page attribute.
I've tried setting the page size manually, but I still keep getting a huge space to the right of all the pages.
Any thoughts on what could be the problem? | Weasyprint HTML to PDF huge gap in right margin | 1.2 | 0 | 0 | 1,861 |
30,292,884 | 2015-05-17T22:39:00.000 | 2 | 0 | 1 | 1 | python,azure,cloud,bigdata,azure-virtual-machine | 30,571,753 | 1 | true | 0 | 0 | There is no additional steps to do in comparison to Your own. local server. Linux on Azure is a standard Linux machine. If You are looking for step-by-step hopw to on running Linux VM on Azure, just search on azure.com and You will find it. I think You will not have any problems even without documentation. Azure portal is very simple to use, also CLI tool for Linux, Mac and Windows. You just need to run Linux VM and SSH-in to it. Nothing more. If You need some help, just write here. | 1 | 2 | 0 | I'll have a linux machine with a virtual machine installed for Microsoft azure soon. I need to run some data mining/graph analysis algorithms on the azure because I work with big data. I don't want to use azure machine learning stuff. just want to run my own python code. What are the steps? If needed, hoe can I install python libraries on azure? | Running python script on Microsoft Azure | 1.2 | 0 | 0 | 4,731 |
30,295,848 | 2015-05-18T05:43:00.000 | 3 | 0 | 1 | 0 | python,file,pandas,permissions | 30,296,559 | 3 | true | 0 | 0 | Better give the complete path for your output csv file. May be that you are checking in a wrong folder. | 1 | 1 | 1 | I am running the following: output.to_csv("hi.csv") where output is a pandas dataframe.
My variables all have values but when I run this in iPython, no file is created. What should I do? | How to write .csv file in Python? | 1.2 | 0 | 0 | 3,754 |
30,297,785 | 2015-05-18T07:52:00.000 | 7 | 0 | 0 | 0 | python,django,authentication | 30,298,038 | 2 | true | 1 | 0 | I think you should use cookies.
When a user that is not authenticated makes a request, look for a cookie named whatever ("nonuserid" in this case). If the cookie is not present it means it's a new user so you should set the cookie with a random id. If it's present you can use the id in it to identificate the anonymous user. | 1 | 8 | 0 | I want to create a table(postgres) that stores data about what items were viewed by what user. authenticated users are no problem but how can I tell one anonymous user from another anonymous user? This is needed for analysis purposes.
maybe store their IP address as unique ID? How can I do this? | how to give some unique id to each anonymous user in django | 1.2 | 1 | 0 | 4,523 |
30,302,766 | 2015-05-18T12:04:00.000 | 1 | 0 | 1 | 0 | python,unicode | 30,302,821 | 7 | false | 0 | 0 | For a given codepoint, you can use unicodedata.name. To get them all, you can work through all the billions to see which have such names. | 2 | 8 | 0 | In Python I can print a unicode character by name (e.g. print(u'\N{snowman}')). Is there a way I get get a list of all valid names? | List of unicode character names | 0.028564 | 0 | 0 | 7,360 |
30,302,766 | 2015-05-18T12:04:00.000 | 0 | 0 | 1 | 0 | python,unicode | 54,364,764 | 7 | false | 0 | 0 | If you want to insert a unicode character by name, but don't know the name. Here is how you get an easy overview of unicode character names.
On Windows
Open "Character Map" (search for charmap.exe and run it).
Select any common Microsoft font (these tend to have a wide variety of unicode characters defined).
Click on any character on the map to get its Unicode Character Name.
On Mac it's called "Character Palette" and found under System Preferences, "International -> Input" or "Language & Text -> Input Sources" by ticking the box next to "Character Palette". | 2 | 8 | 0 | In Python I can print a unicode character by name (e.g. print(u'\N{snowman}')). Is there a way I get get a list of all valid names? | List of unicode character names | 0 | 0 | 0 | 7,360 |
30,304,650 | 2015-05-18T13:34:00.000 | -2 | 0 | 1 | 0 | python,pprint | 35,257,151 | 1 | false | 0 | 0 | You can change the way an object is printed by overriding the __repr__() method on its class.
Python will allow you to override the repr of any class, so use it with care. | 1 | 6 | 0 | Can I have pretty printed data output as in pprint.pprint (new lines, indentation), but also shortened lists as in reprlib.repr at the same time?
An ugly hack seems to be pprint(eval(reprlib.repr(data))), but is there a better way? | Combine reprlib and pprint in Python? | -0.379949 | 0 | 0 | 555 |
30,315,466 | 2015-05-19T01:47:00.000 | 0 | 0 | 0 | 0 | python,pygame | 30,315,673 | 2 | true | 0 | 1 | Not sure if this is the problem, but the stretching might be caused by not redrawing the background. Blitting is like painting, you can't erase stuff. When you want to move something, you need to repaint all the places that have changed - also the background that is not visible after movement.
The quickest way to do this is to redraw the whole background. | 1 | 0 | 0 | I've got my own drawing loaded on to the screen and scaled it to the size I want, but the background of the program I used to make the drawing is still on the image. I noticed that when I move the image, the background doesn't move with the picture, but it actually looks like it's stretching out and it will cover wherever I move the picture to. I think this is because I used the .blit feature when getting my picture on screen, but I can't find a clear enough answer on how to get the picture on screen any other way. Can someone point me in the right direction, please? | Getting my drawing into pygame without .blit() | 1.2 | 0 | 0 | 79 |
30,317,213 | 2015-05-19T05:12:00.000 | 4 | 0 | 1 | 1 | python,rpm | 30,325,775 | 2 | false | 0 | 0 | The *.pyc and *.pyo are being automagically compiled by helper scripts in rpm.
The simplest way to disable is to add "exit 0" at the end of the %install section to disable the running of the helper scripts
Otherwise you will need to change your build configuration and redefine the macros that are being appended to the %install script let when building. | 1 | 3 | 0 | I have a proxy written in python. I want to create an RPM for this. This rpm will just place the appropriate files at their location. and then some python server will pick them.
Now my question is that whenever I generate the rpm, I am getting .pyo and .pyc files as well for every .py file. I don't need those pyc and pyo files.
Is there any flag or anything that I can do to remove them?
Thank you. | How to remove .pyo anc .pyc from an RPM? | 0.379949 | 0 | 0 | 5,993 |
30,317,965 | 2015-05-19T06:11:00.000 | 27 | 0 | 1 | 0 | python,decorator,mixins,python-decorators | 30,318,081 | 1 | true | 0 | 0 | In my opinion, you need mixins when you have a few different classes that should have same functionality.
Good examples of using mixins are Django's class-based views. For example, you have a few different classes: FormView, TemplateView, ListView. All of them have one similar piece of functionality: they have to render templates. Every one of these classes has a mixin, which adds methods required for template rendering.
Another example is if you needed to add a class for an API that returns a JSON result. It could also be inherited from a base, View class. You simply skip template mixins, and define what you need (and probably write your own mixin for JSON encoding).
Additionally, you may override some of methods proposed in mixins which allow you to modify some parts of common code for your local case. It's all about OOP, buddy!
Long story short: mixins add new functionalities.
Decorators are used to modify existing functionalities. For example, if you need to log what is returned from a method in your class. The right choice here is a decorator (added to appropriate methods).
Hope it is helpful. If not, please ask questions. I will update my response. | 1 | 24 | 0 | I have understood the basics of decorators and mixins. Decorators add a new functionality to an object without changing other object instances of the same class, while a mixin is a kind of multiple inheritance used to inherit from multiple parent classes.
Does it mean that decorators should be used when you'd need to modify only a single object instance and use mixins when you'd need a whole new class of objects. Or, is there something more to it that I might be missing? What can be real life use cases for both? | Python: Use of decorators v/s mixins? | 1.2 | 0 | 0 | 4,205 |
30,318,168 | 2015-05-19T06:24:00.000 | 0 | 0 | 0 | 1 | python,linux,ubuntu,cron,crontab | 30,319,952 | 5 | false | 0 | 0 | If all you want to do is reset the content of user crontab file , then just remove the crontab file (or overwrite with your default) , and reload the cron service . | 2 | 2 | 0 | We know the crontab command is used for scheduled tasks in Linux.
I want to write a Python script. Its function is to receive some data (these data are related to crontab setting) and execute a 'crontab' command in order to reset the content of the user's crontab file.
I know how to execute external Linux commands in Python. But when you execute the crontab command (e.g. crontab -u xxx -e), you need to interact with an editor to modify the user's crontab file. (Suppose I don't know where the file is. For new users, crontab will generate a new file anyway. And I don't execute the command as the root user).
So the question is, how can I just execute crontab in Python? Is there any way to avoid interacting with an editor to modify the user's crontab file in Python?
My OS is ubuntu 14.01. | Python: How to handle 'crontab' command? | 0 | 0 | 0 | 6,083 |
30,318,168 | 2015-05-19T06:24:00.000 | 0 | 0 | 0 | 1 | python,linux,ubuntu,cron,crontab | 30,319,851 | 5 | false | 0 | 0 | You could/should first dump your current crontab with crontab -l, edit it the way you want (e. g. add some lines, or modify) and then install the new one.
This usually works with crontab <filename>, but should as well work with crontab - and then piping the new contents into the process's stdin. | 2 | 2 | 0 | We know the crontab command is used for scheduled tasks in Linux.
I want to write a Python script. Its function is to receive some data (these data are related to crontab setting) and execute a 'crontab' command in order to reset the content of the user's crontab file.
I know how to execute external Linux commands in Python. But when you execute the crontab command (e.g. crontab -u xxx -e), you need to interact with an editor to modify the user's crontab file. (Suppose I don't know where the file is. For new users, crontab will generate a new file anyway. And I don't execute the command as the root user).
So the question is, how can I just execute crontab in Python? Is there any way to avoid interacting with an editor to modify the user's crontab file in Python?
My OS is ubuntu 14.01. | Python: How to handle 'crontab' command? | 0 | 0 | 0 | 6,083 |
30,320,265 | 2015-05-19T08:20:00.000 | 0 | 0 | 1 | 0 | python,django,heroku,version | 30,321,377 | 4 | false | 1 | 0 | If you didn't have access to source code, from headers I can see that server is using Gunicorn 0.17.2, which is compatible with Python 2.x >= 2.6, which rules out i.e. Python 3. | 1 | 1 | 0 | We run a site called inteokej.nu and I need to find out which version of Python it runs on. I have pulled all the files to my computer but I don't know if and how I can find out the version number from them? The site is hosted on Heroku and maybe there's a way to find out the version with some kind of Heroku command?
As for now I don't have any possibilities to change any code (e.g. add a code snippet to get the version).
Thanks in advance! | Find out Python version from source code (or Heroku) | 0 | 0 | 0 | 1,237 |
30,322,307 | 2015-05-19T09:54:00.000 | -1 | 0 | 1 | 0 | python,datetime | 30,322,638 | 3 | false | 0 | 0 | Use the classmethod of datetime.strptime(date_string, format). This will return a datetime corresponding to date_string, parsed according to format. | 1 | 0 | 0 | I have a string "Monday, May 18, 2015". I want to convert it into datetime fromat of python keeping the format same. I mean exact replica of the string but the type changed to datetime. How can I do that? | Convert string to date time in specified format | -0.066568 | 0 | 0 | 494 |
30,322,964 | 2015-05-19T10:24:00.000 | 3 | 0 | 0 | 0 | python,rrdtool,rrd | 30,339,442 | 1 | true | 0 | 0 | Under RRDTool 1.4 and earlier, you cannot add a DS or an RRA to an existing RRD file without recreating it. The newly-released RRDTool 1.5 has the ability to add new DS and RRA using the rrdtool tune subcommand, but this may not yet have Python bindings available in your OS.
With 1.4, the only way to add a new RRA is to dump the existing file to XML, modify the XML, and then restore it to create a new RRD. Needless to say, this is not trivial, and does not necessarily build the data in the new RRA from historical data in other RRAs. There exist various third-party utilities such as rrdmerge (distributed with the Routers2 package) that can do this, but they all have shortcomings in one form or another. | 1 | 1 | 0 | I am using RRD for monitoring. In the current RRD files are not all archives present that I want to use in the future. How do I add RRA's to an existing RRD? I'm writing a Python (1.4.7) script using rrdpython.
I only find the option for dumping it to XML, adding the archives and restoring it again. But that doesn't sound attractive and fast.
If there is no good solution, how can I easily 'copy' the content of the RRD to add it to a new RRD (by using 'update' I guess) which does contain the archives? (in python)
Thank you in advance. | How can I add RRA's to an existing RRD? | 1.2 | 0 | 0 | 1,150 |
30,323,607 | 2015-05-19T10:52:00.000 | 2 | 0 | 1 | 0 | python | 30,323,639 | 2 | false | 0 | 0 | The __init__.py has two main functions:
Marking packages: It marks a directory as a Python package, and the inner .py files as Python modules.
Initialization code: As its name suggests, any code inside the __init__.py is automatically executed when the package is imported. This is the right place to run initialization code required for a certain package; however, it's perfectly OK to leave the __init__.py file empty. | 1 | 3 | 0 | I can import from subdirectories with a blank __init__.py file. That works fine. I think that init file in python works like an index file. But I really don't understand why the __init__.py file is blank to import. How do __init__.py file and importing really work?
What have to be __init__.py files content? | Why do I have to add a blank __init__.py file to import from subdirectories | 0.197375 | 0 | 0 | 4,036 |
30,324,370 | 2015-05-19T11:29:00.000 | 2 | 0 | 0 | 0 | python,oracle,cx-oracle | 30,324,469 | 5 | true | 0 | 0 | If is possible to export your excel fila as a CSV, then all you need is to use sqlldr to load the file in db | 3 | 4 | 0 | I have a 3+ million record XLS file which i need to dump in Oracle 12C DB (direct dump) using a python 2.7.
I am using Cx_Oracle python package to establish connectivity to Oracle , but reading and dumping the XLS (using openpyxl pckg) is extremely slow and performance degrades for thousands/million records.
From a scripting stand point used two ways-
I've tried bulk load , by reading all the values in array and then dumping it using cursor prepare (with bind variables) and cursor fetchmany.This doesn't work well with huge data.
Iterative loading of the data as it is being fetched.Even this way has performance issues.
What options and techniques/packages can i deploy as a best practise to load this volume of data from XLS to Oracle DB ?Is it advisable to load this volume of data via scripting or should i necessarily use an ETL tool ?
As of now i only have option via python scripting so please do answer the former | loading huge XLS data into Oracle using python | 1.2 | 1 | 0 | 4,256 |
30,324,370 | 2015-05-19T11:29:00.000 | 0 | 0 | 0 | 0 | python,oracle,cx-oracle | 30,328,198 | 5 | false | 0 | 0 | Excel also comes with ODBC support so you could pump straight from Excel to Oracle assuming you have the drivers. That said, anything that involves transforming a large amount of data in memory (from whatever Excel is using internally) and then passing it to the DB is likely to be less performant than a specialised bulk operation which can be optimised to use less memory. Going through Python just adds another layer to the task (Excel to Python to Oracle), though it might be possible to set this up to use streams. | 3 | 4 | 0 | I have a 3+ million record XLS file which i need to dump in Oracle 12C DB (direct dump) using a python 2.7.
I am using Cx_Oracle python package to establish connectivity to Oracle , but reading and dumping the XLS (using openpyxl pckg) is extremely slow and performance degrades for thousands/million records.
From a scripting stand point used two ways-
I've tried bulk load , by reading all the values in array and then dumping it using cursor prepare (with bind variables) and cursor fetchmany.This doesn't work well with huge data.
Iterative loading of the data as it is being fetched.Even this way has performance issues.
What options and techniques/packages can i deploy as a best practise to load this volume of data from XLS to Oracle DB ?Is it advisable to load this volume of data via scripting or should i necessarily use an ETL tool ?
As of now i only have option via python scripting so please do answer the former | loading huge XLS data into Oracle using python | 0 | 1 | 0 | 4,256 |
30,324,370 | 2015-05-19T11:29:00.000 | 0 | 0 | 0 | 0 | python,oracle,cx-oracle | 63,836,641 | 5 | false | 0 | 0 | Automate the export of XLSX to CSV as mentioned in a previous answer. But, instead of then calling a sqlldr script, create an external table that uses your sqlldr code. It will load your table from the CSV each time the table is selected from. | 3 | 4 | 0 | I have a 3+ million record XLS file which i need to dump in Oracle 12C DB (direct dump) using a python 2.7.
I am using Cx_Oracle python package to establish connectivity to Oracle , but reading and dumping the XLS (using openpyxl pckg) is extremely slow and performance degrades for thousands/million records.
From a scripting stand point used two ways-
I've tried bulk load , by reading all the values in array and then dumping it using cursor prepare (with bind variables) and cursor fetchmany.This doesn't work well with huge data.
Iterative loading of the data as it is being fetched.Even this way has performance issues.
What options and techniques/packages can i deploy as a best practise to load this volume of data from XLS to Oracle DB ?Is it advisable to load this volume of data via scripting or should i necessarily use an ETL tool ?
As of now i only have option via python scripting so please do answer the former | loading huge XLS data into Oracle using python | 0 | 1 | 0 | 4,256 |
30,324,638 | 2015-05-19T11:41:00.000 | 3 | 0 | 1 | 0 | python,file,seek | 30,324,707 | 4 | false | 0 | 0 | Assuming the file isn't too big and memory isn't a concern
open('file.txt').readlines()[-2] | 1 | 1 | 0 | I am wondering if there is a simple way to get to the penultimate line of an open file. f.seek is giving me no end of trouble. I can easily get to the final line, but I can't figure out how to get to the line above that. | Printing to the penultimate line of a file | 0.148885 | 0 | 0 | 490 |
30,324,761 | 2015-05-19T11:47:00.000 | 0 | 0 | 0 | 0 | python,django,windows-7-x64 | 30,326,360 | 1 | true | 1 | 0 | To Summarize the comments:
This is because you're in c:\Windows\system32. By default when you open command prompt is in that system32 directory. you need to change it first. To change directory use cd <what path you want>.
Once you're in the correct directory, you can start the project with django-admin startproject command.
For example: cd c:\ to change directory to your root directory. then type C:\Python34\Scripts\django-admin startproject mysite. It will then create the directory under C:\mysite
Last but not least, you can also put C:\Python34\Scripts in your system environment variable PATH, so that you don't have to type the full address of django-admin. Instead you can then use the django-admin startproject mysite. | 1 | 0 | 0 | I am currently learning how to use Python/Django. I have successfully installed and setup Django. I am experiencing problems creating a project using the django-admin startproject mysite command. I have executed the command from command prompt using the path: C:\Python34\Scripts\django-admin startproject mysite I tried searching for it in the current directory but could not find the folder. I tried executing the command again and found out that the directory exists in:
'C:\Windows\system32\mysite'
I tried searching for it in this directory, but could not find it. How can I make this directory visible and set it under the Python directory?
Here is the exact error I am getting in Command Prompt:
CommandError: 'C:\Windows\system32\mysite' already exists
I am currently running Windows 7 - 64 Bit | Django - Cannot find Directory 'mysite' | 1.2 | 0 | 0 | 1,391 |
30,325,959 | 2015-05-19T12:42:00.000 | 1 | 0 | 1 | 0 | c#,python,mobile,xamarin | 30,330,288 | 2 | false | 0 | 0 | You cannot. Xamarin has built bindings from C#/.NET to the underlying languages and runtimes on iOS and Android. That is what it provides for you; you don't have to code in Objective-C or Java but can use C# and get more reuse. | 1 | 2 | 0 | I have a existing application and the code was written in Python. Now i am developing a Mobile application using Xamarin. Now I want to use the same existing application code written in Python to develop my mobile apps from Xamarin.
How can I use Python from Xamarin. | How to use Python from Xamarin | 0.099668 | 0 | 0 | 10,017 |
30,329,286 | 2015-05-19T15:01:00.000 | 7 | 0 | 1 | 0 | python,pointers,memory,memory-management | 34,317,823 | 1 | true | 0 | 0 | This was answered in the comments through a discussion between me and SuperBiasedMan. The size of a reference in Python is the same as the word size for the CPU. So, it's 4 bytes on a 32bit build of python, and 8 bytes on 64bit python. | 1 | 9 | 0 | I have a project that I am planning, and one bit of information I'll want to have is how much memory a reference takes up in Python. AFAIK, a reference in python is the same as a pointer, and I am guessing that it would be the same size as a 32bit or 64bit pointer (but I could be wrong).
Could anyone clear this up for me, so that I don't have to go on guesswork? | Python: Size of Reference? | 1.2 | 0 | 0 | 2,928 |
30,329,528 | 2015-05-19T15:12:00.000 | 2 | 0 | 0 | 0 | python,database,sqlite | 30,329,701 | 2 | true | 0 | 0 | use the pragma table_info(spamtable) command. The table names will be index 1 of the returned tuples. | 1 | 1 | 0 | Sorry for the rookie question. I have a sqlite file and I need to get table column names. How can I get them? | How to get list of column names of a sqlite db file | 1.2 | 1 | 0 | 696 |
30,330,543 | 2015-05-19T15:58:00.000 | 1 | 1 | 0 | 0 | python,wifi,tethering | 30,333,512 | 2 | false | 0 | 0 | Normally not - from the computer's prospective the tethered cell phone is simply just another wifi router/provider.
You might be able to detect some of the phone carrier networks from the traceroute info to some known servers (DNS names or even IP address ranges of network nodes - they don't change that often).
If you have control over the phone tethering you could also theoretically use the phone's wifi SSID (or even IP address ranges) to identify tethering via individual/specific phones (not 100% reliable either unless you know that you can't get those parameters from other sources). | 1 | 1 | 0 | I was wondering if there is a way to detect, from a python script, if the computer is connected to the internet using a tethered cell phone?
I have a Python script which runs a bunch of network measurement tests. Ideally, depending on the type of network the client is using (ethernet, wifi, LTE, ...) the tests should change. The challenge is how to get this information from the python client, with out asking the user to provide it. Especially detect tethering. | Detect if connected to the internet using a tethered phone in Python | 0.099668 | 0 | 1 | 605 |
30,331,208 | 2015-05-19T16:28:00.000 | 4 | 0 | 0 | 0 | python,matplotlib | 30,336,990 | 2 | true | 0 | 0 | Calling the locator for the colorbar instance should return the tick locations.
colorbar.locator(). | 2 | 5 | 1 | I am using a colorbar in matplotlib and because I want my graph to be more sensitive I take the square root of each value. This gives me square rooted values on my colorbar, but now I want to scale the ticks labels back to the real values. I am thusly having a hard time doing. I see that colorbar has a set_ticks function but I need to be able to get my ticks in the first place to do this generally. Is there an easy way to do this that I am not seeing, or some other way around this? | Get Colorbar Ticks | 1.2 | 0 | 0 | 984 |
30,331,208 | 2015-05-19T16:28:00.000 | 0 | 0 | 0 | 0 | python,matplotlib | 49,789,479 | 2 | false | 0 | 0 | In matplotlib 2.1 you may use method colorbar.get_ticks(). | 2 | 5 | 1 | I am using a colorbar in matplotlib and because I want my graph to be more sensitive I take the square root of each value. This gives me square rooted values on my colorbar, but now I want to scale the ticks labels back to the real values. I am thusly having a hard time doing. I see that colorbar has a set_ticks function but I need to be able to get my ticks in the first place to do this generally. Is there an easy way to do this that I am not seeing, or some other way around this? | Get Colorbar Ticks | 0 | 0 | 0 | 984 |
30,332,159 | 2015-05-19T17:21:00.000 | 0 | 0 | 0 | 0 | python,kivy | 30,334,720 | 1 | false | 0 | 1 | You could Clock.schedule(some_function, 0) in your build method, I think that would run after everything is initialised but before the next frame. | 1 | 2 | 0 | How can I register a callback for when a Kivy gui is loaded?
In my Kivy app, as soon as the GUI is loaded (aka the window pops up with the initial view), I need to kick off a function that loads expensive data and updates the UI.
So far i've been using the on_start method in App but this runs before the GUI is loaded.
essentially, i want something like $( document ).ready() (from jquery) but for ivy | kivy -- event for when guis is loaded | 0 | 0 | 0 | 499 |
30,335,122 | 2015-05-19T20:04:00.000 | 18 | 0 | 1 | 1 | python,windows,python-3.x,windows-10 | 31,065,211 | 2 | false | 0 | 0 | You can use python -m pip install package | 1 | 7 | 0 | I installed the latest version of Python from www.python.org. Python 3.4.3. I then go to run pip and I get
"Fatal error in launcher: Job information querying failed"
Searching for this error message points me to similar issues running Python under wine. If you grab a pre-compiled pip.exe it will work but it seems that when you install, the pip.exe is generated as part of the installer and this pip.exe does not work.
Further I am dealing with a build script that creates a virtual python environment that uses pip.exe and results in the same error. Not sure how to fix this. Also not sure how pip.exe is generated. | Pip.exe from Python on Windows 10 | 1 | 0 | 0 | 18,024 |
30,340,898 | 2015-05-20T05:23:00.000 | 1 | 0 | 1 | 0 | python,object,base-class | 30,341,253 | 2 | false | 0 | 0 | From the docs, chapter 3 (Data Model): "All data in a Python program is represented by objects." Seems clear enough. You say the alternative "might be interesting" but there are already lots of interesting things that aren't Python. | 1 | 5 | 0 | As everyone knows, everything is an object in Python. What I'm wondering about is whether it's possible to create an "object" x such that isinstance(x, object) returns False. I suspect it's possible with sufficient abuse of the CPython API, though achieving this with pure Python would be even more interesting.
Initially I thought that old-style classes would return False since the object hierarchy might not fully apply, but it seems like isinstance(x, object) is indeed True for instances of old-style classes.
While this is mostly of theoretical interest, it might be interesting (or dangerous) if Python allows the creation of a new object hierarchy disconnected from the base object type. | Can a non-object exist in Python? | 0.099668 | 0 | 0 | 1,259 |
30,345,197 | 2015-05-20T09:10:00.000 | 1 | 1 | 0 | 0 | python,c++,eclipse | 30,345,675 | 1 | true | 0 | 0 | Basically you could add C++ nature to the project. Eclipse project could have several natures simultaneously, so you will have both python and C++ goodies.
Right-click on the project.
Select: New -> Other
Under C/C++, select "Convert to a C/C++ project" | 1 | 0 | 0 | I'm working on a large codebase in an Eclipse project. Our codebase has both Python and C++ code. Since I only worked in Python until now, I created the project as a Python project.
Now I'm about to work heavily with some of our C++ modules, and I would like the benefits of CTD. My Eclipse has CTD (the Eclipse C++ plugin) installed. How do I convert my existing PyDev project to work with C++? | Converting a Python project to C++ | 1.2 | 0 | 0 | 473 |
30,347,571 | 2015-05-20T10:54:00.000 | 0 | 0 | 0 | 0 | python,bash,web-scraping | 30,433,834 | 1 | true | 1 | 0 | I solved the issue which keeps searches in GoogleScraper database,we first have to run following command
GoogleScraper --clean
This command cleans all cache and we can search again with new results.
Regards! | 1 | 0 | 0 | I am using GoogleScraper for some automated searches in python.
GoogleScraper keeps search results for search queries in its database named google_scraper.db.e.g. if i have searched site:*.us engineering books and due to internet issue while making json file by GoogleScraper.If the result is missed and json file is not like that what it must be then when i again search that command using GoogleScraper it gives same result while internet is working fine,i mean to say GoogleScraper maintains its database for a query which it has searched and does not search again it, when i search that command whose result is stored in database,it does not give new result but give results from database stored previously | GoogleScraper keeps searches in database | 1.2 | 1 | 1 | 192 |
30,350,382 | 2015-05-20T12:58:00.000 | 1 | 1 | 1 | 0 | python,python-2.7 | 30,350,613 | 1 | false | 0 | 0 | Python gets different amounts of system resources depending upon what else the CPU is doing at the time. If you're playing Skyrim with the highest graphics levels at the time, then your script will run slower than if no other programs were open. But even if your task bar is empty, there may be invisible background processes confounding things.
If you're not already using it, consider using timeit. It performs multiple runs of your program in order to smooth out bad runs caused by a busy OS.
If you absolutely insist on requiring your program to run in the same amount of time every time, you'll need to use an OS that doesn't support multitasking. For example, DOS. | 1 | 0 | 0 | I am working on a Opencv based Python project. I am working on program development which takes less time to execute. For that i have tested my small program print hello world on python to test the time taken to run the program. I had run many time and every time it run it gives me a different run time.
Can you explain me why a simple program is taking different time to execute?
I need my program to be independent of system processes ? | Different time taken by python script every time it is runned? | 0.197375 | 0 | 0 | 38 |
30,352,504 | 2015-05-20T14:23:00.000 | 1 | 1 | 1 | 0 | python,pylint | 30,378,706 | 1 | false | 0 | 0 | You can use the ignore option in the configuration file or add # pylint: disable=all on the top of the python file. | 1 | 1 | 0 | Salutations, all.
I'm working on a python project and have been tasked with cleaning the pylint warnings. Things is, there are specific parts of the code that require indentation or spacing between words that go against Pylint.
Question: is there a way to disable specific pyling warnings on specific files from the rcfile? Like disable wrong continued indentation on files named *tests.py, without making it affect every file.
I'd just add the pylint comment on files, but I was advised against that.
Thanks in advance. | On PyLint, disable specific warning on specif files using rcfile | 0.197375 | 0 | 0 | 422 |
30,353,541 | 2015-05-20T15:04:00.000 | 1 | 0 | 0 | 0 | python,packages,kivy | 30,354,153 | 1 | true | 0 | 1 | Yes you can. Just download the package you want to use and place it in the same folder as your main.py. Then import whatever you wish to use from that package. The packages will also work when you deploy the app onto an Android device. | 1 | 1 | 0 | Is it possible to use any Python package within a Kivy program, and ultimately running it on an android device? for example - can I use the package "xlrd" or "googlemaps" on Kivy? If the answer is positive, How do I do it? normally I get an error message that says "No module named X".
Thank you. | Using various Python packages within a Kivy program | 1.2 | 0 | 0 | 199 |
30,354,621 | 2015-05-20T15:52:00.000 | 0 | 1 | 0 | 1 | python,windows,monitoring | 30,358,001 | 2 | true | 0 | 0 | If there are no other mitigating factors in your design or requirements, my suggestion would be to simplify the script so that it doesn't do the polling; it simply sends the file when invoked, and use Windows Scheduler to invoke the script on whatever schedule you need. By relying on a core Windows service, you can factor that complexity out of your script. | 1 | 0 | 0 | I have a simple python script to send data from a Windows 7 box to a remote computer via SFTP. The script is set to continuously send a single file every 5 minutes. This all works fine but I'm worried about the off chance that the process stops or fails and the customer doesn't notice the data files have stopped coming in. I've found several ways to monitor python processes in a ubuntu/unix environment but nothing for Windows. | How can I monitor a python scrypt and restart it in the event of a crash? (Windows) | 1.2 | 0 | 0 | 403 |
30,357,663 | 2015-05-20T18:28:00.000 | 3 | 0 | 1 | 1 | python,http,tornado,web-frameworks | 30,362,810 | 1 | true | 0 | 0 | The vast majority of Tornado apps should have only one IOLoop, running in the main thread. You can run multiple HTTPServers (or other servers) on the same IOLoop.
It is possible to create multiple IOLoops and give each one its own thread, but this is rarely useful, because the GIL ensures that only one thread is running at a time. If you do use multiple IOLoops you must be careful to ensure that the different threads only communicate with each other through thread-safe methods (i.e. IOLoop.add_callback). | 1 | 5 | 0 | i have been working on tornado web framework from sometime, but still i didnt understood the ioloop functionality clearly, especially how to use it in multithreading.
Is it possible to create separate instance of ioloop for multiple server ?? | Tornado ioloop + threading | 1.2 | 0 | 0 | 4,428 |
30,360,110 | 2015-05-20T20:49:00.000 | 0 | 0 | 1 | 0 | python,python-module | 30,360,215 | 3 | false | 0 | 0 | You can import the same module in separate files (custom modules) as far as I know. Python keeps track of already imported modules and knows how to resolve a second import. | 1 | 0 | 0 | Is there a downside to importing the same built-in module in both my script and custom module?
I have a script that: imports my custom module and imports the built-in csv module to open a csv file and append any necessary content to a list.
I then have a method in my custom module in which i pass a path, filename and list and writes a csv, but I have to import the csv module again (in my module).
I do not understand what happens when I import the csv module twice so I wanted to know if there is a more uniformed way of doing what I'm doing or if this is ok. | Can I import a built-in module twice in both my script and custom module | 0 | 0 | 0 | 328 |
30,361,438 | 2015-05-20T22:26:00.000 | 4 | 0 | 1 | 0 | python,function,input,arguments,terminology | 30,361,573 | 4 | false | 0 | 0 | The inputs to a function are not only the arguments. The function arguments are just one form of input that a function can take. Some functions take other types of inputs. So an input is more general than an argument.
A function can take input from a file or network socket or from a global or module variable.
A class or instance method of a class can also take input from class or instance variables on that same class.
However, in this particular context, the question appears to be using the two interchangeably. | 4 | 2 | 0 | Is there a difference in the Python nomeclature wherein a function taking input is different than a function taking an argument?
Isn't the input (i.e. the data you would have a function "process") the same as when you pass an argument to a function?
The reason I'm asking is Codeacademy has a tutorial that asks the student:
Write a function called digit_sum that takes a positive integer n as
input and returns the sum of all that number's digits.
For example: digit_sum(1234) should return 10 which is 1 + 2 + 3 + 4.
(Assume that the number you are given will always be positive.)
Isn't input in this sense the same as an argument?
Codeacademy is notorious for its poorly written tutorials, so just checking. | Python function taking argument vs input | 0.197375 | 0 | 0 | 1,451 |
30,361,438 | 2015-05-20T22:26:00.000 | 1 | 0 | 1 | 0 | python,function,input,arguments,terminology | 30,361,505 | 4 | false | 0 | 0 | I guess you are confusing the expressions.
The input(s) of a function is (are) the value(s) you pass as argument(s). | 4 | 2 | 0 | Is there a difference in the Python nomeclature wherein a function taking input is different than a function taking an argument?
Isn't the input (i.e. the data you would have a function "process") the same as when you pass an argument to a function?
The reason I'm asking is Codeacademy has a tutorial that asks the student:
Write a function called digit_sum that takes a positive integer n as
input and returns the sum of all that number's digits.
For example: digit_sum(1234) should return 10 which is 1 + 2 + 3 + 4.
(Assume that the number you are given will always be positive.)
Isn't input in this sense the same as an argument?
Codeacademy is notorious for its poorly written tutorials, so just checking. | Python function taking argument vs input | 0.049958 | 0 | 0 | 1,451 |
30,361,438 | 2015-05-20T22:26:00.000 | 1 | 0 | 1 | 0 | python,function,input,arguments,terminology | 30,361,494 | 4 | false | 0 | 0 | It's the same term: The actual input of a function is the argument(s) passed when calling it.
Edit: As I learned, there are more than one answer to the question what input may mean to a function. However, in the case of this basic tutorial the simple answer is appropriate. | 4 | 2 | 0 | Is there a difference in the Python nomeclature wherein a function taking input is different than a function taking an argument?
Isn't the input (i.e. the data you would have a function "process") the same as when you pass an argument to a function?
The reason I'm asking is Codeacademy has a tutorial that asks the student:
Write a function called digit_sum that takes a positive integer n as
input and returns the sum of all that number's digits.
For example: digit_sum(1234) should return 10 which is 1 + 2 + 3 + 4.
(Assume that the number you are given will always be positive.)
Isn't input in this sense the same as an argument?
Codeacademy is notorious for its poorly written tutorials, so just checking. | Python function taking argument vs input | 0.049958 | 0 | 0 | 1,451 |
30,361,438 | 2015-05-20T22:26:00.000 | 3 | 0 | 1 | 0 | python,function,input,arguments,terminology | 30,361,617 | 4 | false | 0 | 0 | I think the term input is too ambiguous to equate to argument. Object methods could use object members as input, but these would not be passed in as arguments. Also, arguments can be outputs (e.g. an array which is filled by the method). | 4 | 2 | 0 | Is there a difference in the Python nomeclature wherein a function taking input is different than a function taking an argument?
Isn't the input (i.e. the data you would have a function "process") the same as when you pass an argument to a function?
The reason I'm asking is Codeacademy has a tutorial that asks the student:
Write a function called digit_sum that takes a positive integer n as
input and returns the sum of all that number's digits.
For example: digit_sum(1234) should return 10 which is 1 + 2 + 3 + 4.
(Assume that the number you are given will always be positive.)
Isn't input in this sense the same as an argument?
Codeacademy is notorious for its poorly written tutorials, so just checking. | Python function taking argument vs input | 0.148885 | 0 | 0 | 1,451 |
30,362,475 | 2015-05-21T00:16:00.000 | 0 | 0 | 1 | 0 | python,visual-studio-2013,pygame | 30,362,867 | 1 | false | 0 | 0 | I've tried using Eclipse with Pygame. It doesn't recognize it.
Visual-Studio2013 just probably thinks something is wrong.
The code should still run fine. | 1 | 1 | 0 | I was using Visual Studio 2013 to edit some python code, and Intellisense is giving me a green squiggly line when I import pygame. How can I fix this? | Intellisense Not Recognizing Python Module(Pygame) | 0 | 0 | 0 | 283 |
30,362,600 | 2015-05-21T00:29:00.000 | 0 | 0 | 1 | 1 | python-3.x,pip,python-requests | 53,805,505 | 6 | false | 0 | 0 | i just reinstalled the pip and it works, but I still wanna know why it happened...
i used the apt-get remove --purge python-pip after I just apt-get install pyhton-pip and it works, but don't ask me why... | 2 | 51 | 0 | I have both Python 2.7 and 3.4 installed on my Ubuntu 14.04 machine. I want to install the 'requests' module so it is accessible from Py3.4.
When I issued pip install requests on my terminal cmd line I got back:
"Requirement already satisfied (use --upgrade to upgrade): requests in /usr/lib/python2.7/dist-packages"
How can I direct pip to install requests for 3.4 even though it is already in 2.7? | How to install requests module in Python 3.4, instead of 2.7 | 0 | 0 | 1 | 316,112 |
30,362,600 | 2015-05-21T00:29:00.000 | 0 | 0 | 1 | 1 | python-3.x,pip,python-requests | 53,132,450 | 6 | false | 0 | 0 | i was facing same issue in beautiful soup , I solved this issue by this command , your issue will also get rectified .
You are unable to install requests in python 3.4 because your python libraries are not updated .
use this command
apt-get install python3-requests
Just run it will ask you to add 222 MB space in your hard disk , just press Y and wait for completing process, after ending up whole process . check your problem will be resolved. | 2 | 51 | 0 | I have both Python 2.7 and 3.4 installed on my Ubuntu 14.04 machine. I want to install the 'requests' module so it is accessible from Py3.4.
When I issued pip install requests on my terminal cmd line I got back:
"Requirement already satisfied (use --upgrade to upgrade): requests in /usr/lib/python2.7/dist-packages"
How can I direct pip to install requests for 3.4 even though it is already in 2.7? | How to install requests module in Python 3.4, instead of 2.7 | 0 | 0 | 1 | 316,112 |
30,363,813 | 2015-05-21T03:00:00.000 | 0 | 0 | 1 | 0 | python,python-2.7,python-3.x,pip,anaconda | 42,434,840 | 4 | false | 0 | 0 | (in command prompt)C:\Python34\scripts\pip.exe install pytz
this assumes your path is similar to mine. I used the default install location for all my pythons(2.7,3.4). | 1 | 11 | 0 | I have the following Python distributions installed on my Windows computer:
Python 2.7 (IDLE)
Python 3.4 (IDLE)
Anaconda (Python 3.4)
Obviously, they all store their libraries in different locations.
So, how can I easily make a targeted installation to (a different) one of them each time I need to do so?
For example, right now, I am trying to install pytz to Python 3.4 (IDLE), and pip install seems to be defaulting to Python 2.7 (IDLE), which is the first distribution of Python I had installed on my computer. | How can I control which Python distribution to pip install a package to when I have Python 2, Python 3, and Anaconda on my computer? | 0 | 0 | 0 | 16,412 |
30,364,325 | 2015-05-21T03:58:00.000 | 0 | 1 | 1 | 0 | python,file,dependencies | 30,380,080 | 1 | false | 0 | 0 | Put the data file in a place relative to the module. Use inspect module to figure out the path of the module and then read the data file using this information. | 1 | 0 | 0 | I have a module in site-packages that uses collection of binary files. Besides hard-coding the absolute paths of these files in the module, is there a better way to handle this module-datafile dependency? | Best way to handle files used by python module | 0 | 0 | 0 | 24 |
30,364,981 | 2015-05-21T05:04:00.000 | 1 | 0 | 1 | 1 | python,subprocess | 30,365,032 | 1 | true | 0 | 0 | You are doing this backwards, and shouldn't be using the child process to kill the parent process.
Instead, you will want a parent process of your "perpetually running" script (which will now be the subprocess). When an update is detected, the subprocess kills itself, and requests that the parent implement your changes. The parent will then restart the subprocess. | 1 | 0 | 0 | Im working on two scripts.
One script is perpetually running.
When it senses an update to itself, it will run the second script as a subprocess.
The second script should kill the first script, implement the changes and run the updated script.
However, I cant find a way to kill the first script. How does the child process kill its parent? | Python kill parent script (subprocess) | 1.2 | 0 | 0 | 650 |
30,365,807 | 2015-05-21T06:10:00.000 | 1 | 0 | 1 | 1 | python,objective-c,ipc | 30,365,943 | 1 | false | 0 | 0 | I would argue it's not the HTTP that adds a lot of overhead, but the TCP 3-way connection handshake.
Having said that, a lot of systems use TCP for inter-process communication, so if you want to use HTTP, it's only a very small extra load on top.
Of course with HTTP, you are creating a new connection with each request, however this is not so bad - you should be able to make each HTTP call within 1 or 2ms.
With HTTP comes a lot of nice properties like not having to maintain a persistent TCP connection, a ton of great libraries to easily make/receive your requests, and the request/response model seems to suit your system needs. | 1 | 0 | 0 | I'm designing a system like this: a Python process (let's call it "server") accepts inputs from another process ("client", written in Objective-C) on the same machine and returns outputs to the client.
What's a good architecture for this system? I mean, what's a good protocol for server/client communication? I think making the server an HTTP service is overkill because the client always lives on the same machine. | Long-running Python process that accepts inputs from another non-Python process | 0.197375 | 0 | 0 | 25 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.