Q_Id
int64
337
49.3M
CreationDate
stringlengths
23
23
Users Score
int64
-42
1.15k
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
Tags
stringlengths
6
105
A_Id
int64
518
72.5M
AnswerCount
int64
1
64
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
6
11.6k
Available Count
int64
1
31
Q_Score
int64
0
6.79k
Data Science and Machine Learning
int64
0
1
Question
stringlengths
15
29k
Title
stringlengths
11
150
Score
float64
-1
1.2
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
8
6.81M
27,934,885
2015-01-14T02:25:00.000
-1
0
1
0
javascript,ipython,ipython-notebook
38,215,176
22
false
0
0
With all the solutions above even though you're hiding the code, you'll still get the [<matplotlib.lines.Line2D at 0x128514278>] crap above your figure which you probably don't want. If you actually want to get rid of the input rather than just hiding it, I think the cleanest solution is to save your figures to disk in hidden cells, and then just including the images in Markdown cells using e.g. ![Caption](figure1.png).
1
187
0
I have an ipython/jupyter notebook that I visualize using NBviewer. How can I hide all the code from the notebook rendered by NBviewer, so that only the output of code (e.g. plots and tables) and the markdown cells are shown?
How to hide code from cells in ipython notebook visualized with nbviewer?
-0.009091
0
0
202,330
27,935,745
2015-01-14T04:11:00.000
1
0
0
0
python,openerp,odoo
28,070,202
9
false
1
0
You can use a private browser session to access the Database menu, from the login screen, and perform the the backup form there (you need to know the master password to access that, defined in the server configuration file).
1
13
0
I need to backup the current db while logged into odoo. I should be able to do it using a button, so that suppose I click on the button, it works the same way as odoo default backup in manage databases, but I should be able to do it from within while logged in. Is there any way to achieve this? I do know that this is possible from outside odoo using bash but thats not what I want.
Backup Odoo db from within odoo
0.022219
1
0
4,840
27,936,012
2015-01-14T04:43:00.000
2
0
0
0
python,django,django-admin
27,936,097
2
true
1
0
You can code the "member area" to be much more user-friendly than Django's admin, inevitably very general purpose. You can carefully restrict exactly what a user can change, saving them from mistakes that could be damaging and hard to fix, add more sanity checks too. All in all, I'd say that, while more work, coding your own "member area" is a far superior option than trying to shoehorn things into the (inevitably!) "one size fits all" Django admin arrangements.
2
0
0
Maybe my question can sound a little bit stupid but it's a real one. I'm doing an ecommerce website, so as an admin I directly use the one provided by django, to manage my article and user. But, what's the best for my user? Should I let them use the admin panel to manage their profile? (I saw I can manage who can do what on the admin panel). Or should i create a small member area to let them manage their account?
Should I allow users to manage their profile using the admin application?
1.2
0
0
50
27,936,012
2015-01-14T04:43:00.000
0
0
0
0
python,django,django-admin
28,121,019
2
false
1
0
Alternatively, you can make these users as 'superusers' in admin, to manage. And you can override view in admin to make it more friendly. Good luck!
2
0
0
Maybe my question can sound a little bit stupid but it's a real one. I'm doing an ecommerce website, so as an admin I directly use the one provided by django, to manage my article and user. But, what's the best for my user? Should I let them use the admin panel to manage their profile? (I saw I can manage who can do what on the admin panel). Or should i create a small member area to let them manage their account?
Should I allow users to manage their profile using the admin application?
0
0
0
50
27,937,988
2015-01-14T07:43:00.000
5
0
1
0
python,python-3.x,pycharm
27,939,054
2
false
0
0
The import does work. When PyCharm said No module named time, I assumed I would get a compiler error and started trying to fix it. However when I eventually just ran the code it worked fine. I expect PyCharm doesn't detect the time module as it's a dll and not a py as noted by Martijn in the comments. This is on PyCharm Community Edition 4.0.4.
1
5
0
When I try to import time I get : No module named time I have tried other time modules(datetime and timeit) and they work fine. I decided to check my installation and I can't find time.py anywhere. I checked the Lib, Scripts, libs and include folders, but can't find it anywhere. Anyone know what I can do to fix this? Maybe download the .py and put it in Lib myself? I am using Python 3.3.5 with PyCharm IDE. Only extra scripts I've installed is EasyInstall and PRAW.
Python 3.3.5 time module missing
0.462117
0
0
3,095
27,939,109
2015-01-14T09:03:00.000
0
0
1
0
python,exception-handling
27,939,203
2
false
0
0
You can create another exception type in A/B or catch all exceptions (which is not really good).
2
0
0
I have a module which imports psycopg2. Call this module A I have a second module, B which imports module A. If psycopg2 throws a custom exception (which is not handled by A), such as psycopg2.OperationalError, How can I handle the exception in module B without having to import psycopg2? Do I need to create some kind of proxy in module A to basically rethrow psycopg2.OperationalError as A.OperationalError?
Python catch exceptions from secondary module
0
0
0
73
27,939,109
2015-01-14T09:03:00.000
0
0
1
0
python,exception-handling
27,939,152
2
false
0
0
Yes, rethrowing the exception as a different class defined in module A is a very good way to solve this.
2
0
0
I have a module which imports psycopg2. Call this module A I have a second module, B which imports module A. If psycopg2 throws a custom exception (which is not handled by A), such as psycopg2.OperationalError, How can I handle the exception in module B without having to import psycopg2? Do I need to create some kind of proxy in module A to basically rethrow psycopg2.OperationalError as A.OperationalError?
Python catch exceptions from secondary module
0
0
0
73
27,940,829
2015-01-14T10:31:00.000
1
0
1
0
python-2.7,kivy
27,944,595
1
false
0
0
I have tried directly importing the kivy.Config module at various different points in the runtime (before the Kivy App is built, during, after). If this is to work, it should be before anything else is imported. Also, kivy is probably looking for the config file in ~/.kivy/config.ini.
1
0
0
I am working on Ubuntu 14.04 64bit. Default python 2.7.x package. Custom built Kivy (rather, it is not the kivy supplied in the repositories. I used pip to gather dependencies and build Kivy in a Virtualenv) For some reason, I seem to have no control over a large portion of my runtime Configuration. I have tried using environment variables, kivi.ini in my working directory and home directory. I have tried directly importing the kivy.Config module at various different points in the runtime (before the Kivy App is built, during, after). It seems that I cannot configure certain Kivi settings (default screen size for instance). My Kivy application is quite functional, but I am having trouble finding where Kivi looks for default configurations, and where the proper place is to override. I have tried many different ways, but it seems there is some master configuration that is taking priority and I am not able to override. Am I missing something simple? Does this have anything to do with the virtualenv (and how Kivy was built)?
Kivy Configuration Ignored
0.197375
0
0
847
27,945,764
2015-01-14T14:54:00.000
4
0
1
0
python-3.x,recursion,import,python-3.4
27,955,271
1
true
0
0
To import a module by name (in 3.4), use importlib.load_module, which is a "simplifying wrapper around importlib.__import__". You will see the latter mentioned (as a builtin) in other answers. To be useful, you must, of course, assign each module returned to something -- unless you are importing merely to check syntax or generate .pyc files, as in the compile_all module.
1
8
0
Given one root directory, I need to import all files from all folders (and folders inside other folders) under the root directory. I figured this could maybe be done with the help of os.walk(), but no idea how to import the files after "walking" through them. Is there an easy way to do this?
Recursively import all .py files from all folders
1.2
0
0
2,001
27,947,639
2015-01-14T16:20:00.000
0
0
1
0
python,pyinstaller
65,626,205
2
false
0
0
Use Auto-py-to-exe to add hindden libraries. In additional files add Rasterio folder (C:/users/Admin/anaconda3/envs/name/Lib/site-packages/rasterio) and then convert to exe. It worked for me. if it says some other libraries are missing then add folder of that library too.
1
30
0
I have two packages (say, dataread and datainspector) that were somehow not detected by PyInstaller. Because of this, the application terminates when the running application reaches the point where it needs to import modules from those packages. The easiest solution would be to copy dataread and datainspector into packaged app. But this will break the intention of packaging a binary version of the application. I've read about hidded imports and hook, and I think that both can solve the problem, but I am not sure of which one to use. Any suggestions? PS: both these packages may contain nested directories.
How to properly create a pyinstaller hook, or maybe hidden import?
0
0
0
74,738
27,949,714
2015-01-14T18:14:00.000
1
0
0
0
python,python-3.4,python-asyncio
27,988,750
1
false
0
0
No. You cannot add a new method or inherit from existing asyncio transport. Consider transports as final or sealed, like sockets. You should never want to inherit from socket but make your class that embeds the socket instance inside, right? The same for transport. See asyncio.streams as example of building new API layer on top of transport/protocol pair.
1
1
0
Is it possible to add new methods to a standard asyncio transport? e.g: Adding a send method to the SSL transport that serializes a protocol buffer, constructs a frame and uses the transports own write method to do a buffered write to the underlying socket. There are plenty of asyncio server/client examples out there, but I have not been able to find ones that implement their own transport or extends an already existing one.
Adding methods to an asyncio Transport
0.197375
0
1
253
27,950,855
2015-01-14T19:25:00.000
0
0
1
0
windows,python-2.7,registry,py2exe
27,986,791
3
false
0
0
Turns out WinPython has a menu option in the Control Console for adding Python packages that not only registers python for redistribution, but also registers it in the Windows Registry. Once I ran that menu option the install went ahead just fine. Why WinPython doesn't add itself during installation I'll never know. A caution to others, don't assume any installation does it all, you may still need to run a registry app.
2
1
0
I've installed Python 2.7.6 onto my Windows 7 32bit system, but it does not seem to have added it to the registry. When I tried installing py2exe (a version appropriate for 2.7.6 on 32bit) it keeps saying I need Python 2.7 which was not found in the registry. Could anyone provide me with a list of the registry items that need to be in place or have a simple app that modifies the registry to that I can install py2exe?
Add Python 2.7.6 to the windows registry
0
0
0
7,408
27,950,855
2015-01-14T19:25:00.000
4
0
1
0
windows,python-2.7,registry,py2exe
39,231,383
3
false
0
0
Installing py2exe (py2exe-0.6.9.win32-py2.7.exe) requires: reg add HKLM\SOFTWARE\Wow6432Node\Python\PythonCore\2.7\InstallPath /ve /t REG_SZ /d "C:\Python27" /f Tested on Windows 10. Regards LO
2
1
0
I've installed Python 2.7.6 onto my Windows 7 32bit system, but it does not seem to have added it to the registry. When I tried installing py2exe (a version appropriate for 2.7.6 on 32bit) it keeps saying I need Python 2.7 which was not found in the registry. Could anyone provide me with a list of the registry items that need to be in place or have a simple app that modifies the registry to that I can install py2exe?
Add Python 2.7.6 to the windows registry
0.26052
0
0
7,408
27,951,419
2015-01-14T20:01:00.000
0
0
1
0
python,c,python-c-api,python-c-extension
27,969,486
3
false
0
1
sprintf into a buffer followed by atoi seems to do the trick
1
0
0
I have a PyFloatObject that I want to convert to a C float. However, PyObjectFloat only provides a conversion to double. Can I safely cast a double to a float, or is there a function to convert PyObject to float i.e. PyObject_AsFloat.
convert PyFloatObject to float
0
0
0
2,614
27,952,331
2015-01-14T20:59:00.000
92
0
1
0
python,pycharm
27,952,376
3
true
0
0
Menu: Run -> Edit configurations -> "+" (add new config) -> Python. Script name: program.py If you need to debug a script from installed packages, such as tox, you can specify the full path too. For example: Script name: /home/your_user/.envs/env_name/bin/tox Above /home/your_user/.envs/env_name is a path to virtual environment containing tox package. Script params: -t input1 -t1 input2
2
63
0
I have been using PyCharm for a bit so I am not an expert. How I normally ran my programs was with the terminal like so: program.py -t input1 -t1 input2 I was wondering how can I debug this? For other programs I wrote, I did not have any arguments so debugging was simply setting break points and pressing debug.
Debugging with PyCharm terminal arguments
1.2
0
0
43,698
27,952,331
2015-01-14T20:59:00.000
1
0
1
0
python,pycharm
51,116,540
3
false
0
0
It was almost correct but just needed little correction with full script path. Menu: Run->Edit configurations->"+" (add new config)->Python. Script name: path + /program.py Script params: -t input1 -t1 input2
2
63
0
I have been using PyCharm for a bit so I am not an expert. How I normally ran my programs was with the terminal like so: program.py -t input1 -t1 input2 I was wondering how can I debug this? For other programs I wrote, I did not have any arguments so debugging was simply setting break points and pressing debug.
Debugging with PyCharm terminal arguments
0.066568
0
0
43,698
27,953,362
2015-01-14T22:07:00.000
3
0
1
0
python,egg,python-wheel
27,953,925
1
true
0
0
Can you assume your prospective users will all have pip >= 1.4 and/or setuptools >= 0.8? If so, wheels are fine. If not, an egg will help them, since previous releases of pip and setuptools don't support wheels. The fact that their Python is 2.6 or better is no guarantee that their installation tools will be reasonably recent, I believe.
1
4
0
Assuming that you are supporting Python 2.6 or newer, does it make any sense to publish .egg packages or is enough to publish .whl ones? In my case, the packages are pure python.
If you publish Python using wheel format do you still need to publish them as egg?
1.2
0
0
72
27,955,463
2015-01-15T01:29:00.000
2
0
0
0
python,html,tags,uri,url-scheme
27,955,487
2
true
1
0
If you don't include the URI scheme (http://, https://, //, etc) then the browser will assume it to be a relative URL. You should be aware of scheme-relative URLs like //www.google.com for your script. In short your should look for a double forward slash // to figure out whether or not a URL will be treated as relative or not.
1
0
0
I'm trying to find a way to test whether a URL is absolute or relative in Python. In the href attribute of an HTML tag, is the lack of a scheme (e.g. http, ftp, etc.) sufficient to mark a URL as relative, or is it possible to have an absolute URL as a href attribute without explicitly specifying the scheme (e.g. 'www.google.com')? I'm getting the scheme by using urlparse.urlparse('some url').scheme.
Is it possible to have an absolute href attribute with no scheme?
1.2
0
1
173
27,955,622
2015-01-15T01:51:00.000
0
0
0
0
java,python,processbuilder,inter-process-communicat
27,969,431
1
false
1
0
From your scenario, you are looking for inter process communication. You can achieve this using shared file. Your python script will write the output in text file, and your java program will read the same file.
1
1
0
Good evening all, am running a python script inside java using processBuilder. the python script returns a list and i dont know how to get it java and use it since all i can do for the moment with process builder is print errors or outputs. is it possible to get the list in java as well. Many thanks
Java/python using processBuilder
0
0
0
266
27,955,957
2015-01-15T02:38:00.000
0
0
0
0
python-3.x,python-idle
27,956,444
1
false
0
1
Execute it directly from the command line with python script.py.
1
0
0
Is there a way to hide the IDLE (or not making it run at all), with a command, when launching a tkinter application, without having to build the application?
Is there a way to hide the IDLE when running a tkinter application?
0
0
0
155
27,957,035
2015-01-15T04:56:00.000
0
0
0
0
python,django,localhost
60,644,419
3
false
1
0
If you're working DEBUG=True mod in your Django project, you shouldn't need anything other than that (I assume you are not using port 80, it requires root access). You must use 0.0.0.0 as host IP, it is a simple solution. And the command is: python manage.py runserver 0.0.0.0:8000. That's it.
1
6
0
I am running my django project in localhost and it works fine.. For test purpose I want to run my localhost from another computer connected in the same network. I have done python manage.py runserver 'my ip address' That works fine too.. Is there any way that I can access my localhost from another computer connected to another network? Like I am connected to A network and running my localhost and my friend is connected to B network. Suppose he wants to access my localhost and see my project running then is it possible to access localhost of a computer from another computer connected to another project?
django run localhost from another computer connected to another network
0
0
0
8,099
27,957,296
2015-01-15T05:25:00.000
6
0
1
0
python
27,957,324
1
false
0
0
== delegates to the left-hand-side's object's __eq__ special method, if there. And string objects definitely have one, and it's highly optimized. So that's really all there is to it...
1
2
0
I was working on optimizing the run-time of a program and got to wondering what "==" in Python really does behind the scenes. In particular, I noticed that it can check whether two large "similar" objects are the same really fast. For instance, if you have two strings of length 10 million and they only differ by a character, running == on them takes about as much time as running 2 == 3.
What does Python's "==" really do
1
0
0
100
27,957,335
2015-01-15T05:30:00.000
0
0
1
1
python,python-2.7
27,957,366
1
true
0
0
This is a shot in the dark, I haven't done much python, but could you not have your background scripts dump their results in a file and then have your window focus on updating when that file updates. In linux you could write to a text file and then open another console window to tail that file.
1
0
0
I need to run several python scripts simultaneously in the background, and have all the results be shown in 1 window, real time. The background scripts will continue running, but as more info is outputted it should be shown inside 1 window. I've tried os and subprocess, but to no avail. This needs to work on all platforms.
How to show realtime results of multiple python scripts in 1 window
1.2
0
0
40
27,961,552
2015-01-15T10:39:00.000
0
0
0
0
python,numpy,comma,data-files
27,961,800
3
false
0
0
I don't know if this is an option but you could pre-process it using tr -s ',' file.txt. This is a shell command so you'd have to do it either before calling python or using system. The latter might not be the best way since dragon2fly solved the issue using a python function.
1
0
1
I am trying to collect some data from a .txt file into my python script. The problem is that when the data was collected, it could not collect data in one of the columns, which has given me more commas than normally. It looks like this: 0,0,,-2235 1,100,,-2209 2,200,,-2209 All I want is to load the data and remove the commas but when I try with numpy.loadtxt it gives me a value error. What do I do?
Loading data file with too many commas in Python
0
0
0
192
27,965,967
2015-01-15T14:44:00.000
8
0
0
0
python,ocaml
27,966,451
3
false
0
0
This is a general question on how to talk between two programs, written in different languages. Actually, the problem should be further subdivided into two separate subproblems: What transport to use? (file, socket, etc) How to serialize and deserialize data. The first question is very general. You can use sockets of different kinds, pipes, shared memory, zmq library, or whatever. It is hard to give any advice here, since all choices has their cons and pros. Maybe using http over TCP socket is not a bad choice, since they're ubiquitous, and there excellent libraries on both sides of the pipe. Another approach is to use pipes, and to call one or another part using popen system call, that will create a process for you and return pipes that you can read or write from. As an extension of the previous, you can even use python as a library, and call the interpreter directly from your ocaml program, passing strings with code. Depending on your task it can be suitable or not. The second question, is about how to serialize OCaml native type, like int to bytes, and then read this bytes as python native int type, and vice verse. There're some solutions here, not so many though. You can use json with ezjsonm library on the OCaml (on python there is a json), you can use cap'n'proto it has bindings in OCaml and Python. Also, there are well known Google Protocol buffers, aka protobufs, with several bindings in OCaml, including piqi library, that can also serialize into many formats. There is another approach, you can make you OCaml program to be a dynamic library exposing interface in C, then create a python module, and call it directly as library. This is not very easy, because it requires to mess with build system, so I do not recommend it until you have performance requirements.
1
6
0
I would like to know the best way to send data from OCaml to Python and get response from Python back to OCaml. One naive method I can think is as follows. 1) In OCaml, write data into a file (input.txt) on file system. 2) In OCaml, run python, which opens input.txt and reads the data and write the execution result into output.txt 3) In OCaml, open output.txt and read the result Is there other easy ways to do this kind of task? Thanks in advance.
Communication between OCaml and Python
1
0
0
1,406
27,972,459
2015-01-15T20:32:00.000
2
0
0
0
python,rest,paypal
27,989,541
1
false
1
0
Got a reply from PayPal support. Apparently you can take the same token you pass to BillingAgreement.execute() and pass it to GetExpressCheckoutDetails in their classic API. I tried it and it works. It means you have to use both APIs (which we weren't planning to do) and store both API auth info, which is annoying. Hopefully they'll fix it someday, but if it's been high-priority for two months I'm not holding my breath.
1
1
0
Let's say I have a billing agreement, which I just executed on the callback from the PayPal site: resource = BillingAgreement.execute(token) The resource returned does not have any payer information (name, email, etc). I can use the ID to load the full BillingAgreement: billing_agreement = BillingAgreement.find(resource.id) That returns successfully, but the resulting object also lacks an payer info. This seems like a critical oversight in the REST API's design. If I just got a user to sign up for a subscription, don't I need to know who they are? How else will I send them a confirmation email, allow them to cancel later, etc? Thanks for the help!
In the PayPal REST API, how can I get payer information from a newly executed BillingAgreement?
0.379949
0
1
555
27,975,963
2015-01-16T01:27:00.000
2
0
0
0
python,django,validation
27,976,034
3
true
1
0
Client side validation may improve user experience (less page reloads). It may decrease number of hits to he server (but sometimes this number is increased :). But it is not necessary. Anyway server side validation is a must. You can't trust data from user input.
2
3
0
I am writing a Django app, and am wondering if any client side validation is necessary. Django handles all validation through forms in python on the backend. If something validates wrong, the user is returned to the screen with all their information still there. I can't see any reason I need to implement client side validation in Django? Is this true? The only reason I can think of is it would save a few hits to the server, but this seems negligible.
Is client side validation nessesary in Django?
1.2
0
0
1,963
27,975,963
2015-01-16T01:27:00.000
3
0
0
0
python,django,validation
27,976,103
3
false
1
0
If you have a web application that faces the public internet client side, validation is pretty much a user expectation. You might be able to ignore this if volume is low and people are motivated to use your website. For an company intranet site, the additional development cost may weigh against client side validation. However, if you use an available client framework (e.g. jquery or django-parsley) the additional cost for client side validation is actually fairly small and likely worth the effort in intraweb applications. ADDED Yes, as others had already stated client-side only validation is very bad as it is the same as no validation -- you can coerce the browser to send whatever you want back to the server. You can do also do lots of nice things client side that you cannot server side. Sometimes these are closely related to client side validation. E.g., limiting a comment to 500 characters. With client side code you can display a characters remaining count on screen -- with a little planning this can be integrated with the validation code.
2
3
0
I am writing a Django app, and am wondering if any client side validation is necessary. Django handles all validation through forms in python on the backend. If something validates wrong, the user is returned to the screen with all their information still there. I can't see any reason I need to implement client side validation in Django? Is this true? The only reason I can think of is it would save a few hits to the server, but this seems negligible.
Is client side validation nessesary in Django?
0.197375
0
0
1,963
27,977,626
2015-01-16T05:07:00.000
0
0
0
0
python,paraview
27,987,246
1
false
0
1
Uniform distribution works by picking a set of random locations in space and finding data points closet to those locations to glyph. Try playing with the Seed to see if that helps pick different random locations that yield better results. If you could share the data, that'd make it easier to figure out what could be going on here, as well.
1
1
1
I'm running Paraview 4.2 on Linux. Here's what's happening: I load my XDMF/hdf5 data into PV, which contains vector data. I apply a glyph filter to the loaded data, and hit apply (thereby using the default mode of Uniform Spatial Distribution). No glyphs appear on screen, and the information tab shows that the filter has no data (0 points, etc.). If I switch to All Points, or Every Nth Point, it works fine and displays the glyphs oriented correctly. Annoyingly, if I then make a cone source, and change the input of the glyph to the cone, Uniform Spatial Distribution works fine for the cone. No errors come up anywhere when I do this, whether in the PV gui or through pvpython. Any ideas?
Paraview glyph uniform distribution does not work on my dataset
0
0
0
653
27,978,383
2015-01-16T06:25:00.000
5
1
0
0
python
27,978,545
2
false
0
0
Even if you did this, I'd strongly discourage it. Root can access pretty much everyone's home directory, but the nuances of adding programs to the PATH that the root user doesn't technically own can be detrimental at best - might lead to a few root services not working properly, and actively insecure at worst. There's literally nothing wrong with installing your own copy of pyenv as another user. There's no pain involved and there's not much sense to do it any other way.
1
7
0
How to use pyenv with another user? For example, If I have installed pyenv in user test's environment, I could use pyenv when i login as test. However, how could i use pyenv when I login as another user, such as root?
How to use pyenv with another user?
0.462117
0
0
3,900
27,980,567
2015-01-16T09:14:00.000
2
0
1
0
python,qt,batch-file,environment
27,981,382
1
true
0
0
"If the bat files contained only setting of environment variables this would be easy" Include a set command at the end of the batch file and capture its output that will be just the listing of the variables in the environment and their values
1
0
0
I'm writing a python script to coordinate building of a number of Qt-projects on windows. The python script decides which architecture to build for, and which versions of Visual Studio and Qt to use. After that is done I would like to run the proper qtenv2.bat and vcvarsall.bat to setup my environment, and then import the resulting environment for use in my python file. If the bat files contained only setting of environment variables this would be easy, but since the also contain logic and stuff I need to actually run them and pickup the changes they have done. I can solve this by using multiple bat/py scripts, but my goal is to write one python script to take care of this build process.
Call a bat file from python and import the environment
1.2
0
0
977
27,982,645
2015-01-16T11:06:00.000
0
1
1
0
performance,python-3.x,import
27,990,196
1
false
0
0
There would be an initial performance hit the first time the modules are loaded. The second, third, fourth, ..., times the modules are loaded, Python gets them from its cache, so no performance hit at all. Having said that, the performance should be minor -- still, being a game, do all the imports up front.
1
2
0
If I had 100 imports, would my program perform worse due to Python looking up names during runtime (and looking through my all 100 imports)? I am creating a game and it would be far easier to describe each area as a separate module containing single class.
Python3 import performance
0
0
0
99
27,983,493
2015-01-16T11:59:00.000
0
0
1
1
python,c++,swig,scons
28,020,565
1
true
0
0
It seems like using the "Delete" function as a Command, after the SharedLibrary line, allows me to delete the unwanted files.
1
0
0
I have a scons setup where I can choose to run SWIG and build a python module from c++. this creates files such as x_wrap.cc x.lib x.obj etc. When all I want to have at the end of the process are theses files: _x.pyd x.py Is there a way I can get scons to delete the unwanted files after the build process?
scons - delete some of the built files after the compilation process
1.2
0
0
408
27,985,812
2015-01-16T14:11:00.000
0
0
0
0
python,unix,ssh,paramiko,robotframework
27,986,741
1
false
0
0
For example, when the connection was unexpectedly dropped.
1
0
0
The documentation of recv_exit_status() in paramiko/channel.py says "If no exit status is provided by the server, -1 is returned.". In which situation can it happen that the server (Unix) is providing no exit status?
When does recv_exit_status() return -1?
0
0
1
233
27,987,614
2015-01-16T15:43:00.000
1
0
0
0
python,pyephem
28,003,737
1
true
0
0
No, the underlying C code inside of libastro does not support leading plus signs or leading zeros. You will have to write a little Python function of your own to add them.
1
1
0
How do I get PyEphem to give angles with sign and a zero padded to degrees. Currently it returns 2:46:32.8 but I want it in the form +02:46:32.8. Now, I could define a function to return it in that form, but I was wondering if there was a simpler way.
Getting PyEphem to return angles with sign
1.2
0
0
55
27,988,150
2015-01-16T16:13:00.000
2
0
0
1
python,ubuntu,wxpython
27,988,300
3
false
0
0
Run this: sudo apt-get install python-wxgtk2.8 python-wxtools wx2.8-i18n
1
0
0
I'm using python and anaconda to work on some code, which turns out to requires wx2.8, but all I can find is installer for wx3.0. I looked into it, and the process for building an older version of wx from source is very unclear. It's not as simple as python setup.py install for example. Does anyone have experience with this, or at least can provides some reading on the matter that they know for a fact works? I'm also not using my system python, so I can't do sudo apt-get install (unless you can specify the python installation path in such a way).
How to get WXpython 2.8 on Ubuntu?
0.132549
0
0
2,485
27,990,624
2015-01-16T18:39:00.000
1
0
1
0
python,pip
27,990,745
2
false
0
0
It also might be the case that some dependencies are for features of the package that you don't require, like a graphical display library as an example. If you wish to use the software for some other purpose, and will never need these features, then skipping the dependencies may save time or at least the headache of installing possibly complex libraries/dependencies.
2
0
0
Like the title states, why would I want to install a package while ignoring dependencies using the --no-deps switch? Seems to me doing so could cause some packages to malfunction. Surprisingly, I cannot find the answer to this.
Why would I want to install a package while ignoring dependencies?
0.099668
0
0
51
27,990,624
2015-01-16T18:39:00.000
1
0
1
0
python,pip
27,990,681
2
true
0
0
Some issues are caused by conflicting dependencies. In those cases, you might install the problematic dependency yourself instead of letting pip autofetch it.
2
0
0
Like the title states, why would I want to install a package while ignoring dependencies using the --no-deps switch? Seems to me doing so could cause some packages to malfunction. Surprisingly, I cannot find the answer to this.
Why would I want to install a package while ignoring dependencies?
1.2
0
0
51
27,990,755
2015-01-16T18:47:00.000
0
0
0
0
python,intel-mkl
41,439,399
1
false
0
0
on my workstation, it is the problem with libiomp5.so. You can find the location of the so file with command (i.e. sudo find / -name libiomp5.so on Linux) and add the directory of its location to etc/ld.so.conf.d/intel_mkl_settings.conf right after the MKL installation directory(/opt/intel/mkl/lib/intel64). That helps specify the location of omp library. Hope this helps.
1
1
0
I try to import skimage.io and have the following error: ...mkl/intel64/libmkl_intel_thread.so: undefined symbol: omp_get_num_procs I have an mkl lib in my LD_LIBRARY_PATH, if I delete it than I have: ImportError: libmkl_rt.so: cannot open shared object file: No such file or directory
skimage.io - undefined symbol: omp_get_num_procs
0
0
0
2,160
27,993,383
2015-01-16T21:52:00.000
0
1
0
0
python,ubuntu,pdf-generation,pdfkit
29,774,518
1
false
1
0
I found the solution. The problem was that I didn't close .colse() the file before the initialisation of the pdfkit
1
0
0
I have a very strange problem. I have a script written in python which is generating an html report then I convert it using pdfkit to pdf . The script is working just fine on MAC and the pdf is generated normally. When I tried to install the same script on Ubuntu I got the following upnormal behavior: The html file is fully generated The pdf file is generated but without the last 2 pages when I tried to convert the either through wkhtmlto pdf command or through the python (outside the script) I got the right PDF form. Any idea why I'm examining this behavior ?
PDFKit with python on Ubuntu
0
0
0
487
27,994,576
2015-01-16T23:49:00.000
0
0
0
0
python,web
27,994,687
2
false
1
0
Recommend flask. I've just done something like this. Only need a few lines of python code and a few lines of html code. No more than 30 lines. Write a html page which has an input and a button. When the page gets an input and the button gets hit, a python script will be invoked. And then result will be rendered to a new page.
1
0
0
Is there an easy, simple way to embed python code in a webpage; i.e., have an embedded app where viewers input numbers and a python code is run and an output is spit out? I don't really want to learn Django just for one project, but if there's no other way, I might have to.
Embed Python code on a webpage
0
0
0
273
27,995,942
2015-01-17T03:46:00.000
0
0
0
1
python,windows-mobile,windows-ce,gspread
28,018,470
1
true
0
0
Although gspread source code is available and a python modul it depends on urllib and that depends on various other modules that are not part of PythonCE. So, I fear, you will not success in getting gspread running on the windows mobile device. Best solution to this seems to use a web server that hosts the html pages. Apache, for example, can host python code. OTOS gspread is a warpper for google spread sheet API that can be invoked directly from html javascript code running on windows mobile device. But does a spread sheet make sense on such small displays?
1
0
0
I am working on an inventory project for work that will use a mobile computer and have run into a problem. I have written a program using Python and the Gspread library, but forgot to check if it will even work with either the windows mobile or windows CE operating systems. From what I have found there is a version of python for Windows CE but I am not sure if the Gspread library even works with this version of python. Has anybody had any experience working with these operating systems or does somebody have a better understanding of python and its libraries? can I just install a library into any version of python?
Gspread and python on windows mobile or windows CE
1.2
0
0
151
27,998,297
2015-01-17T09:57:00.000
3
0
0
0
python,django
27,999,374
2
false
1
0
You can specify different permissions in the auth_user table using the is_superuser and is_staff boolean attributes in the model. Maintaining the session and permissions is easier if you use the auth_user table
1
1
0
I am quite new to Django, I need a example code for creating login and registration form and a default page which a user can see only after logged in. Here important thing is that i want to use different table for users other than the auth_user table for admin. These users can logged in and able to perform some functionality. Please suggest me if its best way to have different table users for such customers? Or i can use the same auth_user table.
Login and registration example in Django with different user table
0.291313
0
0
1,284
28,005,981
2015-01-18T00:39:00.000
3
0
1
0
python
28,006,269
4
false
0
0
__init__ does act like a constructor. It needs an instance to do its job like setting attributes and so on. If __new__ doesn't return explicitly returns an instance, then None is returned by default. Imagine that what will happen when __init__ gets a None as an input and trying to set attributes? It will raise an exception called "AttributeError: 'NoneType' object has no attribute xxxxx". So I think it's natural that not to invoke __init__ when __new__ returns None.
1
7
0
There are many questions on SO asking why python doesn't always call __init__ after object creation. The answer, of course, is found in this excerpt from the documentation: If __new__() returns an instance of cls, then the new instance’s __init__() method will be invoked like __init__(self[, ...]), where self is the new instance and the remaining arguments are the same as were passed to __new__(). If __new__() does not return an instance of cls, then the new instance’s __init__() method will not be invoked. What is the design reason for this?
What is the design reason for the fact that if __new__ does not return an instance of cls, python does not invoke __init__?
0.148885
0
0
615
28,006,100
2015-01-18T01:01:00.000
0
0
1
0
python,class,pygame
50,237,749
3
false
0
1
Well you could always just re-assign a new group object to your old group. your_old_group = new_group I'm not entirely sure but it seems kill is meant to delete specific sprites.
1
1
0
I'm working on a pygame project at the moment and I'm wondering if there is an easy way to delete all sprites in a class. I have all the sprites in a group called self.spritegroup, so I couldn't just delete all objects in a group. Is there a simple shortcut to delete all objects in a class?
Pygame delete all objects in class
0
0
0
1,778
28,009,390
2015-01-18T11:56:00.000
6
0
0
0
python,python-2.7
28,009,442
4
false
0
0
This question is rather subjective to the definition of random, and the distribution you wish to replicate. The simplest solution: Choose a one random number, rand1 : [30,296] Choose a second random number, rand2 : [30, (326-Rand1)] Then the third cannot be random due to the constraint so calc via 356-(rand1+rand2)
1
0
1
please how can I randomly select 3 numbers whose sum is 356 and each of these 3 is more than 30? So output should be for example [100, 34, 222] (but not [1,5,350]) I would like to use random module to do this. thank you!
randomly select 3 numbers whose sum is 356 and each of these 3 is more than 30
1
0
0
131
28,009,999
2015-01-18T13:06:00.000
1
0
1
0
python,fork,daemon,server
28,010,240
1
false
0
0
It's done to ensure that the PID!=SID which ensures that the process cannotacquire tty(i.e. the terminal) to effectively be called a daemon process. A single fork results in the child having same SID as it's parent which means that it can acquire the tty if it's parent had such a permission or rights. So just exiting the parent may not help the cause. The best method to avoid this is to setsid to the first child and fork it and exit the first child too.
1
0
0
Why do we need to fork() twice to create a daemon of a python server? Can't the same be done using a single fork() without subsequently setting it as a session leader by using os.setsid()??
Why should forking be done twice in python to set up a daemon server?
0.197375
0
0
259
28,012,791
2015-01-18T17:44:00.000
-1
0
1
1
python,deployment,packaging
28,012,820
2
false
0
0
Just turn your computer into a server. Simply set up your router for port forwarding so that your server's content's will display when the router's IP is entered. You can of course purchase a DNS domain to give that IP a human readable URL.
1
0
0
I have written a python script on my local laptop which uses several third party packages. I now want to run my script regularly (via a cron job) on an external server. The external server most likely does not have all the dependencies installed, is there is a way to package and deploy my python script and dependencies in order to ensure that it will run? I have already tried to package the script as an exe, but failed to do so.
How do I deploy a python application to an external server?
-0.099668
0
0
452
28,012,863
2015-01-18T17:52:00.000
0
0
0
0
combobox,wxpython
28,027,478
1
false
0
1
I would recommend using the ComboCtrl instead of the ComboBox. The benefit is that the ComboCtrl is a custom widget, so it allows more flexibility. For example, the ComboCtrl provides a scrollbar for long strings. Check out the wxPython demo for some good examples.
1
1
0
In a wxpython Combobox, long strings get left-truncated in the dropdown portion. This can result in some values looking identical when they aren't. I'd like to provide better information to the user than that. The following options occur to me: Insert elipses in the middle of the string before adding it to the combobox's dropdown choices and expanding it back before placing back in the edit portion. Show a tooltip of the full string when the user mouses/hovers over a value in the dropdown. Problem is, the Combobox class does not expose events that enable either of the above. How can I intercept the events corresponding to either of the above? Any other ideas for making long combobox strings visible to the user? Thanks, RichK
Showing long strings in wxpython Combobox dropdown
0
0
0
172
28,015,822
2015-01-18T23:02:00.000
0
0
1
0
python,multithreading,concurrency,hardware
28,016,068
1
true
0
0
OK, so practically speaking, I think the answer is that time.sleep() will yield to other waiting threads. Perhaps other limitations or concerns will rear their heads in time, but at this stage, performance is not the issue, only concurrency.
1
0
0
I'm having trouble getting clarity on this. I have a program, say, with three threads - A, B and C. C is a 'hardware manager', A and B perform their own tasks using APScheduler for scheduling and as part of their routines, make requests of the hardware manager thread. If I use a time.sleep() in thread C (sometimes necessary to wait on certain hardware-related things to complete), can other methods on thread C be called? eg. 'A' asks 'C' to turn on a relay which powers a modem. The method incorporates a sleep(), so once it returns, 'A' can expect a network connection to be present. During this time though, 'B' might request a battery voltage reading from an ADC. Should I expect 'B' to be stuck waiting for the first method call to return?
What limitations does the Python GIL place on multithreading? (with example)
1.2
0
0
200
28,017,037
2015-01-19T02:11:00.000
6
0
1
0
python,heap
28,017,065
2
false
0
0
You can't. Or rather, you can't specify it as a lambda. You can however make a heap of tuples, heapq.heappush(Q, (key(v), v)) and heapq.heappop(Q)[1].
1
2
0
In python heapq if you are putting in objects, how can u use a lambda to specify its key? Like heapq.heappush(Q, v, key=lambda x: f(x)). Thanks
How to use lambdas in python heapq?
1
0
0
5,551
28,019,310
2015-01-19T06:51:00.000
0
1
0
0
django,apache,python-3.x,mod-wsgi
28,044,520
3
false
1
0
Thanks guys, I actually fixed the issue myself this morning by running the make install of mod_wsgi with .configure pointing to python3.4. I think you were right Adam.
3
6
0
Hi I am getting the error below when going to the website url on ubuntu server 14.10 running apache 2 with mod_wsgi and python on django. My django application uses python 3.4 but it seems to be defaulting to python 2.7, I am unable to import image from PIL and AES from pycrypto. ImportError at / cannot import name _imaging Request Method: GET Request URL: Django Version: 1.7.3 Exception Type: ImportError Exception Value: cannot import name _imaging Exception Location: /usr/local/lib/python3.4/dist-packages/PIL/Image.py in , line 63 Python Executable: /usr/bin/python Python Version: 2.7.6 Python Path: ['/var/www/blabla', '/usr/local/lib/python3.4/dist-packages', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/var/www/blabla', '/usr/local/lib/python3.4/dist-packages']
running django python 3.4 on mod_wsgi with apache2
0
0
0
5,696
28,019,310
2015-01-19T06:51:00.000
9
1
0
0
django,apache,python-3.x,mod-wsgi
28,038,045
3
true
1
0
I believe that mod_wsgi is compiled against a specific version of python, so you need a py3.4 version of mod_wsgi. You may be able to get one from your os's package repository or you can build one without too much drama. From memory you'll need gcc and python-dev packages (python3-dev?) to build. OK, quick google, for ubuntu 14.10: sudo apt-get install libapache2-mod-wsgi-py3 should install a py3 version of mod_wsgi (will probably want to remove the existing py2 version). Adding a shebang line won't do any good as the python interpreter is already loaded before the wsgi.py script is read.
3
6
0
Hi I am getting the error below when going to the website url on ubuntu server 14.10 running apache 2 with mod_wsgi and python on django. My django application uses python 3.4 but it seems to be defaulting to python 2.7, I am unable to import image from PIL and AES from pycrypto. ImportError at / cannot import name _imaging Request Method: GET Request URL: Django Version: 1.7.3 Exception Type: ImportError Exception Value: cannot import name _imaging Exception Location: /usr/local/lib/python3.4/dist-packages/PIL/Image.py in , line 63 Python Executable: /usr/bin/python Python Version: 2.7.6 Python Path: ['/var/www/blabla', '/usr/local/lib/python3.4/dist-packages', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/var/www/blabla', '/usr/local/lib/python3.4/dist-packages']
running django python 3.4 on mod_wsgi with apache2
1.2
0
0
5,696
28,019,310
2015-01-19T06:51:00.000
0
1
0
0
django,apache,python-3.x,mod-wsgi
28,032,221
3
false
1
0
From what I see here your application is using py2 interpreter with py3 compiled modules, which is no-go. One simple possible solution that comes me in mind is to add or change first line of manage.py to #!/usr/bin/python3. This will tell script to be interpreted with py3. Next on guess list would be misconfiguration in *.wsgi file or apache config, whichever you are using.
3
6
0
Hi I am getting the error below when going to the website url on ubuntu server 14.10 running apache 2 with mod_wsgi and python on django. My django application uses python 3.4 but it seems to be defaulting to python 2.7, I am unable to import image from PIL and AES from pycrypto. ImportError at / cannot import name _imaging Request Method: GET Request URL: Django Version: 1.7.3 Exception Type: ImportError Exception Value: cannot import name _imaging Exception Location: /usr/local/lib/python3.4/dist-packages/PIL/Image.py in , line 63 Python Executable: /usr/bin/python Python Version: 2.7.6 Python Path: ['/var/www/blabla', '/usr/local/lib/python3.4/dist-packages', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/var/www/blabla', '/usr/local/lib/python3.4/dist-packages']
running django python 3.4 on mod_wsgi with apache2
0
0
0
5,696
28,024,191
2015-01-19T12:00:00.000
0
0
0
0
python,machine-learning,scikit-learn
28,024,414
1
false
0
0
(My answer is based on the usage of svm.SVC, Lasso may be different.) I think that you are supposed pass the Gram matrix instead of X to the fit method. Also, the Gram matrix has shape (n_samples, n_samples) so it should also be too large for memory in your case, right?
1
4
1
I'm trying to train a linear model on a very large dataset. The feature space is small but there are too many samples to hold in memory. I'm calculating the Gram matrix on-the-fly and trying to pass it as an argument to sklearn Lasso (or other algorithms) but, when I call fit, it needs the actual X and y matrices. Any idea how to use the 'precompute' feature without storing the original matrices?
Using precomputed Gram matrix in sklearn linear models (Lasso, Lars, etc)
0
0
0
1,183
28,024,651
2015-01-19T12:26:00.000
0
0
0
0
python,django,login,navigation
28,024,750
2
false
1
0
1: create your own view that the login button take the person to when clicked and load your index.html template. you do not have to use the built in login. 2: logo? you can use any logo/format you want. Django doesn't come with a template that creates the look of the site (beside the admin one); so you need to create it.
2
0
0
Im using the Django template login and want to navigate from the login to my own written index.html file. so if a user push the "login" button the result page is my index file. My second question is how to use logos in django python and what structure i need in my project. best regards
Django Navigation from Template-Login to a self written index.html
0
0
0
85
28,024,651
2015-01-19T12:26:00.000
0
0
0
0
python,django,login,navigation
28,028,387
2
false
1
0
create custom log-in and registration in your project, and write the custom back-end if you have more user ,if request is came from user to log-in then redirect to index,html,
2
0
0
Im using the Django template login and want to navigate from the login to my own written index.html file. so if a user push the "login" button the result page is my index file. My second question is how to use logos in django python and what structure i need in my project. best regards
Django Navigation from Template-Login to a self written index.html
0
0
0
85
28,025,666
2015-01-19T13:24:00.000
15
0
0
0
python-3.x,tkinter
28,027,692
1
true
0
1
If you give the containing frame a color, and use options to put padding between cells, the background will bleed through the gaps. This only works where there are widgets. If you have spans that are empty, you won't see grid lines. It's important to realize that you aren't creating a grid object. "grid" is not a thing, it's just instructions for how to lay out a set of widgets. If there is nothing in a row or column, that column won't show up. You don't create a grid per se, you tell a widget to display inner widgets using conceptual rows and columns. Another trick to learning to work with grid is to give each frame you're trying to use in a grid a distinctive color so you can see where one frame ends and another begins. The best thing to do when struggling with a layout is to get out pencil and paper. Draw out your UI, and natural borders should be evident. You can then use that as a guide to decide what the grid options should be.
1
15
0
Is there a trick to show the grid layout cells (or the borders of the cells) when using it, in order to have a visual idea of what is going on behind the scenes? I have searched a little bit, but have not found nothing yet.
Show grid layout cells in tkinter
1.2
0
0
17,747
28,026,439
2015-01-19T14:05:00.000
0
0
0
0
python,linux,iptables
29,113,478
2
false
0
0
From the networking I've done, you'll need to put the 2 NFQUEUE commands into different table/chain tuples, eg. one in filter/FORWARD and the other in mangle/PREROUTING. Basically, once a packet has gone to a single NFQUEUE in a table/chain combo, it's done for that table/chain and it exits the main chain entirely. My personal recommendation is to put your NFQUEUE into mangle/PREROUTING, which will be called before most of the other tables (assuming you're putting the Suricata NFQUEUE statement into the filter table). I hope this makes sense. Hope it helps!
1
1
0
Here is what I am trying to achieve. I have an inline linux box running Suricata capable of dropping packets. This works with the standard method of placing all traffic onto NFQUEUE 0 and then setting suricata listening on that. The code I am writing needs to be able to intercept DNS and Kerberos packets on NFQUEUE 1, but it still needs to be scanned inline with Suricata, so the packet needs to be passed back to another NFQUEUE that suricata is listening on because I don't think both programs can act as a consumer on the same queue. So far I have worked out how to chop out DNS and Kerberos traffic to a different NFQueue, so suricata listens on NFQUEUE 1 and my program listens on NFQUEUE 2, what I need is a way to use iptables to put traffic from one NFQUEUE onto another. Something like this: iptables -I NFQUEUE --queue-num 1 -j NFQUEUE --queue-num 2 There is probably something with post routing that I am missing, (Something like outbound packets that match my origional DNS/Kerboros rules being placed on to the NFqueue, but this will created a loop when I tested it) Thanks for your time.
NFQUEUE/IPtables - Suricata Inline With Python Intercept for DNS
0
0
0
1,911
28,028,695
2015-01-19T16:00:00.000
0
0
1
0
python
28,028,959
3
false
0
0
Most modules are actually written in C, like Pygame for example. Python itself is based on C. You can't jump to conclusions, but if the library is pure Python, I'd suggest copying the package into your project directory and importing, rather than copying and pasting code snippets.
1
1
0
Given that every library is a python code itself, I think its logical that instead of using the import command, we can actually copy the whole code of that library and paste it to the top of our main.py. I'm working on a remote pc, I cannot install libraries, can I use a library by just doing this? Forgive me if this a very silly question. Thanks
Manually adding libraries
0
0
1
231
28,029,215
2015-01-19T16:27:00.000
0
1
1
0
python,python-2.7
28,029,391
3
false
0
0
I belive second version (not 5 % 2) is faster since unary_not operation is faster than compare operation.
2
0
0
I tried using timeit and time.clock() but my computer's speed is inconsistent and I couldn't find out which is faster, If this question already exists then I apologize but I couldn't find it.
What is faster? "5 % 2 == 0" or "not 5 % 2"
0
0
0
142
28,029,215
2015-01-19T16:27:00.000
1
1
1
0
python,python-2.7
28,029,315
3
false
0
0
Testing %2 (i.e. for oddness / evenness) can be performed quickly by examining the least significant bit of a number. (Do that with logical AND: (n & 1)). You'd be hard pressed to beat that. But any potential performance gain might be probably attenuated in Python, so profile it and use if only, in your judgement, the performance gain outweighs the obfuscating effects of an expression which, although idiomatic in C and C++, may well be unfamiliar to folk with whom you are collaborating.
2
0
0
I tried using timeit and time.clock() but my computer's speed is inconsistent and I couldn't find out which is faster, If this question already exists then I apologize but I couldn't find it.
What is faster? "5 % 2 == 0" or "not 5 % 2"
0.066568
0
0
142
28,033,003
2015-01-19T20:30:00.000
0
0
1
0
python,pygame,pyinstaller
28,058,867
2
true
0
1
i suggest trying another program like py2exe to bundle python programs i currently have not had any issues with it. Their are lots of good youtube videos on the process which is cmd based. I have had some personal problems using pyinstaller and think it is just buggy assuming your program is not flawed.
1
6
0
I have tried multiple times to use PyInstaller to bundle my Python2 programs, but it never seems to work with the Pygame module. I have seen many other issues on this topic, but I couldn't find any useful answers. Does anybody know a solution to this? I am trying to do this on Ubuntu 14.10. -Edit- To be more specific: "never seems to work" means that when I run PyInstaller and build the application it appears to work and makes the application. When you try to run the application nothing happens.
Pyinstaller with pygame
1.2
0
0
9,558
28,035,119
2015-01-19T23:10:00.000
1
0
0
0
python,django,git
68,283,683
10
false
1
0
You should think of migrations as a version control system for your database schema. makemigrations is responsible for packaging up your model changes into individual migration files - analogous to commits - and migrate is responsible for applying those to your database. The migration files for each app live in a “migrations” directory inside of that app, and are designed to be committed to, and distributed as part of, its codebase. You should be making them once on your development machine and then running the same migrations on your colleagues’ machines, your staging machines, and eventually your production machines. golden rule : Make once on dev and migrate on all
5
187
0
Should I be adding the Django migration files in the .gitignore file? I've recently been getting a lot of git issues due to migration conflicts and was wondering if I should be marking migration files as ignore. If so, how would I go about adding all of the migrations that I have in my apps, and adding them to the .gitignore file?
Should I be adding the Django migration files in the .gitignore file?
0.019997
0
0
78,791
28,035,119
2015-01-19T23:10:00.000
3
0
0
0
python,django,git
56,424,456
10
false
1
0
Gitignore the migrations, if You have separate DBs for Development, Staging and Production environment. For dev. purposes You can use local sqlite DB and play with migrations locally. I would recommend You to create four additional branches: Master - Clean fresh code without migrations. Nobody is connected to this branch. Used for code reviews only Development - daily development. Push/pull accepted. Each developer is working on sqlite DB Cloud_DEV_env - remote cloud/server DEV environment. Pull only. Keep migrations locally on machine, which is used for the code deployment and remote migrations of Dev database Cloud_STAG_env - remote cloud/server STAG environment. Pull only. Keep migrations locally on machine, which is used for the code deployment and remote migrations of Stag database Cloud_PROD_env - remote cloud/server DEV environment. Pull only. Keep migrations locally on machine, which is used for the code deployment and remote migrations of Prod database Notes: 2, 3, 4 - migrations can be kept in repos but there should be strict rules of pull requests merging, so we decided to find a person, responsible for deployments, so the only guy who has all the migration files - our deploy-er. He keeps the remote DB migrations each time we have any changes in Models.
5
187
0
Should I be adding the Django migration files in the .gitignore file? I've recently been getting a lot of git issues due to migration conflicts and was wondering if I should be marking migration files as ignore. If so, how would I go about adding all of the migrations that I have in my apps, and adding them to the .gitignore file?
Should I be adding the Django migration files in the .gitignore file?
0.059928
0
0
78,791
28,035,119
2015-01-19T23:10:00.000
1
0
0
0
python,django,git
52,187,013
10
false
1
0
Having a bunch of migration files in git is messy. There is only one file in migration folder that you should not ignore. That file is init.py file, If you ignore it, python will no longer look for submodules inside the directory, so any attempts to import the modules will fail. So the question should be how to ignore all migration files but init.py? The solution is: Add '0*.py' to .gitignore files and it does the job perfectly. Hope this helps someone.
5
187
0
Should I be adding the Django migration files in the .gitignore file? I've recently been getting a lot of git issues due to migration conflicts and was wondering if I should be marking migration files as ignore. If so, how would I go about adding all of the migrations that I have in my apps, and adding them to the .gitignore file?
Should I be adding the Django migration files in the .gitignore file?
0.019997
0
0
78,791
28,035,119
2015-01-19T23:10:00.000
4
0
0
0
python,django,git
37,484,659
10
false
1
0
I can't imagine why you would be getting conflicts, unless you're editing the migrations somehow? That usually ends badly - if someone misses some intermediate commits then they won't be upgrading from the correct version, and their copy of the database will be corrupted. The process that I follow is pretty simple - whenever you change the models for an app, you also commit a migration, and then that migration doesn't change - if you need something different in the model, then you change the model and commit a new migration alongside your changes. In greenfield projects, you can often delete the migrations and start over from scratch with a 0001_ migration when you release, but if you have production code, then you can't (though you can squash migrations down into one).
5
187
0
Should I be adding the Django migration files in the .gitignore file? I've recently been getting a lot of git issues due to migration conflicts and was wondering if I should be marking migration files as ignore. If so, how would I go about adding all of the migrations that I have in my apps, and adding them to the .gitignore file?
Should I be adding the Django migration files in the .gitignore file?
0.07983
0
0
78,791
28,035,119
2015-01-19T23:10:00.000
5
0
0
0
python,django,git
45,315,509
10
false
1
0
The solution usually used, is that, before anything is merged into master, the developer must pull any remote changes. If there's a conflict in migration versions, he should rename his local migration (the remote one has been run by other devs, and, potentially, in production), to N+1. During development it might be okay to just not-commit migrations (don't add an ignore though, just don't add them). But once you've gone into production, you'll need them in order to keep the schema in sync with model changes. You then need to edit the file, and change the dependencies to the latest remote version. This works for Django migrations, as well as other similar apps (sqlalchemy+alembic, RoR, etc).
5
187
0
Should I be adding the Django migration files in the .gitignore file? I've recently been getting a lot of git issues due to migration conflicts and was wondering if I should be marking migration files as ignore. If so, how would I go about adding all of the migrations that I have in my apps, and adding them to the .gitignore file?
Should I be adding the Django migration files in the .gitignore file?
0.099668
0
0
78,791
28,036,292
2015-01-20T01:22:00.000
5
0
1
0
python,importerror,python-newspaper
29,700,163
2
false
0
0
I was able to fix this problem by creating an images directory in /usr/local/lib/python2.7/dist-packages/newspaper , moving images.py to this directory, and placing a blank __init__.py in this directory.
1
3
0
I am pretty new to python and am trying to import newspaper for article extraction. Whenever I try to import the module I get ImportError: cannot import name images. Anyone come across this problem and found a solution?
ImportError when installing newspaper
0.462117
0
0
1,499
28,038,384
2015-01-20T05:30:00.000
1
0
0
0
python,python-2.7,openssl,pycrypto,brython
28,065,519
1
false
1
0
So, first things first: it is not usueal to have the same code to run on server side and client side. Second thing: be aware that no authentication (or "signing") done on client side can be regarded as safe. At most, the client side can take care of closely coupling the signing with the UI to give the user dynamic feedback - but since whatever requests the client side send to the server can very easily be impersonated by an script, authentication must be performed server side for each request - for example, a variable saying the current user has authenticated correctly can just be sent as "True", regardless of usernames and passwords actually known. Third thing: despite all this, since there are these frameworks for using Python or a Python like language client side, it is indeed possible to have some modules in a code base that are used both client side and server side. Of those, I am most familiar with Brython which has achieved a nice level of Python 3.x compatibility and I indeed have a project sharing code client side and server side. The re-used code would have to be refactored to abstract any I/O (like getting user input, or getting values from a database), of couse, since these are fundamentally different things on server side, and client side. Still, some core logic can be in place that is reused both sides. However third party python modules, like Pycrypto won't work client side (you could probably code a xmlrpc/jsonrpc like call to use it server side) - and although Python's hashlib is not implemented now in Brython, the project has got a momentum that opening a feature request for at least the same codecs that exist in javascript could be fulfilled in a matter of days. (bugs/features requests can be open at github.com/brython-dev/brython) (PS. I just found out, to my dismay, that currently there is no standard way to compute any hash, not even md5, in Javascript without third party modules - that just emphasize the utilities of frameworks like Brython or coffescript which can bring up a bundle of functionality in a clean way)
1
1
0
Client side tool to extract values such as common name serial number and public key from pfx file which is loaded by client, and then sign the public key and send to server.. I have completed the backend python code which will import modules from OpenSSL.Crypto library.. How to execute the same in client side?.. i.e signing operation should be done in client side, In google i found like Brython, skulpt, pyjams help in this.. But i m confused to start.. Any suggestions?
Python Client side tool( should work in browser) to extract values from a pfx file and sign it
0.197375
0
1
146
28,039,131
2015-01-20T06:36:00.000
0
0
0
0
python,mysql,mysql-python,mysql-connector,python-3.4
47,486,286
2
false
0
0
Relative to Python 3.6: The official mysql connector only worked in python 2.7 after i installed it on OSX. As an alternative I used the easy_install-3.6 python module integrated in python 3.6 Go to directory: /Library/Frameworks/Python.framework/Versions/3.6/bin command: easy_install-3.6 mysql-connector-python
1
0
0
Python 2.7 and 3.4 co-exist in my mac-os. After installing the official mysql connector (downloaded from dev.mysql.com), import mysql.connector can only pass in python 2.7. Is there any way for the connector to work for both python versions?
mysql-python connector work with python2.7 and 3.4 at the same time
0
1
0
569
28,041,429
2015-01-20T09:11:00.000
1
0
0
0
python,peewee
28,041,761
3
true
1
0
According to source code, no way to find out. Also, according to documentation, it is not recommended to use this method. I suggest to use try/except/else clause.
1
0
0
AFAIK, peewee's Model.get_or_create() doesn't return a flag that indicates a creation, unlike django's get_or_create(). Is there a good way to check if an instance returned by get_or_create() is freshly created? Thanks
get_or_create: is it a 'get' or a 'create'?
1.2
0
0
3,290
28,042,290
2015-01-20T09:53:00.000
0
0
0
0
python,django,versioning
28,045,449
2
false
1
0
As an other answer mentions, Django doesn't store old values by default. You can do this yourself by grabbing the old value and storing it to another attribute on your model on save.
1
0
0
For a model instance does Django store the model instance value by default that I could retrieve before it has been changed? Example I would like to get the status(model attribute) changed for a given date? I am able to check the attribute from LogEntry, But is there some default which stores the actual old value that can be retrieved before the status value had been changed? I am aware of versioning add ons in django.
Does django store instance values before changing it by default
0
0
0
42
28,042,692
2015-01-20T10:12:00.000
1
0
1
0
python,infinite,timedelta
28,043,090
3
false
0
0
The typical way to express an unfinished interval is to use a datetime type's maximum value or NULL for the ending time. As it was shown, you cannot really perform calculations involving the infinite value and get meaningful results. Thus, NULL is better in this regard by simply not allowing you to.
1
7
0
How can you express an infinite timedelta in Python? Up to now we use datetime from stdlib, but we could switch, if it is only supported in a third party library. PostgreSQL does support it. And it would be handy in my case. I want to use it to express an not finished interval. I could use None, but an infinite timedelta could avoid a lot of conditions (if statements).
Infinite Timedelta in Python
0.066568
0
0
2,680
28,044,269
2015-01-20T11:29:00.000
1
0
1
0
python,python-asyncio
28,050,981
3
false
0
0
You may implement own asyncio transport which utilizes .recv_into() function but yes, for now asyncio has not a way to use .recv_into() out-the-box. Personally I doubt in very big speedup: when you develop with C the zero-copy is extremely important but for high-level languages like Python benefits are much lesser.
2
5
0
Socket module has a socket.recv_into method, so it can use user-defined bytebuffer (like bytearray) for zero-copy. But perhaps BaseEventLoop has no method like that. Is there a way to use method like socket.recv_into in asyncio?
is there any operation like socket.recv_into in python 3 asyncio?
0.066568
0
1
1,555
28,044,269
2015-01-20T11:29:00.000
1
0
1
0
python,python-asyncio
28,045,430
3
false
0
0
The low-level socket operations defined for BaseEventLoop require a socket.socket object to be passed in, e.g. BaseEventLoop.sock_recv(sock, nbytes). So, given that you have a socket.socket, you could call sock.recv_into(). Whether it is a good idea to do that is another question.
2
5
0
Socket module has a socket.recv_into method, so it can use user-defined bytebuffer (like bytearray) for zero-copy. But perhaps BaseEventLoop has no method like that. Is there a way to use method like socket.recv_into in asyncio?
is there any operation like socket.recv_into in python 3 asyncio?
0.066568
0
1
1,555
28,057,383
2015-01-20T23:56:00.000
4
0
0
0
python,sockets,network-programming
28,057,748
1
false
0
0
From the python doc: Note close() releases the resource associated with a connection but does not necessarily close the connection immediately. If you want to close the connection in a timely fashion, call shutdown() before close().
1
3
0
I was looking at how to send a TCP FIN using python socket. I tried using the socket.socket.close and it sends out a TCP RST and not a TCP FIN. Can someone please let me know what is the API?
how to send a TCP FIN using python sockets
0.664037
0
1
3,320
28,057,407
2015-01-20T23:59:00.000
0
0
0
0
python,dictionary,storage,store,pickle
28,057,921
2
false
0
0
With 60,000 dimensions do you mean 60,000 elements? if this is the case and the numbers are 1..10 then a reasonably compact but still efficient approach is to use a dictionary of Python array.array objects with 1 byte per element (type 'B'). The size in memory should be about 60,000 entries x 60,000 bytes, totaling 3.35Gb of data. That data structure is pickled to about the same size to disk too.
1
5
1
I have a dictionary with many entries and a huge vector as values. These vectors can be 60.000 dimensions large and I have about 60.000 entries in the dictionary. To save time, I want to store this after computation. However, using a pickle led to a huge file. I have tried storing to JSON, but the file remains extremely large (like 10.5 MB on a sample of 50 entries with less dimensions). I have also read about sparse matrices. As most entries will be 0, this is a possibility. Will this reduce the filesize? Is there any other way to store this information? Or am I just unlucky? Update: Thank you all for the replies. I want to store this data as these are word counts. For example, when given sentences, I store the amount of times word 0 (at location 0 in the array) appears in the sentence. There are obviously more words in all sentences than appear in one sentence, hence the many zeros. Then, I want to use this array tot train at least three, maybe six classifiers. It seemed easier to create the arrays with word counts and then run the classifiers over night to train and test. I use sklearn for this. This format was chosen to be consistent with other feature vector formats, which is why I am approaching the problem this way. If this is not the way to go, in this case, please let me know. I am very much aware that I have much to learn in coding efficiently! I also started implementing sparse matrices. The file is even bigger now (testing with a sample set of 300 sentences). Update 2: Thank you all for the tips. John Mee was right by not needing to store the data. Both he and Mike McKerns told me to use sparse matrices, which sped up calculation significantly! So thank you for your input. Now I have a new tool in my arsenal!
Store large dictionary to file in Python
0
0
0
6,975
28,057,552
2015-01-21T00:14:00.000
0
0
0
0
python,sockets,buffer,recv
28,057,641
2
false
0
0
Learn about OSI layers, and different connections such as TCP and UDP. socket.send implements a TCP transmission of data. If you look into the OSI layers, you will find out that the 4th layer (i.e. transport layer) will buffer the data to be transmitted. The default size of the buffer depends on the implementation.
2
0
0
I'm trying to learn how socket module works and I have a dumb question: Where is socket.send()'s sent data stored before being cleared by socket.recv()?. I believe there must be a buffer somewhere in the middle awaiting for socket.recv() calls to pull this data out. I just made a test with a server which sent a lot of data at once, and then connected to a client that (intentionally) pulled data very slowly. The final result was that data was sent within a fraction of a second and, on the other side, it was entirely received in small chunks of 10 bytes .recv(10), which took 20 seconds long . Where has this data been stored meanwhile??, what is the default size of this buffer?, how can it be accessed and modified? thanks.
Trying to understand buffering in Python socket module
0
0
1
184
28,057,552
2015-01-21T00:14:00.000
0
0
0
0
python,sockets,buffer,recv
28,057,652
2
true
0
0
The OS (kernel) buffers the data. On Linux the buffer size parameters may be accessed through the /proc interface. See man 7 socket for more details (towards the end.)
2
0
0
I'm trying to learn how socket module works and I have a dumb question: Where is socket.send()'s sent data stored before being cleared by socket.recv()?. I believe there must be a buffer somewhere in the middle awaiting for socket.recv() calls to pull this data out. I just made a test with a server which sent a lot of data at once, and then connected to a client that (intentionally) pulled data very slowly. The final result was that data was sent within a fraction of a second and, on the other side, it was entirely received in small chunks of 10 bytes .recv(10), which took 20 seconds long . Where has this data been stored meanwhile??, what is the default size of this buffer?, how can it be accessed and modified? thanks.
Trying to understand buffering in Python socket module
1.2
0
1
184
28,059,694
2015-01-21T04:37:00.000
1
0
1
0
python,user-input,file-transfer
28,059,825
2
false
0
0
First, you need to prompt the user for their file size and transfer speed, obviously. I usually use input. The reason is that sys takes arguments directly after the name of your file in the command line, so you'd say python file.py 10 11. I find creating a better user interface for taking input via prompts to be more logical. so for your case: file_size = input("File Size in MB: ") speed = input("Transfer speed in Megabits/second: ") Now taking those parameters, you have to take into account that one megabyte = 8 megabits, and then do simple unit conversions to come to the final answer of seconds. You asked for a start, so I'll refrain from simply posting a solution. NOTE: This uses Python 3. The Python 2 version would use raw_input.
1
0
0
I am fumbling my way through learning python and need some help getting started on some things. For this project I need to create a program that calculates file transfer time. I need to prompt the user for a file size in megabytes. I also need to prompt the user for the estimated transfer speed in megabits per second. If the transfer time is more than one minute I need to display the time in minutes. Where should I start? I know I will need to have some user input (obviously), import sys, and use sys.argv somewhere...
Python - Calculate file transfer time
0.099668
0
0
2,626
28,059,937
2015-01-21T05:00:00.000
0
1
0
0
python,linux,django,printing,raspberry-pi
28,060,170
1
false
1
0
install a print server on the pi and serve the printer. you may need some sort of tunnel so that the VPS can reach the pi.
1
0
0
I have a website in django, I only going to visit the website using a Raspberry Pi, I need print a data, and for print I am using a Thermal Printer in the Raspberry Pi. I can print from the Raspberry pi using ("/dev/ttyAMA0",19200,timeout=5) for obtain serial communication This work fine but only when the project is hosting local in the raspberry Pi , but the django project is hosting in a VPS with ubuntu then I have problems for printer from the Raspberry PI. because in ubuntu there are not "/dev/ttyAMA0" How I can work with this thermal Printer from a django project for print correctly using a RaspberryPi
django work with a Thermal Printer in Raspberry PI
0
0
0
349
28,059,948
2015-01-21T05:01:00.000
0
0
0
1
python,linux,pip,openstack,devstack
28,060,641
2
false
0
0
Edit the script and append --allow-unverified ie pip install package_name==version --allow-unverified package_name
2
1
0
I am not able to install OpenStack. I executed the script stack.sh and there was Error on exit. I looked at the log, the error is during the execution of the command: sudo -H -E python /home/sagar/devstack/files/get-pip.py : This is the error during the execution of the below command: sudo -H -E python /home/sagar/devstack/files/get-pip.py Collecting pip Could not find any downloads that satisfy the requirement pip No distributions at all found for pip ++ err_trap ++ local r=1
./stack.sh failed while installing Openstack
0
0
0
2,026
28,059,948
2015-01-21T05:01:00.000
1
0
0
1
python,linux,pip,openstack,devstack
28,063,958
2
false
0
0
I got the problem. The system date was not correct.
2
1
0
I am not able to install OpenStack. I executed the script stack.sh and there was Error on exit. I looked at the log, the error is during the execution of the command: sudo -H -E python /home/sagar/devstack/files/get-pip.py : This is the error during the execution of the below command: sudo -H -E python /home/sagar/devstack/files/get-pip.py Collecting pip Could not find any downloads that satisfy the requirement pip No distributions at all found for pip ++ err_trap ++ local r=1
./stack.sh failed while installing Openstack
0.099668
0
0
2,026
28,063,099
2015-01-21T08:58:00.000
1
0
0
0
python-2.7,customization,kivy
28,068,266
1
false
0
1
These variables can be set in the buildozer.spec, e.g. icon.filename in the [app] section.
1
1
0
How do you customize the kivy logo for a kivy app? I am using Buildozer in Ubuntu 14.04.
Customizing a kivy app logo using Buildozer
0.197375
0
0
448
28,063,378
2015-01-21T09:14:00.000
1
0
0
0
python,macos,apache,ampps
28,284,966
1
true
1
0
As far as I can tell, AMPPS does not work on Yosemite at all (@ v2.8)
1
0
0
I am have just recently acquired a new Mac (Yosemite OSX 10.10) I am reconfiguring everything and I need to work with external configs and Python on some new projects. Which bring me to two additional question: how to include an extra configuration with an external config file ? can I just include it to the httpd.conf of Apache from Ampps GUI? would I need to do additional settings in the Admin Panel ? how do I set up the mod_wsgi in Ampps, is there a specific set of actions to trigger ? will I need some specific workflow to get it to work with my external config (bunch of virtual hosts in which some application run on Python) Thanks in advance.
AMPPS Yosemite Python configuration
1.2
0
0
259
28,064,634
2015-01-21T10:17:00.000
2
0
0
0
python,random,scikit-learn
57,910,696
7
false
0
0
If there is no randomstate provided the system will use a randomstate that is generated internally. So, when you run the program multiple times you might see different train/test data points and the behavior will be unpredictable. In case, you have an issue with your model you will not be able to recreate it as you do not know the random number that was generated when you ran the program. If you see the Tree Classifiers - either DT or RF, they try to build a try using an optimal plan. Though most of the times this plan might be the same there could be instances where the tree might be different and so the predictions. When you try to debug your model you may not be able to recreate the same instance for which a Tree was built. So, to avoid all this hassle we use a random_state while building a DecisionTreeClassifier or RandomForestClassifier. PS: You can go a bit in depth on how the Tree is built in DecisionTree to understand this better. randomstate is basically used for reproducing your problem the same every time it is run. If you do not use a randomstate in traintestsplit, every time you make the split you might get a different set of train and test data points and will not help you in debugging in case you get an issue. From Doc: If int, randomstate is the seed used by the random number generator; If RandomState instance, randomstate is the random number generator; If None, the random number generator is the RandomState instance used by np.random.
2
189
1
I want to implement a machine learning algorithm in scikit learn, but I don't understand what this parameter random_state does? Why should I use it? I also could not understand what is a Pseudo-random number.
Random state (Pseudo-random number) in Scikit learn
0.057081
0
0
236,863
28,064,634
2015-01-21T10:17:00.000
23
0
0
0
python,random,scikit-learn
50,672,222
7
false
0
0
If you don't specify the random_state in your code, then every time you run(execute) your code a new random value is generated and the train and test datasets would have different values each time. However, if a fixed value is assigned like random_state = 42 then no matter how many times you execute your code the result would be the same .i.e, same values in train and test datasets.
2
189
1
I want to implement a machine learning algorithm in scikit learn, but I don't understand what this parameter random_state does? Why should I use it? I also could not understand what is a Pseudo-random number.
Random state (Pseudo-random number) in Scikit learn
1
0
0
236,863
28,069,439
2015-01-21T14:19:00.000
7
0
0
0
python,mysql,openerp-7,odoo
28,069,999
1
true
1
0
You can't: the Odoo ORM does not support null numeric values. If you really need to distinguish an "empty" value from a zero value, you need a workaround: either use a string field (simpler, but needs additional checks to allow only number and it's harder to perform calculations) or use a second boolean field to mark empty values.
1
8
0
In Odoo/OpenERP 7, I have a nullable numeric column called balance 'balance': fields.float(string='Balance',digits=(20,2)) I am trying to use Python code to update None into the field self.write(cr, uid, [1], { 'balance':None }) but, rather frustratingly, Python treats None the same as 0 so I end up with 0 in the DB instead of the expected Null. Any pointers on how I can use the write command to store a null value?
Odoo - Write null to numeric column
1.2
0
0
4,136
28,070,431
2015-01-21T15:07:00.000
0
0
0
1
python,linux,wifi,ftp-server
28,070,608
1
false
0
0
On Linux the most straightforward way would be to either use SSH (SCP), for which you only need SSH daemon enabled on the server machine, or to run a trivial webserver. No coding required in either cases.
1
0
0
My application running under Linux creates four to seven data files in a directory whose name includes the client and datetime.These need to be copied by other devices - usually a Linux PC/laptop and potentially an Android phone. Currently the copying is done via a cable connection. I now need to make this wireless and more secure. The solution seems to be to run my PC as an FTP server and allow others to login to pull off the files. Ideally this should be coded in Python 2.7 although 'C' could be an option. The majority of the information I can find, particularly in relation to Python, refers to using the PC as a client rather than a server. Are there Python extensions for running an FTP server or is there a better way of tackling this? Thank you...
Linux PC: How to let other Linux devices copy files
0
0
0
56
28,072,368
2015-01-21T16:40:00.000
1
0
1
0
python,global-variables
28,072,666
3
false
0
0
If you only need a reference to global state, consider passing that as an argument to the function instead of relying on kicking upward through scopes until you hit one where the global value is defined. Under the assumption that the global state truly will only be referenced and never mutated, there's no good reason not to just pass it as an argument whenever a function needs it. (If the global value is a large data structure itself, you should be passing it around by reference anyway). Usually, this still results in a confused design, because you will start to pass the state argument as a parameter all over the place. For example, if a function calls some other function and that interior function needs the global state, then so does the outer function. "Solving" this by having the interior function just kick upward through scopes doesn't really reduce any of the dependence, since the outer function still needs to be nested within scopes that eventually result in finding the global variable. So why not at least do a favor for future code readers and make the use of the variable explicit by naming it in the argument list for the function?
2
1
0
There are plenty of posts on when global variables must be declared in Python, and relatedly, on Python scope rules. I haven’t been able to find a satisfactory treatment of the more specific question above, however, either on the internet or in text books I’ve consulted. Even as a beginner programmer, I can appreciate the potential difficulties that could arise from assigning to global names in a function, and why most programmers recommend that the global statement therefore be used sparingly. However, many of my early programmes contain many functions which themselves contain numerous references (i.e. not requiring that global be declared) to global variables. It seems to me that, because these are just references (i.e. not changing the variable), there isn’t the same potential for difficulties to arise as in the case of assigning to globals. I’d appreciate if more experienced programmers could guide me as to the best practice of global references (as opposed to assignments) in functions. Should I change these global references to function arguments? Many thanks.
Referencing (as opposed to assigning to) global variables in Python functions. Bad practice or not?
0.066568
0
0
88
28,072,368
2015-01-21T16:40:00.000
1
0
1
0
python,global-variables
28,072,436
3
false
0
0
If you try to use a global variable inside of a function the interpreter will try to look for it in the nearest scope, then in others possible. If your code is complicated enough, it'll cycle through lots of scopes and lots of different variables trying to find the one you want. If your script only consists of some functions that do not use the global variable frequently it'll be OK. All in all, the more complicated your code is, the more time will be spent just searching for the variable.
2
1
0
There are plenty of posts on when global variables must be declared in Python, and relatedly, on Python scope rules. I haven’t been able to find a satisfactory treatment of the more specific question above, however, either on the internet or in text books I’ve consulted. Even as a beginner programmer, I can appreciate the potential difficulties that could arise from assigning to global names in a function, and why most programmers recommend that the global statement therefore be used sparingly. However, many of my early programmes contain many functions which themselves contain numerous references (i.e. not requiring that global be declared) to global variables. It seems to me that, because these are just references (i.e. not changing the variable), there isn’t the same potential for difficulties to arise as in the case of assigning to globals. I’d appreciate if more experienced programmers could guide me as to the best practice of global references (as opposed to assignments) in functions. Should I change these global references to function arguments? Many thanks.
Referencing (as opposed to assigning to) global variables in Python functions. Bad practice or not?
0.066568
0
0
88
28,076,316
2015-01-21T20:34:00.000
2
0
0
0
python,django,scheduled-tasks,celery,django-celery
28,076,369
2
false
1
0
Use a simple cron job to trigger a custom Django management command.
2
0
0
Some tuples in my database need to be erased after a given time. I need my django app to check if the rows have expired. While I can definitely write the function, how do I make Django run at everyday at a fixed time? I have heard about Task Queues like Celery. Are they too much powerful for this? Is their anything simpler? May be something build-in?
How do I make my django application perform a job at a fixed time everyday?
0.197375
0
0
140
28,076,316
2015-01-21T20:34:00.000
-1
0
0
0
python,django,scheduled-tasks,celery,django-celery
28,076,358
2
false
1
0
Use a threading.Thread to schedule a continuous event loop. In your thread, use time.sleep to create a gap before the next occurrence of the event.
2
0
0
Some tuples in my database need to be erased after a given time. I need my django app to check if the rows have expired. While I can definitely write the function, how do I make Django run at everyday at a fixed time? I have heard about Task Queues like Celery. Are they too much powerful for this? Is their anything simpler? May be something build-in?
How do I make my django application perform a job at a fixed time everyday?
-0.099668
0
0
140
28,078,555
2015-01-21T23:07:00.000
0
0
0
0
python,opencv,image-processing
28,078,626
1
false
0
0
Very open question, but OpenCV is where to be looking. Your best bet would probably be building Haar cascade classifiers. Plenty of reading material on the topic, somewhat overwhelming at first but that is what I would be looking into.
1
0
1
I've been looking into this for a while and was wondering the feasibility of using something like feature detection in OpenCV to do the following: I'm working on a project that requires identifying items within a grocery store that do not have barcodes (i.e. produce). I want to build a local database of the various items to be identified and, using images of the items, compare them to the database and tell what the item is. This doesn't need to be perfectly accurate (it doesn't need to tell between different types of apples, for example), but I want it to be able to tell between something like a peach and an orange, but still be able to tell a banana is a banana even though its color is slightly different. My question is, is what I'm trying to do possible using OpenCV? From what I've been reading, identical objects can be tracked with relative ease, but I'm having trouble stumbling upon anything more like what I'm attempting to do. Any nudges in the right direction would be immensely appreciated.
Detecting similar objects using OpenCV
0
0
0
243
28,083,203
2015-01-22T07:19:00.000
0
0
1
0
python,matplotlib
28,083,896
1
false
0
0
Yes the matplotlib site above will do the job! The same procedure you will have to follow to install numpy, which I guess you will also need.
1
0
1
I just started using python and definitely need the matplotlib. I'm confused by the fact that there is even not a clear explanation for the basic ideas behind install a lib/package in python generally. Anyway, I'm using windows and have installed Python 3.4.2 downloaded from the offical website, how should I install the matplotlib? Thanks in advance!
How to install matplotlib on windows
0
0
0
986
28,084,065
2015-01-22T08:20:00.000
2
0
0
0
python,nginx,flask
28,084,606
2
false
1
0
Serve your image through Flask instead of your web server, treat it like any other url with permissions. Nginx is obviously a much better choice to serve your static files but it won't integrate with Flask.
1
1
0
I've created an application in which media files(files that are uploaded by users, not css/js) are served statically by another server on the subdomain like: media.example.com/path/to/image.jpg. How can I limit access to the images so that only certain people who are logged in and have permission can see them? Please note that persmissions on page in which an image is displayed are working but I want to further limit access to the images themselves so image urls can't be shared. Thanks
How to handle static/media file permission on flask?
0.197375
0
0
1,641
28,092,518
2015-01-22T15:27:00.000
0
0
1
0
python,matplotlib,figures
28,105,601
1
false
0
0
Figures need a canvas to draw on. Try fig.draw()
1
2
1
I am working with a matplotlib-based routine that returns a figure and, as separate objects, the axes that it contains. Is there any way, that I can display these things and edit them (annotate, change some font sizes, things like that)? "fig.show()" doesn't work, just returns an error. Thanks.
How to display a matplotlib figure object
0
0
0
1,408
28,096,856
2015-01-22T19:13:00.000
1
1
0
0
php,python,sql,unicode
28,096,917
2
false
0
0
just put a N infront of the string, something like INSERT INTO MYTABLE VALUES(N"xxx") and make sure your column type is nvarchar
2
0
0
I want to build an universal database in which I will keep data from multiple countries so I will need to work with the UNICODE charset. I need a little help in order to figure out which is the best way to work with stuff like that and how my queries will be affected ( some sql example queries from php/python for basic stuff like insert/update/select would also be great) Thank you.
How to insert UNICODE characters to SQL db?
0.099668
1
0
1,733
28,096,856
2015-01-22T19:13:00.000
0
1
0
0
php,python,sql,unicode
28,096,868
2
false
0
0
there is nothing special you need to do. with php you can do... query("SET NAMES utf8");
2
0
0
I want to build an universal database in which I will keep data from multiple countries so I will need to work with the UNICODE charset. I need a little help in order to figure out which is the best way to work with stuff like that and how my queries will be affected ( some sql example queries from php/python for basic stuff like insert/update/select would also be great) Thank you.
How to insert UNICODE characters to SQL db?
0
1
0
1,733