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
2013-08-07 02:10:19.867
Use of Mechanize Library with Python 2.7 and Django
How do I use the mechanize library with Django? I read online that I could put it in a directory (e.g. /lib/) and include as needed. The problem is, the the source I had found didn't show how to use it from configuration to initial use. Unfortunately, I also looked high and low elsewhere on google with nothing to find....
As per comments, the answer is: pip install mechanize then just open a python interpreter and import mechanize to confirm. That should be it, you can start using mechanize in your Django project.
0
false
1
2,714
2013-08-07 17:16:24.917
Why doesn't the index/list of an array begin with 1?
Is there any special reason? I know that that's how the language has been written, but can't we change it? And what are the challenges we'd face if the index start with 1?
The basic reason behind it is that the computer remembers the address at wich the first part of any variable/object is stored. So the index represents the "distance" in between that and what you're looking for, so the first one is 0 away, the second 1...
0.240117
false
3
2,715
2013-08-07 17:16:24.917
Why doesn't the index/list of an array begin with 1?
Is there any special reason? I know that that's how the language has been written, but can't we change it? And what are the challenges we'd face if the index start with 1?
In C and C++, array indexing is syntactic sugar for dereferencing an offset pointer. That is, array[i] is equivalent to *(array + i). It makes sense for pointers to point to the beginning of their block of memory, and this implies that the first element of the array needs to be *array, which is just array[0].
0.240117
false
3
2,715
2013-08-07 17:16:24.917
Why doesn't the index/list of an array begin with 1?
Is there any special reason? I know that that's how the language has been written, but can't we change it? And what are the challenges we'd face if the index start with 1?
One thing is that, you can reference and navigate the arrays using pointers. Infact the the array operations decay to pointer arithmetic at the back end. Suppose you want to reach a nth element of an array then you can simply do (a + n) where a is the base address of an array(1-dimension), but if the subscript starts ...
0.081452
false
3
2,715
2013-08-07 20:42:28.817
Boto randomly connecting to different regions for S3 transfers
I have several S3 buckets containing a total of 40 TB of data across 761 million objects. I undertook a project to copy these objects to EBS storage. To my knowledge, all buckets were created in us-east-1. I know for certain that all of the EC2 instances used for the export to EBS were within us-east-1. The problem ...
The problem ended up being an internal billing error at AWS and was not related to either S3 or Boto.
0
false
1
2,716
2013-08-07 21:37:06.100
What are the differences between the threading and multiprocessing modules?
I am learning how to use the threading and the multiprocessing modules in Python to run certain operations in parallel and speed up my code. I am finding this hard (maybe because I don't have any theoretical background about it) to understand what the difference is between a threading.Thread() object and a multiprocess...
Multiple threads can exist in a single process. The threads that belong to the same process share the same memory area (can read from and write to the very same variables, and can interfere with one another). On the contrary, different processes live in different memory areas, and each of them has its own variables. In...
0.999999
false
1
2,717
2013-08-08 06:50:56.587
cx_freeze - how debug app
I have small Python3 application for manipulating some specific XML files. For gui I am using PySide and for parsing files -lxml. I had some troubles with freezing it with cx_freeze but finally succeed. Now - some parts of application simply don't work... no error message & no log created. For example on Enter press ...
Take a look at the pyside documentation and see if there is a redirect output to a window option - it is entirely possible that something is causing an error that is being printed out to nowhere.
0
false
1
2,718
2013-08-09 10:36:59.023
nearest k neighbours that satisfy conditions (python)
I have a slight variant on the "find k nearest neighbours" algorithm which involves rejecting those that don't satisfy a certain condition and I can't think of how to do it efficiently. What I'm after is to find the k nearest neighbours that are in the current line of sight. Unfortunately scipy.spatial.cKDTree doesn't...
If you are looking for the neighbours in a line of sight, couldn't use an method like cKDTree.query_ball_point(self, x, r, p, eps) which allows you to query the KDTree for neighbours that are inside a radius of size r around the x array points. Unless I misunderstood your question, it seems that the line of sight is...
0
false
1
2,719
2013-08-09 12:26:52.800
Django/Python requirements.txt get always recent package
When I create my requirements.txt I always want it to get the most recent package, without me having to know a version number, how can I do this? For example I want this to get the latest version of Django: requirements.txt Django>= South==0.7.6
Well, this is a bit of a bad idea. The idea of having a requirements.txt is that you can perfectly replicate what you have on the machine you develop on, i.e exactly the environment it works on. You can do what you want by just not specifying a version number in requirements.txt, but you are better off manually upgradi...
0.545705
false
1
2,720
2013-08-09 15:55:32.050
OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
when connecting to mysql database in Django ,I get the error. I'm sure mysql server is running. /var/run/mysqld/mysqld.sock doesn't exist. When I run $ find / -name *.sock -type s, I only get /tmp/mysql.sock and some other irrelevant output. I added socket = /tmp/mysql.sock to /etc/my.cnf. And then restared mysql, exi...
I faced this problem when connecting MySQL with Django when using Docker. Try 'PORT':'0.0.0.0'. Do not use 'PORT': 'db'. This will not work if you tried to run your app outside Docker.
0
false
3
2,721
2013-08-09 15:55:32.050
OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
when connecting to mysql database in Django ,I get the error. I'm sure mysql server is running. /var/run/mysqld/mysqld.sock doesn't exist. When I run $ find / -name *.sock -type s, I only get /tmp/mysql.sock and some other irrelevant output. I added socket = /tmp/mysql.sock to /etc/my.cnf. And then restared mysql, exi...
in flask, you may use that app=Flask(__name__) app.config["MYSQL_HOST"]="127.0.0.1 app.config["MYSQL_USER"]="root"...
0
false
3
2,721
2013-08-09 15:55:32.050
OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
when connecting to mysql database in Django ,I get the error. I'm sure mysql server is running. /var/run/mysqld/mysqld.sock doesn't exist. When I run $ find / -name *.sock -type s, I only get /tmp/mysql.sock and some other irrelevant output. I added socket = /tmp/mysql.sock to /etc/my.cnf. And then restared mysql, exi...
You need to change your HOST from 'localhost' to '127.0.0.1' and check your django app :)
0
false
3
2,721
2013-08-11 03:02:04.637
Multiprocessing in python on Mac OS
Any basic information would be greatly appreciated. I am almost completed with my project, all I have to do now is run my code to get my data. However, it takes a very long time, and it has been suggested that I make my code (python) available to multiprocess. However, I am clueless on how to do this and have had a lot...
You need to use the multiprocessing module. Both modules enable concurrency, but only multiprocessing enables true parallelism. Due to Python's Global Interpreter Lock, multiple threads cannot execute simultaneously. Keeping all 16 of your processors busy comes at the cost of a certain increased difficulty in programm...
1.2
true
1
2,722
2013-08-12 04:47:05.947
finding a set of ranges that a number fall in
I have a 200k lines list of number ranges like start_position,stop position. The list includes all kinds of overlaps in addition to nonoverlapping ones. the list looks like this [3,5] [10,30] [15,25] [5,15] [25,35] ... I need to find the ranges that a given number fall in. And will repeat it for 100k numbers. For ex...
How about, sort by first column O(n log n) binary search to find indices that are out of range O(log n) throw out values out of range sort by second column O(n log n) binary search to find indices that are out of range O(log n) throw out values out of range you are left with the values in range This should be O(n log...
0
false
1
2,723
2013-08-14 03:39:01.737
Opening Series of Gifs in Chrome Using webbrowser
I have a series of local gif files. I was wondering how I would be able to open this series of local gifs using the webbrowser module. I am, by the way, running on Mac OS X Snow Leapord. Whenever I try to use the webbrowser.open('file:gif_name') snippet, my computer throws the error 0:30: execution error: Bad name for ...
Use this line: webbrowser.open('file://'+os.getcwd()+'/gif_name.gif') and change the default app to view pictures to Chrome.
1.2
true
1
2,724
2013-08-16 21:44:10.887
SciPy 0.12.0 and Numpy 1.6.1 - numpy.core.multiarray failed to import
I just installed ArcGIS v10.2 64bit background processing which installs Python 2.7.3 64bit and NumPy 1.6.1. I installed SciPy 0.12.0 64bit to the same Python installation. When I opened my Python interpreter I was able to successfully import arcpy, numpy, and scipy. However, when I tried to import scipy.ndimage I go...
So it seems that the cause of the error was incompatibility between scipy 0.12.0 and the much older numpy 1.6.1. There are two ways to fix this - either to upgrade numpy (to ~1.7.1) or to downgrade scipy (to ~0.10.1). If ArcGIS 10.2 specifically requires Numpy 1.6.1, the easiest option is to downgrade scipy.
1.2
true
1
2,725
2013-08-18 15:43:02.070
What part of installed Python does python4delphi use?
I have Python 2.7 installed in "C:\Python27". Now I run 1st demo of Python4delphi with D7, which somehow uses my Py2.7 install folder. If I rename Python folder, demo can't run (without error message). I didn't change properties of a demo form. What part/file does py4delphi use from my Python folder?
python4delphi is a loose wrapper around the Python API and as such relies on a functioning Python installation. Typically on Windows this comprises at least the following: The main Python directory. On your system this is C:\Python27. The Python DLL which is python27.dll and lives in your system directory. Registry se...
1.2
true
1
2,726
2013-08-19 06:09:51.400
Is celery's apply_async thread or process?
Can someone tell me whether Celery executes a task in a thread or in a separate child process? The documentation doesn't seem to explain it (read it like 3 times). If it is a thread, how does it get pass the GIL (particularly whom and how an event is notified)? How would you compare celery's async with Twisted's react...
Can someone tell me whether Celery executes a task in a thread or in a separate child process? Neither, the task will be executed in a separate process possibly on a different machine. It is not a child process of the thread where you call 'delay'. The -C and -P options control how the worker process manages it's ow...
0.673066
false
1
2,727
2013-08-19 13:23:06.447
Selecting random rows with python and writing to a new file
I need to open a csv file, select 1000 random rows and save those rows to a new file. I'm stuck and can't see how to do it. Can anyone help?
The basic procedure is this: 1. Open the input file This can be accomplished with the basic builtin open function. 2. Open the output file You'll probably use the same method that you chose in step #1, but you'll need to open the file in write mode. 3. Read the input file to a variable It's often preferable to read th...
-0.201295
false
1
2,728
2013-08-20 08:57:32.947
How to authenticate android user POST request with Django REST API?
As of now, I have a Django REST API and everything is hunky dory for the web app, wherein I have implemented User Auth in the backend. The "login_required" condition serves well for the web app, which is cookie based. I have an Android app now that needs to access the same API. I am able to sign in the user. What I nee...
You may want to use the Django Sessions middleware, which will set a cookie with a django session_id. On the following requests, the sessions middleware will set an attribute on your request object called user and you can then test if user is authenticated by request.user.is_authenticated() ( or login_required decorat...
0
false
1
2,729
2013-08-20 18:33:30.180
Calling c++ function, from Python script, on a Mac OSX
I've a c++ code on my mac that uses non-standard lybraries (in my case, OpenCV libs) and need to compile this so it can be called from other computers (at least from other mac computers). Runned from python. So I've 3 fundamental questions: How to compile my project so it can be used from python? I've read that I shou...
How to compile my project so it can be used from python? I've read that I should create a *.so file but how to do so? That depends on your compiler. By example with g++: g++ -shared -o myLib.so myObject.o Should it work like a lib, so python calls some specific functions, chosen in python level? Yes it is, in my...
0.081452
false
1
2,730
2013-08-21 23:30:45.447
Python saving data and retrieving it
I want to make a python program that lets you track how much certain people owe you. It should ask you your name and the people's names the first time it is run. Afterwards it should say something along the lines of "Welcome back (name)" and be able to retrieve the people's names and how much they owe you, as well as a...
Your program should: Check if a file (with a fixed filename) exists (or has any contents). If it does not exist, then obtain data from the user and save it in the file. If it does exist, read it. Display it to the user. Ask the user an input of "quit" (to exit) or a person name. If a person name, ask the user for t...
1.2
true
1
2,731
2013-08-21 23:35:27.673
how to define reserved template for python file for eclipse
I need to use a default template for my files, such as first heading : description of file, author, shebang line and so on. But PyDev and eclipse don't do it for me. When i want to create a new file in my project, how i have them?
You can define the templates used in PyDev (both for code-completion and for new modules) in window > preferences > pydev > editor > templates. Anything with the context 'new module' there will be shown to you when you create a new module (and you can have many templates, such as one for unittests, empty modules, class...
1.2
true
1
2,732
2013-08-22 16:24:59.327
How to get content of element in embeded python codes in web2py view
I want to know how I can get content of a certain element by a dynamic id/name in embeded python codes in web2py view page? Basically I want something like: {{for task in tasks:}} ... {{=TEXTAREA(task['remark'], _name='remark'+str(task['id']), _id='remark'+str(task['id']), _rows=2)}} {{=A('OK', _class='button', _href=U...
I used a Form to achieve this. Working quite well.
1.2
true
1
2,733
2013-08-22 21:08:38.647
wxpython csv reader crashing while processing
I have built a csv reader with. It iterats through a file and gives results based on search terms. I am reading 3 gig files. When I let it iterate through the file it works fine. But if I even touch the wxpython window after processing has begun the app stops responding then crashes. My best guess is I have to som...
During a heavy operation a wx frame is "stuck" waiting on the process to finish. You're best solution is to create a worker thread and let it do the heavy job for you.
0.201295
false
1
2,734
2013-08-23 03:00:51.513
I'm trying to make a password creator
I've been trying to make a password creator to create a password for a assessment and one of the things that's needed is if the password doesn't have at least 2 numbers in it will print a error asking for a password with at least two numbers. I do not know how to do this and I was just wondering if you could give me a ...
If the problem is indeed to create a new password, I explain how to do it, but no code: Use the random.SystemRandom() if you want secure passwords. First create N characters from the set of allowed characters, where N is the length of your password. Then check if there are at least 2 digits. If there are less than 2 di...
0
false
1
2,735
2013-08-23 16:05:17.583
Google App Engine, Change which python version
I'm trying to use the GCS client library with my app engine app and I ran into this - "In order to use the client library in your app, put the /src/cloudstorage directory in your sys.path so Python can find it." First, does this mean I need to move the directory into my sys.path OR does it need to add the ~/src/clouds...
In GAE change the python path via Preferences settings, set Python Path to match your python 27 path.
0.386912
false
1
2,736
2013-08-26 02:45:13.943
Python win32com constants
I'm currently wondering how to list the constants in win32com in python, for example using excel win32com.client.Dispatch('Excel.Application') Is there a way to display all constants using win32com.client.Constants ? Or does someone know where i could find win32com's documentation ? Because all the links I found are d...
To find out what Com applications you can use... See http://timgolden.me.uk/pywin32-docs/html/com/win32com/HTML/QuickStartClientCom.html Basically you can't know for sure. Sorry. Each computer will have a different list based on the software installed, the webpage I linked suggests using pyWins ComBrowser, however I ha...
1.2
true
1
2,737
2013-08-26 04:58:09.307
in SciTE, how to make the whole block of code have less margin in python
My English just as my programming, are not good, apologize. I'm using SciTE to run python code. I added a while statement to the outside of a block of code. Then, in order to indent the next block of code, I selected it and pressed tab. After some more coding, I now want to delete the while statement and dedent (uninde...
Highlight the block of code and press shift+tab
1.2
true
1
2,738
2013-08-26 14:30:56.480
Understanding why multithreading could not read a global variable
With this global variable defined in the script upper focus t0 = time.time() ## is global and this function def timestamp(t0): ... return ("[" + str(time.time()-t0)+ "] ") ## time stamping from initial start I'm trying to timestamp every print() of my script with print(timestamp(t0) + ""...whatever..."") This...
Each process has a separate instance of the global variable. If you want each process to see the same value, you'll need to pass that value as an argument to each process.
1.2
true
1
2,739
2013-08-27 00:42:40.183
Can i generate reporting using google calendar
I am planning my all day activities in Google calendar LIke Offcie time sleeping playing Gym I am happy with Google but issue is that i don't get reporting so that i can see how much time is spent in each category. I know python and django so i was thinking is it possible that i still log all events in Google calenda...
I'm probably going to write a Python script for this soon. I had written a reporting app before in C#, but it's badly written and I think Google has changed their API again so it's not working anymore. The way I did it was to use tags. I wanted my total work hours per client. I would enter them into Google Calendar a...
0
false
1
2,740
2013-08-27 01:35:35.183
Retrieve 10 random lines from a file
I have a text file which is 10k lines long and I need to build a function to extract 10 random lines each time from this file. I already found how to generate random numbers in Python with numpy and also how to open a file but I don't know how to mix it all together. Please help.
It is possible to do the job with one pass and without loading the entire file into memory as well. Though the code itself is going to be much more complicated and mostly unneeded unless the file is HUGE. The trick is the following: Suppose we only need one random line, then first save first line into a variable, then...
0.067922
false
1
2,741
2013-08-27 04:01:03.880
sublime text remove repository
I have installed package control, and I use it frequently, the problem is that I added a new repository and it is wrong, and when I try to install other package, sublime throw exception, somebody know how can I remove a repository in sublime text. Note: I have the problem in a OSX.
You can also access the Package Control settings from the Menu bar under: Preferences -> Package Settings -> Package Control -> Settings - User. From there you can edit or remove the bad URL.
0.201295
false
1
2,742
2013-08-27 09:56:20.113
appending object references to python list with boost
I have a vector of pointers to objects in c++ and want to expose it to python with a list. So far I gave a reference of a python list to c++. I figured pointers are not suitable for python so I read about how to make a pointer to a reference by (*obj) it. But when I call: myList.append((*obj)); python just crashes. Can...
Okay so the Problem appears when the type is not declared for boost::python. !
0
false
1
2,743
2013-08-27 11:14:01.773
How debug or trace DBus?
I writing Dbus service implementing some protocol. My service sends to client message with unexpected data (library i used has some bugs, that i want to overwrite). How to inspect, trace client calls? I want to determine what client wants and locate buggy method. Or how to trace all calls in service? I has much of logg...
dbus-monitor "sender=org.freedesktop.Telepathy.Connection.******"
1.2
true
1
2,744
2013-08-27 20:43:38.017
virtualenv/virtualenvwrapper confusion - how to properly use
Sorry if this is dumb but every piece of documentation i read doesn't ever seem to answer this question in a direct way. How do i properly use virtualenv so that I have a virtualenv i can call with workon? When i do tutorials like "Effective Django" they use the virtualenv command on an empty folder, then activate it....
When i do tutorials like "Effective Django" they use the virtualenv command on an empty folder, then activate it. That works, until tomorrow when I want to work on the app again at which point the virtualenv is gone. I strongly doubt that this is the case, unless something is deleting your directories overnight. If t...
0.673066
false
1
2,745
2013-08-28 13:40:17.650
Is there a way to add multiple filemasks in wx.lib.filebrowsebutton.FileBrowseButton?
I'm trying to make a wx.lib.filebrowsebutton.FileBrowseButton button match both txt and csv files, but it doesn't seem to support glob pattern as described, *.{txt,csv} ends up matching nothing on windows and it literally tries to look for files with extension of {txt,csv}. So how do I make it work for both txt and csv...
The documentation is not very clear. You should be using a semi-colon inside parenthesis, like so: "TXT and CSV files (*.txt; *.csv)|*.txt; *.csv" You can also add a second line like so: "TXT and CSV files (*.txt; *.csv)|*.txt; *.csv|PNG files (*.png)|*.png"
1.2
true
1
2,746
2013-08-28 22:29:27.230
Allowing remote access to Elasticsearch
I have a default installation of Elasticsearch which I am trying to query from a third party server. However, it seems that by default this is blocked. Is anyone please able to tell me how I can configure Elasticsearch so that I can query it from a different server?
There is no restriction by default, ElasticSearch expose a standard HTTP API on the port 9200. From your third party server, are you able to: curl http://es_hostname:9200/?
0.081452
false
2
2,747
2013-08-28 22:29:27.230
Allowing remote access to Elasticsearch
I have a default installation of Elasticsearch which I am trying to query from a third party server. However, it seems that by default this is blocked. Is anyone please able to tell me how I can configure Elasticsearch so that I can query it from a different server?
In config/elasticsearch.yml, put network.host: 0.0.0.0. And also add Inbound Rule in firewall for your ElasticSearch port(9200 ByDefault). It worked in ElasticSearch version 2.3.0
0.240117
false
2
2,747
2013-08-29 12:36:57.357
What does extent do within imshow()?
Im wanting to use imshow() to create an image of a 2D histogram. However on several of the examples ive seen the 'extent' is defined. What does 'extent' actually do and how do you choose what values are appropriate?
Extent defines the images max and min of the horizontal and vertical values. It takes four values like so: extent=[horizontal_min,horizontal_max,vertical_min,vertical_max].
1.2
true
1
2,748
2013-08-30 20:28:20.080
Fastest text search in Python
I am developing my first Flask application (with sqlite as a database). It takes a single name from user as a query, and displays information about this name as a response. All working well, but I want to implement typeahead.js to make better user experience. Typeahead.js sends requests to server as user types, and sug...
You are looking for "partial matches". I would load all possible names into an array, and sort them. Then I would separately create a (26x26) lookup array that shows the index of the first element in the list of names that corresponds to a combination of the first two letters; you might also have a dict (rather than an...
0
false
1
2,749
2013-08-31 08:14:49.117
How to perfectly match a proxy with regex?
I need to match both formats like: user:pass@112.213.123.12:3847 and 111.23.123.78:2938, how do you do that(match valid proxy only)? And by the way, is there such module(validate proxy formats) in python already?
The solution I'm currently using to accept http / https only, username:password optionally and host as an IP or domain name is the following: ^(?:https?:\/\/)(?:(\w+)(?::(\w*))@)?([a-zA-Z0-9][a-zA-Z0-9-_]{0,61}[a-zA-Z0-9]{0,1}\.([a-zA-Z]{1,6}|[a-zA-Z0-9-]{1,30}\.[a-zA-Z]{2,3})|((?:\d{1,3})(?:\.\d{1,3}){3}))(?::(\d{1,5...
0
false
1
2,750
2013-08-31 08:21:39.527
How to show EOF in Python? / how to identify lines?
I have to write a code which recognizes a text line by line and reverses each line in the output, I dont know how to enter a text with multiple lines (as "input()" function will take the input after the first "Enter" but I still want to enter more lines? second I don't know how to count the input line by line? whould ...
Entering multiple lines: use three quotation marks thusly: """hello this is multiple lines""" count lines... len(text.split()) or len(text.split('\n')) etc
-0.201295
false
1
2,751
2013-08-31 10:02:16.830
tkinter - Change menubar location
I have a program thats like a desktop enviroment with educational games and I was wondering how to put the menubar on the bottom of the window. Thanks In Advance!
You can't, if you're talking about the native menubar you get when you set the menu attribute of the root window. You can create your own menubar that behaves a little bit like a menubar by using a frame and one or more menubuttons, and place that at the bottom.
1.2
true
1
2,752
2013-09-01 04:10:55.323
Sending python objects to node.js via socket.io
Ok so what I'd like to do is have a game written in python and for all the multiplayer to be handled socket.io just because these are two things I'm fairly familiar with and I wanna keep possibilities for a web version or web app for the game open So what I'm wondering is, how exactly do I do this and would it be bette...
Assuming your Python objects are simple enough (not instances of classes, say), just send a JSON representation (json.dumps()) of them to the socket.io side. I am assuming you can parse JSON on the client side if needed.
1.2
true
1
2,753
2013-09-02 09:46:14.120
How to change automatically the type of the excel file from Tab space separated Text to xls file?
I have an excel file whose extension is .xls but his type is Tab Space separated Text. When I try to open the file by MS Excel it tells me that the extension is fake. And So I have to confirm that I trust the file and so I can read it then. But my real problem is that when I try to read my file by the xlrd library it g...
mv file.{xls,csv} It's a csv file, stop treating it as an excel file and things will work a lot better. :) There are nice csv manipulation tools available in most languages. Do you really need the excel library?
0.201295
false
1
2,754
2013-09-02 23:19:34.027
Unable to run any Python program using code runner
I'm brand new to coding. I managed to figure out how to use github and I have been forking projects over to my machine in an attempt to play around with them and learn python. My problem is every single project I fork over, when I run any of the .py files in Coderunner it pops up with errors and doesn't run correctly...
Coderunner is more useful in testing single python files instead of larger projects, however it can run such projects. A larger project should have a setup.py or a main.py which should be run. Also, what errors are you getting?
0.386912
false
1
2,755
2013-09-03 16:16:34.310
ImportError: Could not import settings 'company.foo.settings' (Is it on sys.path?): No module named foo.settings
I was asked to split a big project into some reusable libraries (packages). So the idea was to do this: company-django-shared company-django-shared-dev company-python-shared company-python-shared-dev These are installable with setuptools and namespaces: company company.packagename company.packagename.tests company.u...
The only way I found for now is the following: Do not use the namespace_packages parameter in setuptools.setup() Instead, explicitly define "namespace" packages with this in the __init__.py file: __import__('pkg_resources').declare_namespace(__name__) I have not done a lot of testings as to if this will work if I don...
1.2
true
1
2,756
2013-09-03 19:32:47.110
how to disable the window maximize icon using PyQt4?
I would like to know how to disable the window Maximise button in pyqt4. I am at present using QWidget.setFixedSize (self, QSize) to prevent user window resizing, however the maximise button is still enabled and when pressed causes the application to move to the top left corner of the screen. I am basically wanting to ...
you could set the maximumSize and minimumSize with the same values, it'll get to dissapear maximise button
0.081452
false
1
2,757
2013-09-03 19:55:15.560
Real time timer
I am new to Python so be gentle. I have been trying to write a program that counts or measures events in real time. At the moment I am using the sleep command but this pause event doesn't take into account the time the program takes to run. I have read up on the datetime module and can sort of see how this could be use...
Your best bet (besides Googling for help before posting a question on SO) might be to do something like this: Note the time when the program starts. start = datetime.datetime.now() Do your calculations sleep until 100 seconds after start. (start + datetime.timedelta(seconds=100)) Note that this won't be perfect, sinc...
0.995055
false
1
2,758
2013-09-04 05:35:05.257
Python text game: how to make a save feature?
I am in the process of making a text based game with Python, and I have the general idea down. But I am going to make the game in depth to the point where, it will take longer than one sitting to finish it. So I want to be able to make the game to where, on exit, it will save a list of variables (player health, gold, r...
First, don't overthink this. You don't need to use anything complicated. As a preliminary step, research basic file input/output in python. Second, I'm assuming you have a player class in your game? Or possibly an overall class which keeps track of game state. Well have that class store default values for your variabl...
0.201295
false
1
2,759
2013-09-04 22:35:30.123
How to Customize vim for scripting in Python 3 ?
I am new to vim and I want to use it for scripting Python3. anyone knows how to customize vim for editing Python 3 scripts? (mainly for indentations, coloring and tab suggestions... ) Thanks
You should put customized settings in to ~/.vim/ftplugin/python.vim This will be sourced when vim sees a file with a filetype python. To make sure the settings only affect the current buffer use setlocal. To make sure that mappings only affect the current buffer use noremap <buffer> Just make sure to have filetype plug...
0.201295
false
1
2,760
2013-09-05 20:30:51.763
Multiple Quotes in String
In Python how would I write the string '"['BOS']"'. I tried entering "\"['BOS']\"" but this gives the output '"[\'BOS\']"' with added backslashes in front of the '.
Enclose the entire string with """ or ''' (you would use ''' if the outermost quotation marks were ") in cases like these to make things simpler. """'"['BOS']"'"""
0.101688
false
1
2,761
2013-09-06 05:30:44.997
How to properly decouple Django from an AJAX application?
I'm using TastyPie and Django to build out my backend for an application that will have browser and mobile (native iOS) clients. I have been through the TastyPie and Django docs, can authenticate successfully either using the TastyPie resources I set up, or using Djangos built in views. I see a lot of examples on inclu...
A mobile client doesn't care if the Javascript comes from Django or any other web server. So go ahead and put all your JavaScript and static HTML on another server. If you want your mobile app to see if the user is logged in, it should make an AJAX call to your Django backend (where the request is authenticated). The...
1.2
true
1
2,762
2013-09-09 20:01:29.213
How can I automatically add author and copyright info to newly created ipython notebooks?
I'd like to pre-pend a simple author and copyright clause the beginning of newly created ipython notebooks. Is this possible? If so how can it be done?
We want to support this in metadata at notebook top level, but nobody has taken time to write a proposal for metadata structure, how to edit it, and how to show it. This would be usefull for view on nbviewer, but also for conversion to LaTeX, and other format. It might just be slightly more complicated that at first th...
0.386912
false
1
2,763
2013-09-10 06:12:19.727
How to create text box in plone site
Hi want to add text box and label in plone site but, that plone site does not display text box how can i create text box in plone site thanks!
You can create a static text portlet in that context you need it: folder, page.
1.2
true
1
2,764
2013-09-10 09:44:08.053
How to TTS Chinese using pyttsx
I want to know how to text-to-speech Chinese using the python package 'pyttsx'. It seems to need some other modules like neospeech.
Yes, neospeech is a language library. By installing it, you can just set the voice of pyttsx and tts Chinese as well.
1.2
true
1
2,765
2013-09-10 10:34:53.577
How to print report in EXCEL format (XLS)
I'm a beginner of openerp 7. i just want to know the details regarding how to generate report in openerp 7 in xls format. The formats supported in OpenERP report types are : pdf, odt, raw, sxw, etc.. Is there any direct feature that is available in OpenERP 7 regarding printing the report in EXCEL format(XLS)
In python library are available to export data in pdf and excel For excel you can use: 1)xlwt 2)Elementtree For pdf genration : 1)Pypdf 2)Reportlab are available
0
false
1
2,766
2013-09-10 21:15:34.923
IPython Notebook NB convert formatting Footers?
Using the NB convert with default options ("article") I am not getting a footer with page numbers? I know nothing about LaTex but a brief look at the tpl files seems to indicate that I should get footers (maybe with page numbers?) The "book" option give nice footers, but is not a great format for other reasons... I loo...
You can set the author using ipython nbconvert --to latex --SphinxTransformer.author='John Doe' file.ipynb
0.545705
false
1
2,767
2013-09-11 13:39:24.747
In Python, how do I execute a .exe file, and stop it after n seconds?
I am using "subprocess" to execute a .exe file from a Python script. I need to do this in a loop, ie start the .exe, run it for a minute, kill it, do it all over again. I am using subprocess.check_call to execute it with arguments, but I don't know how to stop it.
subprocess.check_call is used to check the returned value - use subprocess.Popen this returns a process ID, (pid), which can be used after your time limit with pid.terminate() to end the process, (kill it).
0
false
1
2,768
2013-09-11 15:46:45.063
How to alter a string after it has been printed
Ok, I ask this question on behalf of someone else but I would also like to know if and how it is possible. Let's say you have a given line of code producing the string Time left: 4 Is there any way how I can then after this string has been printed edit the value of the "4" and change it to a "3" and then reprint the...
One method is printing the backspace escape character (\b), which will will move the text cursor one character back; however, it is your responsibility to print something afterward to replace the text. For example, if the current text in the terminal is Time left: 4 and you print "\b", the user will see nothing has cha...
0.265586
false
1
2,769
2013-09-11 17:54:21.380
noob, but I installed python 2.7.5 on my mac, how to I "target" that one rather than the built in 2.7.2?
I went thought and installed pip and then added a bunch of libraries that I like to use and then, only after installing everything, did I realize that everything went into the 2.7.2 sit-packages directory, so the Python2.7.5 version doesn't see anything. Now, If I type python --version in the terminal, the correct ver...
Honestly, one way around this is to make sure that virtualenv works with the right version, and just use pip inside the virtualenv.
1.2
true
1
2,770
2013-09-12 02:08:16.763
Upgrading to Python 2.7 Google App Engine 500 server error
I just started using Google App Engine and I am very new to Python. I may have made a stupid mistake or a fatal error, I don't know, but I realized that the basic "template" I downloaded from a website was old and used Python 2.5. So, I decided to update to Python 2.7 (after recieving a warning in the site's dashboard)...
I'm submitting as an answer because I'm relatively new to SO and don't have enough rep to comment, so sorry about that... But line 7 of your new main.py uses webapp instead of webapp2, so that may be causing some troubles, but likely isn't the reason that it's not working. Could you also provide the contact.html templa...
0.265586
false
3
2,771
2013-09-12 02:08:16.763
Upgrading to Python 2.7 Google App Engine 500 server error
I just started using Google App Engine and I am very new to Python. I may have made a stupid mistake or a fatal error, I don't know, but I realized that the basic "template" I downloaded from a website was old and used Python 2.5. So, I decided to update to Python 2.7 (after recieving a warning in the site's dashboard)...
Thank you everyone for your respective answers and comments, but I recently stumbled upon GAE boilerplate and decided to use that and everything's fine. I kept having very odd problems with GAE beforehand, but the boilerplate is simple and seems to be working fine so far. Anyways, thanks again. (Note: I would delete th...
1.2
true
3
2,771
2013-09-12 02:08:16.763
Upgrading to Python 2.7 Google App Engine 500 server error
I just started using Google App Engine and I am very new to Python. I may have made a stupid mistake or a fatal error, I don't know, but I realized that the basic "template" I downloaded from a website was old and used Python 2.5. So, I decided to update to Python 2.7 (after recieving a warning in the site's dashboard)...
I'm not sure if this is your formatting when you loaded your code here, but where you define app in main.py should not be part of the contacts class. If it is, your reference to main.app in your app.yaml won't work and your page won't load.
0.265586
false
3
2,771
2013-09-12 03:49:54.783
Django Clear All Admin List Filters
I have a Django admin control panel and in each list of objects there are lots and lots of list filters. I want to be able to clear all the filters with a click of a button, but can't find where this ability is, if it already exists in Django. Routes I'm considering (but cannot figure out): Make the last item in the b...
If you have at least one entry in search_fields and therefore are showing a search box on your admin changelist page, if you have any filters or search terms in effect you should see information to the right of it showing the number of rows that match your current filter and search criteria. It'll be worded as somethi...
0
false
1
2,772
2013-09-12 05:13:58.220
Python's ConfigParser: Cross platform line endings?
Does anyone know how Python deals with ConfigParser line endings in the different OSes? Because it follows the Windows INI format. But what about Linux? (As you know, Windows text line endings are typically CRLF, and Unix's are CR.) I want users of my app to take their config files (.INI files) easily from Windows to L...
You're fine, ConfigParser will still work. The reason is that is uses fp.readline, which reads up to and including the next LF (\n). The value is then stripped of whitespace, which removes the CR (\r). I'd say just use LF (\n) as your line separator - it will work on both systems, but using both won't cause any harm ei...
1.2
true
1
2,773
2013-09-12 10:39:29.013
After converting python script to executable with pyinstaller I get: error while loading shared libraries... Permission denied
I have a python script which adds a user using the command os.system('useradd user'). This code works fine when run like a python script like this sudo python script.py. However, once I convert it to executable with pyinstaller with the command python pyinstaller.py --onefile script.py, and run the executable like this...
Looks like os.system('sudo useradd user') solved the issue.
1.2
true
1
2,774
2013-09-12 20:05:51.827
About font of python interpreter in PyScripter
I am using PyScripter as IDE for Python. Python version 3.3.2 64 bit version. Python interpreter in scripter is very small for visualisation. Can anybody please help me how to increase the font of python interpreter in PyScripter?
In PyScripter 2.5.3 right mouse click on interpreter window and to choose in a pop-up menu 'interpreter editor option'.
0.999329
false
1
2,775
2013-09-13 04:21:56.880
Cash flow diagram in python
I need to make a very simple image that will illustrate a cash flow diagram based on user input. Basically, I just need to make an axis and some arrows facing up and down and proportional to the value of the cash flow. I would like to know how to do this with matplot.
If you simply need arrows pointing up and down, use Unicode arrows like "↑" and "↓". This would be really simple if rendering in a browser.
0
false
1
2,776
2013-09-13 07:24:46.263
Optimal algorithm for cache with expire
I need simple cache structure (in python, but it doesn't really matter), with some specific requirements: Up to several millions of small objects (100 bytes on average) Speed is the key (both put and get), I'd expect operation times at about few microseconds Only one thread accessing this - so it can be all just in me...
One implementation of a hashtable is to store a list of (key, value) for each hash value. You can extend this to storing a list of (key, insertion time, value) for each hash value. On both get and set, you can throw away expired items as you scan for the key you're interested in. Yes, it may leave expired items in the ...
0
false
2
2,777
2013-09-13 07:24:46.263
Optimal algorithm for cache with expire
I need simple cache structure (in python, but it doesn't really matter), with some specific requirements: Up to several millions of small objects (100 bytes on average) Speed is the key (both put and get), I'd expect operation times at about few microseconds Only one thread accessing this - so it can be all just in me...
Only experiments will tell you which is better. Here's another simple idea to consider: link all the keys in a linked list in order of arrival. Each time you retrieve a key, iterate from the beginning of the list and remove all expired items, from both the list and the dictionary.
0.135221
false
2
2,777
2013-09-13 09:56:42.507
python pip specify a library directory and an include directory
I am using pip and trying to install a python module called pyodbc which has some dependencies on non-python libraries like unixodbc-dev, unixodbc-bin, unixodbc. I cannot install these dependencies system wide at the moment, as I am only playing, so I have installed them in a non-standard location. How do I tell pip wh...
Just in case it's of help to somebody, I still could not find a way to do it through pip, so ended up simply downloading the package and doing through its 'setup.py'. Also switched to what seems an easier to install API called 'pymssql'.
-0.173164
false
1
2,778
2013-09-13 15:43:00.843
How to avoid repeated pre-calculation in django view
I am writing an API which returns json according to queries. For example: localhost/api/query?a=1&b=2. To return the json, I need to do some pre-calculations to calculate a value, say, x. The pre-calculation takes long time (several hundred milliseconds). For example, The json file returns the value of x+a+b. When the ...
You could add a model (with a db table) that stores values for a, b and x. Then for each query, you could look for an instance with a and b and return the associated x.
0.201295
false
2
2,779
2013-09-13 15:43:00.843
How to avoid repeated pre-calculation in django view
I am writing an API which returns json according to queries. For example: localhost/api/query?a=1&b=2. To return the json, I need to do some pre-calculations to calculate a value, say, x. The pre-calculation takes long time (several hundred milliseconds). For example, The json file returns the value of x+a+b. When the ...
If you are using some sort of cache (memcached, redis) you can store it there. You can try to serialize the object with pickle, msgpack etc. That you can retrieve and deserialze it.
0.386912
false
2
2,779
2013-09-14 06:29:53.133
How to perform flash object testing in selenium webdriver with python?
After trying to find some help on the internet related to flash testing through selenium, all I find is FlexUISelenium package available for Selenium RC. I DO NOT find any such package available for Selenium Webdriver. I am working with python and selenium webdriver and I do not see any packages available to automate ...
Use flashselenium or sikuli for flash object testing.
0
false
1
2,780
2013-09-14 08:11:29.187
How to if few letters are part of the string entered?
Can somebody pls help me on how to write the code to check if few given letters are part of the string entered. the output must be true if the letters are present or false. For example: Return True if and only if the name is valid (that is, it contains no characters other than 'B' 'A' 'N') if the word entered is BANANA...
To check if something, you use a conditional clause (if/elif/else) To check what letters are used in a string, you can use a set. For example, if the input is BANANA, you can do set("BANANA") to create a set of unique values ({"B", "A", "N"}) To check if certain letters are in the set, you can use the all() function. a...
0
false
1
2,781
2013-09-14 19:42:12.450
How do I run a scipt from within Python on windows/dos?
All I know how to do is type "python foo.py" in dos; the program runs but then exits python back to dos. Is there a way to run foo.py from within python? Or to stay in python after running? I want to do this to help debug, so that I may look at variables used in foo.py (Thanks from a newbie)
To stay in Python afterwards you could just type 'python' on the command prompt, then run your code from inside python. That way you'll be able to manipulate the objects (lists, dictionaries, etc) as you wish.
0.135221
false
1
2,782
2013-09-15 23:45:29.720
Selecting the rows with the N most recent unique values of a datetime
I have a postgres DB in which most of the tables have a column 'valid_time' indicating when the data in that row is intended to represent and an 'analysis_time' column, indicating when the estimate was made (this might be the same or a later time than the valid time in the case of a measurement or an earlier time in th...
I'm not sure about the SQLalchemy part, but as far as the SQL queries I would do it in two steps: Get the times. For example, something like. SELECT DISTINCT valid_time FROM MyTable LIMIT 3 ORDER BY valid_time DESC; Get the rows with those times, using the previous step as a subquery: SELECT * FROM MyTable WHERE vali...
0.201295
false
1
2,783
2013-09-16 12:20:58.030
create a session to another site
I'm developing a backend in Django and I need to log in to another server backend with a simple POST method. So I would need to create a session object or something like that to handle that login. Any Ideas on how to do that?
If you're not looking for single sign-on, then likely you want to either do the work in the view, and if you need the session to persist, store it in the (local django) session object; or outsource it to something like celery, and again, keep anything you need to keep track of in the session object.
0
false
1
2,784
2013-09-16 20:44:48.013
Using python and skype4py to receive and send chat
I would like to be able to read messages from a specific user in skype using skype4py then send an automated response based upon the message back to the skype chat window. That way a user could message me and get an automated response saying that I'm currently busy or whatever. I really just need to know how to read an...
I do not want to give you all the answer so that you can improve your coding skills but I will give you some clues: 1)Use boolean values for being activated and deactivated 2)Set a command that activates and deactivates 3) set a value that if reaceived or sent chat and true/false then reply. Gave you a lot of clues! Go...
0
false
1
2,785
2013-09-17 09:25:12.047
get list of named loglevels
In my application, I'm using python.logging for logging. Now I want to control the loglevel interactively, so i created a combobox hat lets the user select "ERROR", "WARN", "INFO",... What I don't really like is that currently the values in the combobox are hardcoded. Instead,Ii would like to have a list of all "named"...
As you are only reading values, logging._levelNames looks an appropriate solution to me. Keep going with logging.addLevelName for setting new values though.
1.2
true
1
2,786
2013-09-18 03:18:43.453
Simplifying development process for Django
I'm a freelance editor and tutor as well as a fiction writer and artist looking to transition to the latter on a full-time basis. Naturally, part of that transition involves constructing a website; a dynamic site to which new content in various forms can be added with ease. Now, I've always intended to learn how to pro...
As a Django developer i can assure you that it grows on you and becomes easier to understand the development environment. You should remember that settings.py is probably going to be where your thoughts will be for quite a while in the start; the good part is that its only once, after you got it up and running you'll ...
0
false
1
2,787
2013-09-18 08:25:40.247
Py.test skip messages don't show in jenkins
I have a minor issue using py.test for my unit tests. I use py.test to run my tests and output a junitxml report of the tests. This xml report is imported in jenkins and generates nice statistics. When I use a test class which derives from unittest.TestCase, I skip expected failures using: @unittest.skip("Bug 1234 : ...
I solved it using this line as the first line of the test: pytest.skip("Bug 1234: This does not work") I'd rather have used one of the pytest decorators, but this'll do.
0.386912
false
1
2,788
2013-09-18 21:17:19.343
How to share Ipython notebook kernels?
I have some very large IPython (1.0) notebooks, which I find very unhandy to work with. I want to split the large notebook into several smaller ones, each covering a specific part of my analysis. However, the notebooks need to share data and (unpickleable) objects. Now, I want these notebooks to connect to the same ker...
When I have a long noetbook, I create functions from my code, and hide it into python modules, which I then import in the notebook. So that I can have huge chunk of code hidden on the background, and my notebook smaller for handier manipulation.
0.386912
false
1
2,789
2013-09-19 04:49:20.043
Repeat rows in files in wakari
In wakari, how do I download a CSV file and create a new CSV file with each of the rows in the original file repeated N number of times in the new CSV file.
cat dataset.csv dataset.csv dataset.csv dataset.csv > bigdata.csv
0
false
1
2,790
2013-09-20 06:26:31.357
Analyze Text to find patterns and useful information
to provide some context: Issues in an application are logged in an excel sheet and one of the columns in that sheet contains the email communication between the user (who had raised the issue) and the resolve team member. There are bunch of other columns containing other useful information. My job is to find useful ins...
Try xlrd Python Module to read and process excel sheets. I think an appropriate implementation using this module is an easy way to solve your problem.
0
false
1
2,791
2013-09-21 15:43:47.487
Sum 7 days after current date in Django
I Need to put an expiration date in a template, it show the current date and the expiration date will be 8 days from current date. Can someone tell me how can I do it? Is possible do it with Django or do I have to do it whit maybe Jquery or JavaScript? And I need to send it to my database too, not just display it in th...
I would do it in django. Have two DateFields in your model, both that could be blank and null. On the first time someone views your page (with both dates unset), create a view for the template request that sets the one of the DateFields to today = datetime.date.today() and the other to today + datetime.timedelta(8) t...
1.2
true
1
2,792
2013-09-21 23:09:39.610
How does python find the end of string?
I know python has inbuilt string support. But what I would like to know is how it handles the end of string construct. C has '\0' character to signify end of string. How does python do it? It would be great if someone could tell me how it works in the cpython source code.
AFAIK, CPython keeps track of the length and start of the string. As of CPython 3.3 it also keeps track of how many bytes per character in order to compress strings that can fit into subsets of the Unicode spectrum, such as Latin-1 strings.
1.2
true
1
2,793
2013-09-23 20:49:07.597
Integrate other html documentation into sphinx docs
How do you include html docs generated by other tools such as nose, coverage, and pylint reports into Sphinx documentation. Should they go into the _static directory? and if so, how do you link to them? I am trying to build a concise package of all of the code development tool documentation into a .pdf or html.
I have a similar problem and I could solve it by doing the following. Note this is just for the HTML output. Create an index.rst field with just the following: ====================== Javadoc of the API XXX ====================== As I am using the extension "sphinx.ext.autosectionlabel", this becomes a "level 1" secti...
0
false
1
2,794
2013-09-24 03:49:58.167
confusion with results of `python setup.py install --user`
Say I have a python application that I want to install and if I run python setup.py install --user, everything gets put into ~/.local as expected (on linux), and inside of that the stuff in ~/.local/lib/python2.7/site-packages/ gets seen by the PYTHONPATH as expected; however, my executables that are created by setup.p...
Instead of using --user, why not use a virtualenv? they are much more flexible, and put its bin directory on the path when activated. Otherwise, manually putting ~/.local/bin on your PATH, as you did, is what you need to do.
0.386912
false
1
2,795
2013-09-24 05:27:00.383
Need to know iPhoto Library location programmatically using Applescript
One of my desktop apps I need to know where the iPhoto Library is installed, programmatically. I do not want to pick it from predicted location (/Users/me/Pictures/iPhoto) since power user may have installed it somewhere else. I'm developing app using Python and I guess Applescript might have way to figure out iPhoto l...
Simply invoke the system command which iPhoto (assuming that you can run iPhoto from a shell) and parse the output.
0
false
1
2,796
2013-09-24 12:18:38.287
Is Multi-threading required for PyQt4 and Writing to Serial
My simple Python app uses PyQt4 for its GUI and clicking a QPushButton causes the app to send a message via serial. GUI elements also update frequently. Question: I did not know how to implement multithreading. Will not having multithreaded process cause the app to be less responsive and less consistent in sending the ...
That depends. Your PC is idle 99.9995% of the time while you type; so it has a lot of CPU power to spend on background tasks. Most people don't notice this since the virus scanner typically eats 5-20% of the performance. But typing or clicking a button barely registers in the CPU load. OTOH, if you run a long task in t...
0.386912
false
1
2,797
2013-09-25 18:40:50.850
How to Run Python without a Terminal
I want to teach some students basic Python programming without having to teach them how to use the terminal. Recently, I was teaching a 2 hour intro session, and not only did teaching terminal stuff take a long time, but it also intimidated a lot of the students. I would like a solution where students wouldn't have t...
Surely that's what IDLE is for? It's not much good as an IDE, but it does work well for exactly what you describe - opening modules and executing them, and running commands in an interactive shell.
1.2
true
2
2,798
2013-09-25 18:40:50.850
How to Run Python without a Terminal
I want to teach some students basic Python programming without having to teach them how to use the terminal. Recently, I was teaching a 2 hour intro session, and not only did teaching terminal stuff take a long time, but it also intimidated a lot of the students. I would like a solution where students wouldn't have t...
When I'm not near my own PC, I use ideone.com. I like that it is a universal IDE, which for me means both C++ and Python.
0
false
2
2,798
2013-09-26 14:54:10.997
Importing and debugging a Python Django project made in a different environment
I am working on a Django project that was created by another developer on a different machine. I see that in the root of the application, there is a .virtualenv directory. Is it possible to simply setup this project locally on my Windows machine using the project settings and Python version (the app uses 2.7), so that ...
I once faced the same problem and it took me so much time to configure another environment that I eventually had to create a VM with the same version of OS and libraries. I then made a raw copy of the project and it worked fine.
0
false
1
2,799
2013-09-26 18:44:43.440
Laravel 4 passwords and python
I have a hashed password using the Hash::make() function of laravel when a user is created. I eventually need to take that hashed password, and pass it to a python script to perform a login and download of site resources. I know the hash is a one-way action, but I'd like to keep the password hashed to be security con...
you cant the best you can do is encrypt it with a reversible encryption ... but then you need to store the key somewhere ... eventually you will have some plain text somewhere (or encoded at best) that will allow decryption ... you could store the hash and do a query against a db that maps hashes to pw's but you still ...
1.2
true
1
2,800
2013-09-27 19:18:45.063
Specifying the line width of the legend frame, in matplotlib
In matplotlib, how do I specify the line width and color of a legend frame?
For the width: legend.get_frame().set_linewidth(w) For the color: legend.get_frame().set_edgecolor("red")
1.2
true
1
2,801
2013-09-28 20:21:51.813
Python program on server - control via browser
I have to setup a program which reads in some parameters from a widget/gui, calculates some stuff based on database values and the input, and finally sends some ascii files via ftp to remote servers. In general, I would suggest a python program to do the tasks. Write a Qt widget as a gui (interactively changing views,...
Django is a good candidate for the website, however: It is not a good idea to run heavy functionality from a website. it should happen in a separate process. All functions should be asynchronous, I.E. You should never wait for something to complete. I would personally recommend writing a separate process with a mess...
0
false
1
2,802
2013-09-29 01:43:22.283
Possible to share resources (logging, database, file etc.) across Python subproccesses?
I've written a large program in Python that calls numerous custom modules' main methods one after another. The parent script creates some common resources, like logging instances, database cursors, and file references which I then pass around to the individual modules. The problem is that I now need to call some of the...
The question exactly as you ask it has no general answer. There might be custom ways; e.g. on Linux a lot of things are actually file descriptors, and there are ways to pass them to subprocesses, but it's not nicely Pythonic: you have to give them as numbers on the command line of the subprocess, and then the subproce...
0.386912
false
1
2,803