Q_CreationDate stringlengths 23 23 | Title stringlengths 11 149 | Question stringlengths 25 6.53k | Answer stringlengths 15 5.1k | Score float64 -1 1.2 | Is_accepted bool 2
classes | N_answers int64 1 17 | Q_Id int64 0 6.76k |
|---|---|---|---|---|---|---|---|
2014-10-01 13:23:59.843 | Python/Django get country flag from IP | I am using django-countries to get a flag from the CountryField and it works. However, some users don't have a country set on their profiles, but I still have to display a flag. My idea was to get a country from IP and then get a flag from the country or anything similar to that.
Unfortunately, this is not happening in... | Personally I would set a generic flag as a fallback (django flag perhaps?) if user does not set their country, and to be fair there must be a reason if user doesn't. Or you can simply make that country field mandatory.
And assuming that person in that country based on their existing IP just doesn't sound right.
Imagine... | 0 | false | 1 | 3,406 |
2014-10-02 09:07:34.327 | django multiple database for multiple organisation in a single project | In my project there is two models ,ORGANISATION and CUSTUMER .Here what i am doing is while i am adding new customer to the organisation i save the organisation_id to the table CUSTOMER .But now i am worrying about the performance of my project when the database becomes huge.
So now i am planning to create new database... | It doesn't make sense to create a new database for each organization. Even if the number of customers or organizations grows to the hundreds or thousands, keeping data in a single database is your best option.
Edit:
Your original concern was that an increase in the number of organizations would impact performance. Well... | 0.386912 | false | 1 | 3,407 |
2014-10-03 11:19:42.980 | Way to compute the value of the loss function on data for an SGDClassifier? | I'm using an SGDClassifier in combination with the partial fit method to train with lots of data. I'd like to monitor when I've achieved an acceptable level of convergence, which means I'd like to know the loss every n iterations on some data (possibly training, possibly held-out, maybe both).
I know this information i... | The above answer was too short, outdated and might result in misleading.
Using score method could only give accuracy (it's in the BaseEstimator). If you want the loss function, you could either call private function _get_loss_function (defined in the BaseSGDClassifier). Or accessing BaseSGDClassifier.loss_functions cl... | 0 | false | 1 | 3,408 |
2014-10-03 12:07:18.943 | Django sqlite3 database dump | How can i create Django sqlite3 dump file (*.sql) using terminal?
There is a fabric fabfile.py with certain dump scripts, but when i try to use fab command next massage shows up:
The program 'fab' is currently not installed. To run fab please ask your administrator to install the package 'fabric'.
But there are fabri... | You could also use fixtures. And generate fixtures for your app. Dependes on what you're planing to do with them.
You'll just make a loaddata after that. | 0 | false | 1 | 3,409 |
2014-10-05 02:35:55.613 | The exe executable of my application, also opens a console | I create an exe executable of my application made in pyqt, and everything went well, but when I run the exe in windows before opening the application opens a console and while the application is open that console is also.
I need someone to tell me how to make the console does not come out, or at least not visible.
I'... | The best solution is in the post linked to in a comment to your post, but on Windows you can also set a property on a shortcut that starts the app, to have the console minimized. It still shows in taskbar, there id you need it, can be handy in some situations(like during dev to use same script as user will, but not hav... | 0 | false | 1 | 3,410 |
2014-10-06 07:04:15.737 | preclassified trained twitter comments for categorization | So I have some 1 million lines of twitter comments data in csv format. I need to classify them in certain categories like if somebody is talking about : "product longevity", "cheap/costly", "on sale/discount" etc.
As you can see I have multiple classes to classify these tweets data into.
The thing is that how do I ev... | The thing is that how do I even generate/create a training data for
such a huge data
I would suggest finding a training data set that could help you with the categories you are interested in. So let's say price related articles, you might want to find a training data set that is all about price related articles and ... | 0 | false | 1 | 3,411 |
2014-10-09 14:19:27.980 | How can I find the break frequencies/3dB points from a bandpass filter frequency sweep data in python? | The data that i have is stored in a 2D list where one column represents a frequency and the other column is its corresponding dB. I would like to programmatically identify the frequency of the 3db points on either end of the passband. I have two ideas on how to do this but they both have drawbacks.
Find maximum point ... | Assuming that you've loaded multiple readings of the PSD from the signal analyzer, try averaging them before attempting to find the bandedges. If the signal isn't changing too dramatically, the averaging process might smooth away any peaks and valleys and noise within the passband, making it easier to find the edges. T... | 0 | false | 1 | 3,412 |
2014-10-09 16:04:00.147 | how to update python 2.7 to python 3 in linux? | My OS is CentOS 7.0. It's embedded python version is 2.7, and I want to update it to Python 3.4.
when input the
print sys.path
output is:
['', '/usr/lib/python2.7/site-packages/setuptools-5.8-py2.7.egg',
'/usr/lib64/python27.zip', '/usr/lib64/python2.7',
'/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/l... | Python 2 and 3 can safely be installed together. They install most of their files in different locations. So if the prefix is /usr/local, you'll find the library files in /usr/local/lib/pythonX.Y/ where X.Y are the major and minor version numbers.
The only point of contention is generally is the file python itself, whi... | 0.673066 | false | 1 | 3,413 |
2014-10-10 15:18:43.820 | odoo mod_wsgi schedulers not working | When I deploy openerp/odoo using mod_wsgi, I found my schedulers stop working, can any one help how can I get my cron/schedulers working. If I deploy it using mod_proxy it will solve the issue but I want to deploy using mod_wsgi. | The schedulers don't work when running through wsgi because your Odoo instances are just workers. AFAIK you just run a standalone instance on a 127.0.0.1 port and it runs your scheduled tasks. | 0 | false | 1 | 3,414 |
2014-10-10 16:57:21.697 | Django apps structure | I'm learning Django but it's difficult to me to see how should I divide a project into apps?
I've worked on some Java EE systems, almost for procedures for government and all that stuff but I just can't see how to create a Django project for this purposes?
For example, if you should have to do a web app for making easi... | When you say "procedures" i guess you're talking about pages (or views in Django). So I would implement a single "app" to do that.
Remember a project is composed of apps. When you create a project a main app (with the same name of the project) is created. This is a good place to code the procedures you said.
Think of a... | 0 | false | 1 | 3,415 |
2014-10-11 04:20:14.600 | Android - ADB/MonkeyRunner Setting API Levels | I've downloaded an APK onto a Velocity Cruz Tablet running Android 2.2.1 (API Level 8), and I'm trying to install it via whatever I can manage to make work. I already had ADT on my computer (Windows 8.1 if this helps) for API Level 19 for use with my phone. So I used the SDK Manager to get API Level 8. I can't for the ... | You are trying to install an APK which is intended for a higher version onto API level 8 and thus the package manager refuses to install it. It has nothing to do with adb or monkeyrunner. | 1.2 | true | 1 | 3,416 |
2014-10-11 14:44:09.737 | How to count the number of times a button is clicked Python(tkinter) | So I am writing a program for school, and I have to make a maths quiz, the quiz needs to be out of 10 questions. I have made a button that is defined with a command that generates a new questions, clears the text box, get the answer from the dictionary, and inserts the new question into the textbox. At the moment the... | You need a variable in a global or class instance scope and a function that has access to the scope of the variable that increments the variable when called. Set the function as the command attribute of the Button so that the function is called when the button is clicked. | 0.201295 | false | 1 | 3,417 |
2014-10-11 15:34:47.067 | How to manually copy folder to /app/.heroku/python/lib/python2.7/site-packages/? | I have deployed my local python web service project to Heroku. I have all my dependencies in requirement.txt file. But, one module psycopg2 is not getting installed properly and I am getting installation error. So, I removed it from requirement.txt and thought I will push everything to heroku first, and then I will man... | You could keep the psycopg2 directory in the same directory of apps, but that's actually a hack and you should try fix on installing psycopg2 on Heroku. | 0 | false | 1 | 3,418 |
2014-10-11 19:16:29.970 | Open a URL with default broswer? | I'm new developer in QPython (experienced with python), I want to open an url with user's default browser.
I tried AndroidBrowser().open("...") but, to my surprise, I got Segmentation Fault!
So I said OK, let's try to open it manually as activity, then I tried to import jnius and got Segmentation Fault as well.
Any sug... | Apparently, this happens just in console mode, so in other QPython mods it works fine. | 1.2 | true | 1 | 3,419 |
2014-10-11 21:22:10.227 | Calculate fontsize | I'm trying to adequate the FontSize of my text into a width-height specific context. For instance, if I got a image (512x512 pixels) and I got for instance 140 characters. What would be the ideal FontSize?
In the above case, a 50 pixels Fontsize seems to be ok but what happened if there's a lot more text? the text wil... | It's pretty tricky to do analytically.
One way is trial and error. Choose a large font size and render the layout to see whether it fits
Use bisection algorithm to converge on the largest font that fits | 0.995055 | false | 1 | 3,420 |
2014-10-12 10:03:25.743 | How best to implement rooms for a text-based game? | I was thinking of making a text-based game about detectives, case-solving, with complete freedom, loads of variables, etc.
But before I get serious with it I need to know how to make rooms. E.g. you start in the hall and you type in "Go kitchen" and you go to the kitchen.
I have achieved this by using import file whe... | Do not use import to implement application logic.
In your use case, a room is the classic example of an object in object-oriented programming. You should have a class Room which defines the functionality for rooms. Individual rooms are instances of that class (later you can add subclasses, but I would not worry about t... | 1.2 | true | 1 | 3,421 |
2014-10-13 21:56:25.693 | Using pdb in emacs inserts => into my code | I'm trying to learn how to use pdb in emacs.
I run emacs in console mode and in my python file I have something like import pdb and pdb.set_trace() at the beginning of the file. I use C-c C-c to execute the buffer and pdb starts running. It works fine except that I end up with a => inserted into my code on the line tha... | Normally there is no "=>" inserted at all. What there is instead is a "=>" that is displayed but which is not part of the buffer's content. Are you sure it's really in the code and are you sure you can delete it as if it were normal text? | 1.2 | true | 1 | 3,422 |
2014-10-14 07:35:22.563 | How to store data crawled in scrapy in specfic order? | I have to crawl data from a web page in a specfic order as liked i declared fields in my item class and then have to put them in csv file.problem now occuring is there its stores data not in specfic order as like its scrapping data of any field and putting in csv file but i want it should store data as i declared in my... | For this we have to make a list in fields_to_export in the BaseItemExporter class
field_iter = ['Offer', 'SKU', 'VendorCode'] like this
and then have to pass this list in the field | 0 | false | 1 | 3,423 |
2014-10-14 10:26:54.877 | Make an object exists in all templates | I have a django and I wrote some views. I know how to pass my variables to template, but I also has some external modules with their own views, which I wont modify. Please help me understand how can I get one of my object "Menu.objects.all()" exist in all templates? So for example a I have django-registration and i wan... | You can add variables to context | 0.201295 | false | 1 | 3,424 |
2014-10-14 10:28:47.347 | How to search for JavaScript variables in a file, using Python? | I have directory with many JaveScript files. Here I want to scan each file and want to replace each JavaScript variable with string like 'str1', 'str2', 'str3', ..., 'strn' and so on.
My question is: how to identify a JavaScript variable?
Doubts:
If I say keyword after var is a variable, however there is no compulsion... | If you use an IDE such as phpstorm, it can easily find variables for you. I don't see the use in programming something in Python to do this. | -0.905148 | false | 1 | 3,425 |
2014-10-15 06:21:51.100 | Why is z3.And() slow? | I am using Z3 Python bindings to create an And expression via z3.And(exprs) where exprs is a python list of 48000 equality constraints over boolean variables. This operation takes 2 seconds on a MBP with 2.6GHz processor.
What could I be doing wrong? Is this an issue with z3 Python bindings? Any ideas on how to opti... | Using Z3 over Python is generally pretty slow. It includes parameter checks and marshaling (_coerce_expr among others).
For scalability you will be better of using one of the other bindings or bypass the Python runtime where possible. | 1.2 | true | 1 | 3,426 |
2014-10-15 20:09:28.080 | Pyramid app with handlebar.js: I don't need a template for this view; how to disable? | I'm adding a page to a complex Pyramid-based app that uses Handlebar templates.
I need a file download URL that doesn't need a template, but the system is giving me a 404
code for missing template anyway.
How do I tell a view at configuration time "do not use a handlebar template with this one?" | This was a red herring; the URL was wrong but the log file mentioned a missing template so I was focused in the wrong direction.
I had to get a custom redirection piece of code from one of the developers on this project and I have it working now. | 0.386912 | false | 1 | 3,427 |
2014-10-15 23:00:50.607 | The time to queue tasks in celery bottlenecks my application - how to parallelize .delay()? | I'm having a major problem in my celery + rabbitmq app where queuing up my jobs is taking longer than the time for my workers to perform jobs. No matter how many machines I spin up, my queuing time will always overtake my task time.
This is because I have one celery_client script on one machine doing all the queuing (c... | If queuing up your tasks takes longer than the task, how about you increase the scope of the tasks so they operate on N files at a time. So instead of queuing up 1000 tasks for 1000 files. You queue up 10 tasks that operate on 100 files at a time.
Make your task take a list of files, rather than a file for input. Then ... | 0 | false | 1 | 3,428 |
2014-10-16 20:39:21.567 | Can a "C++ application signal python script on completion"? | I'm working on developing a test automation framework. I need to start a process(a C++ application) on a remote linux host from a python script. I use the python module "paramiko" for this. However my c++ application takes sometime to run and complete the task assigned to it. So till the application completes processi... | The best way I can think of to do this is to run both of them in a web server. Use something like Windows Web Services for C++ or a native CGI implementation and use that to signal the python script.
If that's not a possibility, you can use COM to create COM objects on both sides, one in Python, and one in C++ to handl... | 0 | false | 1 | 3,429 |
2014-10-18 17:10:18.760 | Sampling parts of a vector from gaussian mixture model | I want to sample only some elements of a vector from a sum of gaussians that is given by their means and covariance matrices.
Specifically:
I'm imputing data using gaussian mixture model (GMM). I'm using the following procedure and sklearn:
impute with mean
get means and covariances with GMM (for example 5 components)... | Since for sampling only relative proportion of the distribution matters, scaling preface or can be thrown away. For diagonal covariance matrix, one can just use the covariance submarine and mean subvector that has dimensions of missing data. For covariance with off-diagonal elements, the mean and std dev of a sampling ... | 0.201295 | false | 1 | 3,430 |
2014-10-21 06:04:11.527 | web.py how to get message from request when the contentType is 'text/xml' | My situation is : A server send a request to me, the request's contentType is 'text/xml', and the request content is an xml. First I need to get the request content. But when I use 'web.input()' in 'POST' function, I couldn't get any message, the result just is ''. I know web.py can get form data from a request, so how... | Use web.data(). | 0.386912 | false | 1 | 3,431 |
2014-10-21 06:06:35.603 | when importing functions from inside builtins like os or sys is it good practice to import as protected? | in myModule.py I am importing environ from os , like
from os import environ since I am only using environ, but when I do dir(myModule) it shows environ as publicly visible , how ever should it be imported as protected assuming some other project may also have its own environ function ? | If you're doing from os import environ, then you'll reference it as environ.
If you do import os, it's os.environ.
So depending on your needs, the second option might be better. The first will look better and read easier, whereas the second avoids namespace pollution. | 1.2 | true | 1 | 3,432 |
2014-10-21 06:12:19.650 | Using PythonAnywhere as a game server | I'm building a turn-based game and I'm hoping to implement client-server style networking. I really just need to send the position of a couple of objects and some other easily encodable data. I'm pretty new to networking, although I've coded some basic stuff in socket and twisted. Now, though, I need to be able to send... | It depends what sort of connection your clients need to make to the server. PythonAnywhere supports WSGI, which means "normal" HTTP request/response interactions -- GET, POST, etc. That works well for "traditional" web pages or web apps.
If your client side needs dynamic, two-way connections using non-HTTP protocols,... | 0.386912 | false | 1 | 3,433 |
2014-10-21 13:14:05.840 | Run specific django manage.py commands at intervals | I need to run a specific manage.py commands on an EC2 instance every X minutes. For example: python manage.py some_command.
I have looked up django-chronograph. Following the instructions, I've added chronograph to my settings.py but on runserver it keeps telling me No module named chronograph.
Is there something I'm m... | First, install it by running pip install django-chronograph. | 0 | false | 2 | 3,434 |
2014-10-21 13:14:05.840 | Run specific django manage.py commands at intervals | I need to run a specific manage.py commands on an EC2 instance every X minutes. For example: python manage.py some_command.
I have looked up django-chronograph. Following the instructions, I've added chronograph to my settings.py but on runserver it keeps telling me No module named chronograph.
Is there something I'm m... | I would suggest you to configure cron to run your command at specific times/intervals. | 0.135221 | false | 2 | 3,434 |
2014-10-21 14:00:35.233 | 32bit exe on 64bit Python using py2exe | I need to make an 32bit exe file using py2exe. The problem is that my machine and Python are 64bit. Is there some simple way how to make 32bit using 64bit Python and py2exe?
I heard that I should uninstall py2exe and install new py2exe 32bit, can this help me?
EDIT: If 32bit py2exe works, can I install 32bit py2exe nex... | You should install the 32-bit python (in a separate directory, you can do it on the same machine). Install 32-bit py2exe for this 32-bit Python installation plus all Python packages that you need. Then you can build a 32-bit eecutable. | 1.2 | true | 1 | 3,435 |
2014-10-22 08:17:33.057 | Checking all code paths in a project written in a scripting language for syntax-correctness | This question applies to dynamically interpreted code, I guess
In detail
Say I have a set of data processing projects that depend on a common module called tools. Down the road of development, I find out that I want to change the interface of one of the functions or methods in tools.
This interface-change might not be ... | Best answer is 'write tests'. For purely syntactical checking with some code correctness, like calling a function which does not exist like you are describing, pylint is probably the best tool. Install it with pip install pylint. | 1.2 | true | 1 | 3,436 |
2014-10-22 14:02:12.653 | How to convert numpy array into libsvm format | I have a numpy array for an image and am trying to dump it into the libsvm format of LABEL I0:V0 I1:V1 I2:V2..IN:VN. I see that scikit-learn has a dump_svmlight_file and would like to use that if possible since it's optimized and stable.
It takes parameters of X, y, and file output name. The values I'm thinking about ... | The svmlight format is tailored to classification/regression problems. Therefore, the array X is a matrix with as many rows as data points in your set, and as many columns as features. y is the vector of instance labels.
For example, suppose you have 1000 objects (images of bicycles and bananas, for example), featurize... | 1.2 | true | 1 | 3,437 |
2014-10-23 10:43:06.983 | Python cant see installed module | I downloaded Snappy library sources for working with compression and everything was great on one machine, but it didn't work on another machine. They have completely same configurations of hardware/OS + python 2.7.3.
All I was doing is "./configure && make && make install".
There were 0 errors during any of these pro... | I just found python-snappy on github and installed it via python. Not a permanent solution, but at least something. | 1.2 | true | 1 | 3,438 |
2014-10-23 13:56:19.917 | Automatic documentation generation for Dymola code | since I could not find an answer to my question neither here nor in other forums, I decided to ask it to the community:
Does anybody know if and how it is possible to realize automatic documentation generation for code generated with Dymola?
The background for this e. g. is that I want/need to store additional informat... | If you mean the Modelica model code, how does the HTML export in Dymola work for you? What's missing?
If you mean the C code generated by Dymola, the source code generation option enables more comments in the code. | 1.2 | true | 1 | 3,439 |
2014-10-26 17:18:47.110 | AWS EMR perform "bootstrap" script on all the already running machines in cluster | I have one EMR cluster which is running 24/7. I can't turn it off and launch the new one.
What I would like to do is to perform something like bootstrap action on the already running cluster, preferably using Python and boto or AWS CLI.
I can imagine doing this in 2 steps:
1) run the script on all the running instanc... | bootstrap script executed once the cluster started (first time or at the beginning), however AWS provide ssh to master and other nodes there you can write shell script,install libs, packages, python program , git clone your repo etc...
Hope this may be helpful.
Amit | 0 | false | 2 | 3,440 |
2014-10-26 17:18:47.110 | AWS EMR perform "bootstrap" script on all the already running machines in cluster | I have one EMR cluster which is running 24/7. I can't turn it off and launch the new one.
What I would like to do is to perform something like bootstrap action on the already running cluster, preferably using Python and boto or AWS CLI.
I can imagine doing this in 2 steps:
1) run the script on all the running instanc... | Late answer, but I'll give it a shot:
That is going to be tough.
You could install Amazon SSM Agent and use the remote command interface to launch a command on all instances. However, you will have to assign the appropriate SSM roles to the instances, which will require rebuilding the cluster AFAIK. However, any future... | 0.995055 | false | 2 | 3,440 |
2014-10-27 19:39:08.317 | Using numpy with PyDev | Although I've been doing things with python by myself for a while now, I'm completely new to using python with external libraries. As a result, I seem to be having trouble getting numpy to work with PyDev.
Right now I'm using PyDev in Eclipse, so I first tried to go to My Project > Properties > PyDev - PYTHONPATH > Ext... | I recommend you to either use the setup.py from the downloaded archive or to download the "superpack"-executable for windows, if you work on windows anyway.
In PyDev, i overcame problems with new libraries by using the autoconfig button. If that doesn't work, another solution could be deleting and reconfiguring the pyt... | 0 | false | 1 | 3,441 |
2014-10-28 20:27:09.830 | Django CAS and TGT(Ticket Granting Tickets) and service ticket validation | I'm using CAS to provide authentication for a number of secure services in my stack. The authentication front-end is implemented using Django 1.6 and the django-cas module. However, I'm reading around and I don't seem to get information on how django-cas handles Ticket Granting Tickets and also validation of service ti... | Turns out django-cas handles TGT using django sessions. However, for validation of the service ticket, you have to manually make a validation request including the ST(service ticket) granted after login and the service being accessed. | 0 | false | 1 | 3,442 |
2014-10-30 09:38:45.967 | Python: how to read 'Chunked Transfer Coding' from a request in web.py server | I am using web.py to run a server. I need to get a request from a remote server, however, the request sends me a data with Chunked Transfer Coding.
I can use web.ctx.env['wsgi.input'].read(1000) to get the data. But this is not what I need since I don't know the length of the data (because it is chunked). But if I use... | web.py runs CherryPy as the web server and it has support for handling requests with chunked transfer coding. Have you misread the documentation? | -0.201295 | false | 1 | 3,443 |
2014-10-30 15:39:47.537 | Installing NumPy and SciPy on 64-bit Windows (with Pip) | I found out that it's impossible to install NumPy/SciPy via installers on Windows 64-bit, that's only possible on 32-bit. Because I need more memory than a 32-bit installation gives me, I need the 64-bit version of everything.
I tried to install everything via Pip and most things worked. But when I came to SciPy, it co... | Follow these steps:
Open CMD as administrator
Enter this command : cd..
cd..
cd Program Files\Python38\Scripts
Download the package you want and put it in Python38\Scripts folder.
pip install packagename.whl
Done
You can write your python version instead of "38" | 0 | false | 2 | 3,444 |
2014-10-30 15:39:47.537 | Installing NumPy and SciPy on 64-bit Windows (with Pip) | I found out that it's impossible to install NumPy/SciPy via installers on Windows 64-bit, that's only possible on 32-bit. Because I need more memory than a 32-bit installation gives me, I need the 64-bit version of everything.
I tried to install everything via Pip and most things worked. But when I came to SciPy, it co... | for python 3.6, the following worked for me
launch cmd.exe as administrator
pip install numpy-1.13.0+mkl-cp36-cp36m-win32
pip install scipy-0.19.1-cp36-cp36m-win32 | 0 | false | 2 | 3,444 |
2014-11-02 11:30:39.970 | 32 bit python on 64 bit windows machine | I've downloaded pythonxy (2.7.6.1) on my new 64 bit Windows machine (Windows 7 Enterprise, SP1). When I try to run python, I get an error saying the side-by-side configuration was incorrect. WinPython 32 bit (2.7.6.3) shows the same behavior, WinPython 64 bit is fine.
However, I badly need to compile Python modules wi... | I just got an answer from one of my colleagues who told me had the exact same problem. The solution was indeed downloading and installing a version of vcredist_x86.exe, but the trick is to find the exact right one. Apparently you can get to a page somewhere from where you can choose the right version. Sorry for not bei... | 0 | false | 1 | 3,445 |
2014-11-02 14:08:08.190 | ZeroRPC auto-assign free port number | I am using ZeroRPC for a project, where there may be multiple instances running on the same machine. For this reason, I need to abe able to auto-assign unused port numbers. I know how to accomplish this with regular sockets using socket.bind(('', 0)) or with ZeroMQ using the bind_to_random_port method, but I cannot fig... | Having read details about ZeroRPC-python current state, the safest option to solve the task would be to create a central LotterySINGLETON, that would receive <-REQ/REP-> send a next free port# upon an instance's request.
This approach is isolated from ZeroRPC-dev/mod(s) modifications of use of the otherwise stable Zero... | 0 | false | 1 | 3,446 |
2014-11-03 20:00:03.590 | Import Data Efficiently from Datastore to BigQuery every Hour - Python | Currently, I'm using Google's 2-step method to backup the datastore and than import it to BigQuery.
I also reviewed the code using pipeline.
Both methods are not efficient and have high cost since all data is imported everytime.
I need only to add the records added from last import.
What is the right way of doing it?
... | There is no full working example (as far as I know), but I believe that the following process could help you :
1- You'd need to add a "last time changed" to your entities, and update it.
2- Every hour you can run a MapReduce job, where your mapper can have a filter to check for last time updated and only pick up those... | 0.386912 | false | 1 | 3,447 |
2014-11-04 02:49:32.270 | Summation of every row, column and diagonal in a 3x3 matrix numpy | My assignment is Tic-Tac_Toe using pygame and numpy. I Have almost all of the program done. I just need help understanding how to find if a winner is found. I winner is found if the summation of ANY row, column, or diagonal is equal to 3.
I have two 3x3 matrices filled with 0's. Let's call them xPlayer and oPlayer. Th... | set a bool to checks every turn if someone has won. if it returns true, then whosever turn it is has won
so, for instance, it is x turn, he plays the winning move, bool checks if someone has won,returns true, print out (player whose turn it is) has won! and end game. | -0.386912 | false | 1 | 3,448 |
2014-11-04 10:57:36.373 | Processing musical genres using K-nn algorithm, how to deal with extracted feature? | I'm developing a little tool which is able to classify musical genres. To do this, I would like to use a K-nn algorithm (or another one, but this one seems to be good enough) and I'm using python-yaafe for the feature extraction.
My problem is that, when I extract a feature from my song (example: mfcc), as my songs are... | One approach would be to take the least RMS energy value of the signal as a parameter for classification.
You should use a music segment, rather than using the whole music file for classification.Theoretically, the part of the music of 30 sec, starting after the first 30 secs of the music, is best representative for ge... | 0.673066 | false | 1 | 3,449 |
2014-11-04 13:00:35.933 | py.test -k: collecting tests takes too much time | If I do Run Unittest .... test_foo in PyCharm it takes quite long to run the test, since all tests get collected first. PyCharm uses py.test -k to run the test.
Since we have more than 1000 tests, collecting them takes some time (about 1.2 seconds). Often the test itself needs less time to execute!
Since I use this ver... | Answer to own question:
I installed pyCharm again (for other reasons) and now it uses utrunner.py.
It is much faster if I run Run 'Unittest test_foo', since not this does not collect all tests before running the test.
Problem solved. | 1.2 | true | 1 | 3,450 |
2014-11-04 19:30:31.310 | Django site-external access | A bit of a beginner question.Iv just started learning Django and can pretty much create basic stuff .Now when I want to access my website on my computer I just type in the local URL and I can access the site,other links etc.
If I want to show this to someone else how would I do it?..They wouldn't be able to just type i... | By others, do you mean someone on your local network or someone on internet.
On local network its very easy, instead starting the local developmnet server by
python manage.py runserver you can do
python manage.py runserver 10.1.0.123:8000 (assuming 10.1.0.123 is your system's ip),
then people on you local network ca... | 0 | false | 1 | 3,451 |
2014-11-05 03:43:29.830 | Using tuples in a linked list in python | My teacher wants us to recreate the dict class in Python using tuples and linkedlists (for collisions). One of the methods is used to return a value given a key. I know how to do this in a tuple ( find the key at location[0] and return location[1]) but I have no idea how I would do this in the case of a collision. Any ... | It sounds like you have some sort of hash to get a shortlist of possibilities, so, you hash your key to a small-ish number, e.g. 0-256 (as an example, it might hash to 63). You can then go directly to your data at index 63. Because you might have more than one item that hashes to 63, your entry for 63 will contain a li... | 1.2 | true | 1 | 3,452 |
2014-11-06 15:44:47.470 | use email address as datastore key using python app engine | I define my model ndb in python. I want to use the email address of a user as the key, how do I do that? user is passing in the email address through an html form. I have everything setup and working. I just don't know how to specify that the email address string is the key. | When you create your entity do this:
MyModel(id=emailAddress).put()
then use get_by_id
user = MyModel.get_by_id(emailAddress) | 1.2 | true | 1 | 3,453 |
2014-11-08 00:25:00.103 | Reading a file in home directory from another directory | I am trying to read a file in another directory. My current script is in path/to/dir. However, I want to read a file in ~/. I'm not sure how to do this.
I tried f = open("~/.file") but I am getting an error
IOError: [Errno 2] No such file or directory: '~/.file' | os.path.expanduser will help you | 0.201295 | false | 1 | 3,454 |
2014-11-09 18:20:36.290 | Python GUI library to show 16bit greyscale image | guys,
I am trying to find a python GUI library that can show and process 16bit greyscale image easily. I need to modify pixels. I have tried wxpython. It can show the images. But when I tried to convert a numpy array with single channel 16bit data to a string and loaded it in wxImage, it showed me that invalid buffer s... | You can use pyqt or pyside, but I would recommend pyqtgraph which is excellent for this sort of thing. You can build your ui in pyside and use pyqtgraph to manage image output | 1.2 | true | 1 | 3,455 |
2014-11-10 05:49:27.647 | create a class only if a package is available on the system | I have classes in a Python project that depend on an external packages. I would like these classes to be created only if their dependencies are available.
For example, how can I have a class YamlParser which only exists if yaml can be imported? | The modular and extensible solution is to put YamlParser in its own source file, and simply put the import yaml statement at the beginning. Any code which tries to import this code will fail if the required module yaml is missing. | 0 | false | 1 | 3,456 |
2014-11-10 16:44:56.403 | Can I use the Python SocketServer class for this implementation? | I've come to the realization where I need to change my design for a file synchronization program I am writing.
Currently, my program goes as follows:
1) client connects to server (and is verified)
2) if the client is verified, create a thread and begin a loop using the socket the client connected with
3) if a file on t... | SocketServer will work for you. You create one SocketServer per port you want to listen on. Your choice is whether you have one listener that handles the client/server connection plus per file connections (you'd need some sort of header to tell the difference) or two listeners that separate client/server connection and... | 1.2 | true | 1 | 3,457 |
2014-11-11 00:01:06.530 | python 2.7 - how to print with utf-8 characters? | i´m working with python version 2.7 and I need to know how to print utf-8 characters. Can anyone help me?
->I already tried putting # coding: iso-8859-1 -*- on top,
->using encode like print "nome do seu chápa".encode('iso-8859-1') also doesn't work and even
-> using print u"Nâo" doesn't work | A more complete response.
Strings have two types in Python 2, str and unicode.
When using str, you are using bytes so you can write them directly to files like stdout.
When using unicode, it has to be serialized or encoded to bytes before writing to files.
So, what happens here? print "nome do seu chápa".encode('iso-88... | 0 | false | 2 | 3,458 |
2014-11-11 00:01:06.530 | python 2.7 - how to print with utf-8 characters? | i´m working with python version 2.7 and I need to know how to print utf-8 characters. Can anyone help me?
->I already tried putting # coding: iso-8859-1 -*- on top,
->using encode like print "nome do seu chápa".encode('iso-8859-1') also doesn't work and even
-> using print u"Nâo" doesn't work | I got the answer: my console needed to be restarted. I use Spyder(from Python x,y) for development and this error occcured, so beware.
UPDATE: Spyder console seems to suck, because to get it to work, I had to use string.encode('latin1') and (now here's the catch) OPEN A NEW CONSOLE! If I try to reuse my already open co... | 0 | false | 2 | 3,458 |
2014-11-12 07:42:59.927 | how to start iPython in xshell | I just begin to use xshell in Windows 7, it looks good, but how can I enter interactive console of iPython in xshell?
In cmd of windows, when I type "ipython", it will bring me to the interactive console automatically.
However, in xshell, I've tried several command like "ipython", "ipython console", all of them would n... | According to the response from technical support team of XSHELL, it seems xshell does not support interactive shell currently.
how can I enter interactive console of iPython in xshell? In cmd of windows, when I type "ipython", it will bring me to the interactive
console automatically. However, in xshell, I've tried... | 1.2 | true | 1 | 3,459 |
2014-11-12 14:33:40.883 | Get count of reachable live objects | I'm currently debugging a memory leak in a Python program. Since none of my objects have a __del__ method, I'm assuming the issue is some sort of global variable that continues to accumulate references to reachable objects. Also, when I run using gc.debug(gc.DEBUG_LEAK), I see a lot of gc: collectable messages, but n... | It looks like gc.get_objects is what you want. Be careful using DEBUG_LEAK as it implies DEBUG_SAVEALL. DEDUG_SAVEALL causes all unreferenced objects to be saved in gc.garbage rather than freed. This means the number of objects tracked by the garbage collector can only increase. Additionally gc.get_objects does not ret... | 1.2 | true | 1 | 3,460 |
2014-11-13 18:12:03.297 | how to use custom encoding/decoding with Google Protobuf | I'm writing a python app that already has the protobuf messages defined. However, we need to use a custom wire format (I believe that's the correct term).
How do you (in python) override the base encoding functions?
I've looked in encoder.py and that's a maze of nested functors. So what do I need to monkey patch (or w... | I wouldn't recommend trying to monkey-patch the encoding functions. You will almost certainly break something.
What you can do is write an independent function which encodes a protobuf in an arbitrary way via reflection. For an example of this, see the text_format.py module in Protobufs itself. This module encodes and ... | 1.2 | true | 1 | 3,461 |
2014-11-14 05:15:59.343 | Missing widget - how do I load one (Discretize) | In ORANGE - I found that the Discretize widget is missing in my installation - where do I go to load it? | In my case this error was due to an old version of numpy being installed prior to installing Orange on a windows install. The Orange installer did not upgrade numpy even though for some widgets it requires it (the discretize widget being one of them which then fails to load silently^).
Uninstalling numpy and rerunning... | 0 | false | 1 | 3,462 |
2014-11-14 21:22:29.297 | How to run Unix commands in python installed on a windows machine? | I tried using some Unix command using the subprocess module on my Python interpreter installed on a windows 7 OS. However, it errors out saying command not found. It does recognize Windows commands though. Can I somehow use Unix commands in here too?
Thanks,
Vishal | You have to install Unix Bash for Windows, but not sure if it works correctly ... Better solution is install or virtualize some Linux distribution. | 0 | false | 1 | 3,463 |
2014-11-15 17:16:16.357 | With PyCharm, how do I reference django files when using remote AWS interpreter? | I have an existing django project on an AWS instance. I have copied my Python files to my local machine. PyCharm is configured to use the Python interpreter on the remote machine. The django file references are, naturally, not resolved by PyCharm, since the django files are not on the local machine.
Is the usual pro... | (Using PyCharm 4.0) Go to Tools --> Deployment --> and either select an existing server connection or create a new one. Under the Mappings tab, you can associate a local path with a remote path. I keep my Django project folder mapped to the one on the server.
Once you hit OK, go back to Tools --> Deployment, and you ... | 0 | false | 1 | 3,464 |
2014-11-17 04:17:52.957 | Which version of Python did pip or easy_install refer to by default? | I am a non-programmer who started to learn Python. My Mac OS X Yosemite shipped with Python 2.7.6. I installed Python 3.4.2 too. If I use pip or easy_install in the terminal to install a package, how do I know which Python I installed the package in? It seems Python 3.4.2 shipped with pip and easy_install, but I think ... | There's an easy way around it - use pip2 or pip2.7 or pip-2.7 for Python 2, and pip3 or pip3.4 or pip-3.4 for Python 3. Both version ship with easy_install, but Python 2 does not contain pip by default - you have to install it yourself. | 1.2 | true | 1 | 3,465 |
2014-11-18 19:04:52.423 | Using Anaconda modules outside of IPython | I'm interested in creating physics simulations with Python so I decided to download Anaconda. Inside of an IPython notebook I can use the pylab module to plot functions, for example, with ease. However, if I try to import pylab in a script outside of IPython, it won't work; Python claims that the pylab module doesn't e... | As a side note,
If you want to keep this functionality and move to a more script-like environment I would suggest using something like Spyder IDE. It comes with an editor linked with the IPython console that supports all the same magics as the IPython notebook. | 0 | false | 2 | 3,466 |
2014-11-18 19:04:52.423 | Using Anaconda modules outside of IPython | I'm interested in creating physics simulations with Python so I decided to download Anaconda. Inside of an IPython notebook I can use the pylab module to plot functions, for example, with ease. However, if I try to import pylab in a script outside of IPython, it won't work; Python claims that the pylab module doesn't e... | I bet it will work if you use Anaconda's Python distribution.
Try running ./anaconda/bin/python and importing it from that Python session. | 0.201295 | false | 2 | 3,466 |
2014-11-19 10:10:02.570 | IDLE crashes for certain buttons on Mac | I am running OS X 10.9.5, and IDLE w/ Python 3.4.1.
When I press the buttons for (¨/^) or (´/`), IDLE crashes and the program closes.
This causes me to lose changes to files, as well as time. My fellow students using Mac experience the same problem.
Anyone know how I can fix this? | I got the similar problem, Try British pc keyboard it works for me | 0 | false | 1 | 3,467 |
2014-11-19 16:14:19.203 | applying the same command to multiple files in multiple subdirectories | I have a directory with 94 subdirectories, each containing one or two files *.fastq. I need to apply the same python command to each of these files and produce a new file qc_*.fastq.
I know how to apply a bash script individually to each file, but I'm wondering if there is a way to write a bash script to apply the comm... | You can try find . -name "*.fastq" | xargs your_bash_script.sh, which use find to get all the files and apply your script to each one of them. | 0.386912 | false | 1 | 3,468 |
2014-11-20 04:43:06.713 | HOWTO: Use reindent.py for dummies | I am a beginner at Python and have made the mistake of mixing spaces and tabs for indentations. I see people use reindent.py, but I have no idea how to use it. please explain in the simplest way possible without trying to use too fancy words and dumb it down as best as possible as I am a beginner.
Thanks. | If you are using Eclipse IDE, there are two formatting options available that can be used to accomplish this, accessed from the Source Menu.
a) "Source > Convert space-tabs to tabs" or
b) "Source > Convert tabs to space-tabs"
I was able to format code that had 2 spaces instead of a tab using the first option. You sim... | 0 | false | 1 | 3,469 |
2014-11-20 08:11:43.403 | PyDev not appearing in Eclipse after install | I have Java version 7 and had installed PyDev version 3.9 from Eclipse Marketplace..but it's not showing up in New project or in Windows perspective in Eclipse..Can some one please tell me what i need to do ??? | Had this same problem a few days ago. You might have downloaded the wrong version of PyDev for your python version (2.7.5 or something is my python version, but I downloaded PyDev for version 3.x.x)
1) Uninstall your current version PyDev
2) you have to install the correct version by using the "Install New Software", ... | 0 | false | 1 | 3,470 |
2014-11-21 02:12:43.317 | How to use java libraries in python processing | Im using processing in python mode but I want to use the processing library sound. But I dont know how to import this into my program in python syntax.
In java its like this:
Import processing.sound.*;
Thanks | You can use add_library(processing.sound). I used it with g4p library | 0 | false | 2 | 3,471 |
2014-11-21 02:12:43.317 | How to use java libraries in python processing | Im using processing in python mode but I want to use the processing library sound. But I dont know how to import this into my program in python syntax.
In java its like this:
Import processing.sound.*;
Thanks | Use the add_library function:
add_library("sound") | 0 | false | 2 | 3,471 |
2014-11-21 16:50:49.297 | django development server, how to stop it when it run in background? | I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development? | Ctrl+c should work. If it doesn't Ctrl+/ will force kill the process. | 0.16183 | false | 5 | 3,472 |
2014-11-21 16:50:49.297 | django development server, how to stop it when it run in background? | I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development? | You can Quit the server by hitting CTRL-BREAK. | -0.121841 | false | 5 | 3,472 |
2014-11-21 16:50:49.297 | django development server, how to stop it when it run in background? | I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development? | From task manager you can end the python tasks that are running.
Now run python manage.py runserver from your project directory and it will work. | 0.040794 | false | 5 | 3,472 |
2014-11-21 16:50:49.297 | django development server, how to stop it when it run in background? | I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development? | well it seems that it's a bug that django hadn't provided a command to stop the development server . I thought it have one before~~~~~ | 0.240117 | false | 5 | 3,472 |
2014-11-21 16:50:49.297 | django development server, how to stop it when it run in background? | I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development? | As far as i know ctrl+c or kill process is only ways to do that on remote machine.
If you will use Gunicorn server or somethink similar you will be able to do that using Supervisor. | 0.121841 | false | 5 | 3,472 |
2014-11-22 19:06:19.233 | Trouble grasping MIBs with PySNMP | I am fairly new to the SNMP protocol and have only been introduced to it recently in my computer networking course.
I understand how the manager sends Gets, Sets, GetNext, GetBulk and all that, it will catch Traps and such. One thing I don't entirely understand is the MIB
From what I gather, the MIB is chillen on an a... | Manager needs to know the variables to query for something specific. The variables can be identified by OIDs or MIB objects names.
MIBs give Manager information such as:
Human friendly symbolic names associated with the OIDs
Types of values associated with particular OIDs
Hints on variable access permissions that are ... | 0 | false | 1 | 3,473 |
2014-11-22 19:51:34.410 | Python: Calculate all values of dictionary to z-scores | I have a dictionary, for which I want to calculate all values to zscores. Now I do know how to how to compute the zscore of an array, but have no idea how to do this for a dictionary. Does anybody have some tips?
Thanks! | assuming you use Scipy to calculate the Z-score and not manually
from scipy import stats
d = {'keys':values, ...}
dict_values = d.values()
z = stats.zscore(dict_values)
This will return a Numpy array with your z scores | 0 | false | 1 | 3,474 |
2014-11-23 16:30:42.723 | Using cross-validation to find the right value of k for the k-nearest-neighbor classifier | I am working on a UCI data set about wine quality. I have applied multiple classifiers and k-nearest neighbor is one of them. I was wondering if there is a way to find the exact value of k for nearest neighbor using 5-fold cross validation. And if yes, how do I apply that? And how can I get the depth of a decision tre... | I assume here that you mean the value of k that returns the lowest error in your wine quality model.
I find that a good k can depend on your data. Sparse data might prefer a lower k whereas larger datasets might work well with a larger k. In most of my work, a k between 5 and 10 have been quite good for problems with... | 0 | false | 1 | 3,475 |
2014-11-24 22:41:39.640 | how to get python 2.7 into the system path on Redhat 6.5 Linux | I have installed (or so I think) python 2.7.5. When I type "Python --version" I get python2.7.5
I've narrowed this down to:
When I run "python" in a terminal in my /Home/UsrName/ directory it is version 2.7.5
However when I run "python" in a terminal in /Home/UserName/Downloads/Ipython directory I get 2.6.6
I went in... | You have your $PATH fine, as you can run python without specifying full path, aka /usr/bin/python.
You get 2.6.6 in Ipython directory because it has python executable in it, named, wild guess - python. 2.7.5 is installed system-wide. To call 2.7.5 from the Ipython dir, use full path /usr/bin/python, or whatever which ... | 0 | false | 2 | 3,476 |
2014-11-24 22:41:39.640 | how to get python 2.7 into the system path on Redhat 6.5 Linux | I have installed (or so I think) python 2.7.5. When I type "Python --version" I get python2.7.5
I've narrowed this down to:
When I run "python" in a terminal in my /Home/UsrName/ directory it is version 2.7.5
However when I run "python" in a terminal in /Home/UserName/Downloads/Ipython directory I get 2.6.6
I went in... | I think I know what is happening - abarnert pointed out that the cwd (".") may be in your path which is why you get the local python when you're running in that directory. Because the cwd is not normally setup in the global bashrc file (/etc/bashrc) it's probably in your local ~/.bashrc or ~/.bash_profile. So edit thos... | 0 | false | 2 | 3,476 |
2014-11-25 01:47:42.690 | Python program needs full path in Notepad++ | Not a major issue but just an annoyance I've come upon while doing class work. I have my Notepad++ set up to run Python code straight from Notepad++ but I've noticed when trying to access files I have to use the full path to the file even given the source text file is in the same folder as the Python program being run.... | In the properties of the shortcut that you use to start Notepad++, you can change its working directory, to whichever directory you're more accustomed to starting from in Python. You can also begin your python program with the appropriate os.chdir() command. | 0.386912 | false | 1 | 3,477 |
2014-11-25 19:49:51.540 | How to modify Django admin ManyToManyField text? | I have "Articles" and "Modules" apps. Inside "Modules" app there is model which have to display articles and they're linked by ManyToManyField in "Modules".
My question is how to modify text value in select field in Django admin? As default it displays names of articles, but i want also some information from Article mo... | The Django Admin select menus use the unicode value of the model instance to populate things like menus. Whatever your __unicode__ method returns should be what is in the select menu. | 0 | false | 1 | 3,478 |
2014-11-26 09:05:05.340 | Is there a way to integrate a processing sketch written in Python in a webpage? | The title says it all.
I spent a lot of time designing a sketch in Processing using the Python language.
Now, I would like to put the sketch on a webpage.
Of course, I could just translate the sketch from python language to javascript and use a javascript library for processing.
However, this would be a very lengthy pr... | At the moment there is no straightforward way to do this. But some workarounds can be found. For example, since Processing's python mode is using Jython language (Python on JVM) you can do the following:
Compile the Jython code to Java bytecode
Decompile Java bytecode to real Java code
Use processing.js to make the sk... | 0 | false | 1 | 3,479 |
2014-11-27 12:34:57.853 | Sphinx documentation: how to reference a Python property? | How can I reference a method, decorated with @property?
For simple methods, :py:meth: is working fine, but not for properties: it does not create a link to them. | I use :py:obj: instead.
:py:attr: won't work for me when the property is in another page. | 0 | false | 1 | 3,480 |
2014-11-27 19:37:11.963 | Training a LDA model with gensim from some external tf-idf matrix and term list | I have a tf-idf matrix already, with rows for terms and columns for documents. Now I want to train a LDA model with the given terms-documents matrix. The first step seems to be using gensim.matutils.Dense2Corpus to convert the matrix into the corpus format. But how to construct the id2word parameter? I have the list of... | id2word must map each id (integer) to term (string).
In other words, it must support id2word[123] == 'koala'.
A plain Python dict is the easiest option. | 0.386912 | false | 1 | 3,481 |
2014-11-28 16:11:42.497 | Generate a random point in space (x, y, z) with a boundary | I would like to generate a uniformly random coordinate that is inside a convex bounding box defined by its (at least) 4 vertices (for the case of a tetrahedron).
Can someone suggest an algorithm that I can use?
Thanks!
If a point is generated in a bounding box, how do you detect whether or not it is outside the geomet... | There's a lot that's unspecified in your question, such as what distribution you want to use. For the sake of this answer, I'll assume a uniform distribution.
The straightforward way to handle an arbitrary volume uniform distribution is to choose three uniformly random numbers as coordinates in the range of the boundin... | 1.2 | true | 1 | 3,482 |
2014-11-28 16:39:08.463 | IPython Notebook previous cell content | Is it possible in an IPython-Notebook cell to get the previous (above) cell content ?
I can see previous output with %capture magic function but I don't find how to get the previous cell content. | I didn't find how to get the previous content cell in a cell.
But I found another solution, creating a custom magic notebook function to capture the cell content and work with that. | 1.2 | true | 1 | 3,483 |
2014-11-28 17:56:08.303 | How to import from saved QPython file? | With QPython on Kindle fire .. I use QEdit to write & save a .py file .. say bob.py ..
But when I switch to Console, I can't IMPORT from bob ..
Can someone tell me how to do this?
John (new to QPython) | The comment from Yulia V got me thinking, maybe I just needed to append the location of "Scripts" to the sys.path, and Yep, that worked fine!!
Thanks Yulia! | 0 | false | 2 | 3,484 |
2014-11-28 17:56:08.303 | How to import from saved QPython file? | With QPython on Kindle fire .. I use QEdit to write & save a .py file .. say bob.py ..
But when I switch to Console, I can't IMPORT from bob ..
Can someone tell me how to do this?
John (new to QPython) | I think you can save the module file into the same directory which you script locates or /sdcard/com.hipipal.qpyplus/lib/python2.7/site-packages/ | 0 | false | 2 | 3,484 |
2014-11-28 19:32:29.730 | How do I run python in Codeanywhere? | I just started with learning Python 3.4.x.
I really want to keep learning and developing on all devices. That's why I'm using Codeanywhere.
But the problem is I don't know how to execute a .py file in Codeanywhere.
Is there a method to do it?
Thanks | You run your .py files just like you would if you were running the python commandline in windows.
ex.
python myfile.py
Open a SSH terminal from your python devbox and type it in the cmd line and you're all set. | 0.386912 | false | 1 | 3,485 |
2014-11-29 03:58:00.320 | python - how to have video file(data) into list? | I am doing a project on media (more like a video conferencing).
The problem is , although I am able to send text/string data from one peer to another, I am still not sure about video files.
Using gstreamer, I am able to capture video stream from my webcam and doing the encoding/coding (H.264) , I am able to write the ... | If you are to send a video(with audio) to a peer in the network, you would better use RTP(Real time Transfer Protocol) which works on top of UDP. RTP provides feature of timestamps and profile which help you syncronize the audio and video sent through two ports. | 1.2 | true | 1 | 3,486 |
2014-11-29 15:58:41.700 | ttyUSB0 not found on Raspberry Pi | I'm making a code where the pi gets a serial input from a usb-serial board(From the sparkfun RFID starter kit), how can I make this work?
error
Traceback (most recent call last):
File "main", line 22, in
ser = s.Serial('ttyUSB0', 9600, timeout=10000)
File "/usr/lib/python2.7/dist-packages/serial/serialutil.... | It's the cable. Check the USB cable. All of that yanking | 0 | false | 1 | 3,487 |
2014-11-29 22:02:24.363 | Efficiently applying text widget tags in tkinter text widgets | I'm trying to implement syntax highlighting for text in a Text widget.
I use an external library to lexically analyse the text and give me the tokenised text. After that I go over all the words in the text and apply tag to their position in the text widget so that I can style each word.
My concern now is how do I dea... | One possible answer is to do something like Idle does. As a user hits each key, its custom incremental parser tags identifiers that are a keyword, builtin, or def/class name*. It also tags delimited char sequences that are a string or comment. I does what can be done quickly enough.
For example, if one types printer ... | 0.386912 | false | 1 | 3,488 |
2014-11-30 01:01:16.643 | DLL loading (C#/IronPython/C#) in VS2012 | I want to debug separate pieces of my application in Visual Studio 2012.
I have C# executable which works with Oracle.DataAccess dll. It works fine.
Within it IronPython runtime is invoked and it works fine too.
Within these IronPython modules object from main C# application is invoked and it works fine with Oracle dll... | You can try replicating what "works for me". Create a solution containing:
python project (ironpython)
C# project
Add a reference to desired oracle library (Oracle.DataAccess.dll) to C# project using the standard VS mechanism. C# project should also contains a post build step to copy the resulting dll and pdb into th... | 1.2 | true | 1 | 3,489 |
2014-11-30 19:08:02.543 | network animation with static nodes in python or even webgl | So I have a particular task I need help with, but I was not sure how to do it. I have a model for the formation of ties between a fixed set of network nodes. So I want to set up a window or visualization that shows the set of all nodes on some sort of 2-dimensional or 3-dimensional grid. Then for each timestep, I want ... | This looks like a good use-case for Vispy indeed. You'd need to use a PointVisual for the nodes, and a LineVisual for the edges. Then you can update the edges in real time as the simulation is executed.
The animation would also work in the IPython notebook with WebGL.
Note that other graphics toolkits might also work f... | 1.2 | true | 1 | 3,490 |
2014-12-01 10:39:48.047 | How do i pass on control on to different terminal tab using perl? | I am trying to automate a scenario in which, I have a terminal window open with multiple tabs open in it. I am able to migrate between the tabs, but my problem is how do i pass control to another terminal tab while i run my perl script in a different tab.
Example: I have a terminal open with Tab1,Tab2,Tab3,Tab4 open in... | The main thing to understand is that each tab has a different instance of terminal running, more importantly a different instance of shell (just thought I would mention as it didnt seem like you were clear about that from your choice of words). So "passing control" in such a scenario could most probably entail inter-pr... | 0.386912 | false | 1 | 3,491 |
2014-12-02 17:36:31.497 | Training a Machine Learning predictor | I have been trying to build a prediction model using a user’s data. Model’s input is documents’ metadata (date published, title etc) and document label is that user’s preference (like/dislike). I would like to ask some questions that I have come across hoping for some answers:
There are way more liked documents than d... | You either need to under-sample the bigger class (take a small random sample to match the size of the smaller class), over-sample the smaller class (bootstrap sample), or use an algorithm that supports unbalanced data - and for that you'll need to read the documentation.
You need to turn your words into a word vector. ... | 1.2 | true | 1 | 3,492 |
2014-12-02 21:38:40.960 | Delete cells in Excel using Python 2.7 and openpyxl | I'm trying to delete cells from an Excel spreadsheet using openpyxl. It seems like a pretty basic command, but I've looked around and can't find out how to do it. I can set their values to None, but they still exist as empty cells. worksheet.garbage_collect() throws an error saying that it's deprecated. I'm using t... | In openpyxl cells are stored individually in a dictionary. This makes aggregate actions like deleting or adding columns or rows difficult as code has to process lots of individual cells. However, even moving to a tabular or matrix implementation is tricky as the coordinates of each cell are stored on each cell meaning ... | 1.2 | true | 1 | 3,493 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.