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
17,457,921
2013-07-03T20:52:00.000
1
0
1
0
ipython-notebook
17,462,705
1
true
0
0
No, because the kernel does not know it is accessed from a notebook. Dev version have auto-save feature though, and you could write a javascript extension that listen for cell execution event. But Python is not the way to do it. (or display(Javascript('js-code-to-save-notebook')) in the last cell, but I did not tell you)
1
1
0
Is there are a way to save the Ipython notebook as an ipynb file from a cell within that notebook? I know I can save it at any time by manually pressing "CTRL-M S", but I would like to use a command in a cell to do so (python command or %magic). In this way I could "Run all cells" and be sure that the output (e.g. inline figures) is saved into the notebookfile when the execution is finished. Update: Current versions of the Jupyter notebook (the successor of the IPython notebook) autosave into a hidden folder every few minutes (This feature was in development when I asked the question - see accepted answer).
IPython Notebook: Save the currently running notebook as ipynb file using a python command in a cell?
1.2
0
0
1,370
17,458,754
2013-07-03T21:54:00.000
1
0
1
0
python,performance
17,458,825
1
true
0
0
that depends on what you want to do. In general, use the simplest tool that is required to do the task. in would, I imagine, be much more efficient that regular expressions, but doesn't allow wildcards, repeats etc. If the pattern you are looking for is all on one line, you can search on one line at a time, processing each one (and getting it out of memory) before the next line. If you are looking for the start of a string or the end, they use mystring.startswith() or mystring.endswith() - these are more efficient. You might be able to split the data into more manageable chunks. If you want multi-line searches, which wont be at the beginning or end, and include wildcards or repeats... you might be stuck with regexes.
1
0
0
I am going through the algorithms course on MIT OCW. It is mentioned in a lecture that we have to be careful in using re.findall since re can be generally exponential complexity algorithm. Is this a concern when parsing large files or datasets and is there an alternative to regular expressions for efficiently extracting patterns from data?
Efficiency concerns for re.findall on large datasets
1.2
0
0
158
17,459,068
2013-07-03T22:22:00.000
2
0
1
1
python,eclipse,pydev,mylyn
17,459,126
1
false
0
0
The problem seems to be the "PyDev Navigator Content". Ho to solve this make sure the Mylyn focus is disabled for the explorer view in the View Menu -> Customise View on the "Content" tab disable "PyDev Navigator Content" ==> now the python files are shown correctly when the Mylyn context is enabled Note: This works in both: the "PyDev Package Explorer" and in the "Project Explorer" You may add *.pyc to Preferences->Mylyn->Context->Resources -- this will prevent the pyc files to appear in your context when they are compiled automatically...
1
2
0
I use mylyn 3.9.0 with PyDev 2.7.5 with the PyDev Mylyn integration 0.4.0. Mylyn seems to build up contexts correctly (I can see the context tree in the task/context tab). But the python files are not shown "PyDev Package Explorer" nor in the "Project Explorer". What could prevent the python files to appear? Uninstalling the PyDev Mylyn integration did not help.
When I use Mylyn with PyDev I see the context in the task but python files are not shown in any explorer
0.379949
0
0
1,155
17,459,271
2013-07-03T22:45:00.000
0
0
1
0
python
17,459,300
2
false
0
0
combine them all into a single string first, and then do a single FILENAME.write with that one string. On your list of strings, you can try using ','.join(string_list) to combine all the strings into a comma separated single string.
1
1
0
I have a file and a list of strings I extract from the other file the amount of which may change. My question is, how in Python can I write them into the output file so that they're in one line rather than each one in new line? I tried simply using FILENAME.write(str) for each in a loop through the whole list but that seems to force endline after each call.
Writing arbitrary many strings into one file line
0
0
0
43
17,459,680
2013-07-03T23:23:00.000
0
0
0
0
python,django,database-design,frameworks,relational-database
17,460,337
1
false
1
0
One reason is possibly that Django does not (currently) have the ability to modify database tables after creation. You can 'kind-of' do STI using proxy models. This will not allow you to have different fields on the different models, but it will allow you to attach different behaviour (via model methods) to different subclasses. However, if you decide to create a subclass with extra fields, Django will not be able to update the database to reflect that.
1
0
0
What is the rationale behind the decision to not support Single Table Inheritance in Django? Is STI a bad design? Does it result in poor performance? Would it conflict with the Django ORM as it is? Just wondering because it's been a missing feature for like ten years now and so there must have been a conscious decision made that it would never be supported.
Why doesn't Django support Single Table Inheritance?
0
0
0
147
17,461,600
2013-07-04T03:53:00.000
0
0
0
0
python,vtk
25,908,567
2
false
0
1
just use vtktexture, vtkimagedata & add your own image as texture background to the vtkrenderer by reducing the opacity like a watermark. thats it
1
1
0
Simple question, but I've tried a few things and nothing seems to work. I want to overlay some statistics onto a 3d VTK scene, using 2D vtkTextActors. This works fine, but the text is at times difficult to see, depending on what appears behind it in the 3D scene. For this reason, I'd like to add a 2d, semi-transparent "box" behind my text actors to provide a darker background. Which VTK object is appropriate for this? I've tried so far: vtkLegendBoxActor: Not what I want, but I can use this with no text to display a semi-transparent box on screen. I cannot size it directly and I get warnings about not initialising some of the content. vtkImageData: Tried manually creating image data and adding it to the scene; I believe it was placed within the 3d scene and not used as an overlay. If that's not the case then I couldn't get it to show at all. vtkCornerAnnotation: Scales with window size, is fixed to a corner and the background opacity cannot be set AFAIK. vtkTextActor: Cannot set a background color or opacity Can anyone tell me how they might achieve what I'm after in VTK?
Semi-transparent 2d VTK text background
0
0
0
1,042
17,461,720
2013-07-04T04:07:00.000
1
0
1
1
python,ubuntu
17,461,770
1
false
0
0
Just never build anything like this using ./configure && make && make install on systems with package manager. This may (and will) cause unforeseen consequences. In order to uninstall what you have installed without package manager cd to folder with makefile and perform make uninstall. If you want to install other version of python alongside with your existing version, find appropriate package and use update-alternatives to choose default one.
1
0
0
I downloaded and built a new installation of Python on my Ubuntu 12.04 system without realizing that Ubuntu already comes with it installed. Whatever I did messed things up as one of the modules I need is no longer working. Is there a way to revert back to the original install? Thx!
How to revert back to original Ubuntu Python installation?
0.197375
0
0
751
17,463,935
2013-07-04T07:10:00.000
1
0
1
0
python,sockets,multiprocessing
17,464,094
1
true
0
0
You should keep it really simple and have a socket handler thread which: Opens the Socket, Retains ownership of it, Handles it for your main program, i.e. on data arriving passes it to the parent via one of an event, pubsub or a callback, If the connection is lost either reopens it or lets the parent know and end cleanly, On shutdown closes the socket for you. Then everything becomes non-blocking. This is a much cleaner design pattern especially if you use pubsub.
1
1
0
I wish to create a sock.Socket object from a main program using multiprocessing to avoid blocking the main program if the socket is not available during the creation process. The socket gets created but can not be returned to the main program. After some reading it seems that objects can not be shared between python processes. It there a possible design pattern to circumvent this? Is multiprocessing suitable for this application or should I be considering another approach?
How to create a socket object using multiprocessing and pass it back to the parent process
1.2
0
0
174
17,464,274
2013-07-04T07:28:00.000
1
0
0
0
python,networkx
17,471,244
1
true
0
0
That algorithm's run time could get very long for some degree sequences. And it is not guaranteed to produce a graph. Depending on your end use you might consider using the configuration_model(). Though it doesn't sample graphs uniformly at random and might produce parallel edges and self loops it will always finish.
1
0
1
I have an empirical network with 585 nodes and 5,441 edges. This is a scale-free network with max node degree of 179 and min node degree of 1. I am trying to create an equivalent random graph (using random_degree_sequence_graph from networkx), but my python just keeps running. I did similar exercise fro the network with 100 nodes - it took just a second to create a random graph. But with 585 nodes it takes forever. The result of is_valid_degree_sequence command is True. Is it possible that python goes into some infinite loop with my degree sequence or does it actually take a very long time (more than half hour) to create a graph of such size? Please let me know if anyone has had any experience with this. I am using Python 2.7.4. Thanks in advance!
An issue with generating a random graph with given degree sequence: time consuming or some error?
1.2
0
0
532
17,469,330
2013-07-04T11:38:00.000
1
0
0
0
python,xml,postgresql,openerp
17,473,961
1
true
1
0
This is not a generally accepted way of doing customization in openerp. Ususally, you should make a custom module that implements your customization when installed on the OpenERP server installation. Are you using Windows or Linux? The concept here is to move all of the server addons files to the upsite server, including a dump of the database which can be restored on the upsite server. Here's how. First click the Manage databases at the login screen, Do a backup database and save the generated dump file. Install openerp o nthe upsite server (*major versions must match). Copy the server addons folder, and upload to the upsite server's addon directory. Restart openerp service. Then restore the dump file from your backup location. This is basically how you can mirror a "customized" openerp installation across servers. Hope this helps.
1
0
0
I installed OpenERP V 7 on my local machine. I made ​​modification in the CSS. I also remove some menu, change the labels of some windows and change the position of some menus (one after the other in the order decided by the customer). The work required is over and runs well on the premises. Now I'm looking for a way to move my work on the server while keeping the changes. Knowing that I worked directly through the interface of OpenERP. Someone has an idea?
after working in local server, how to move OpenERP on a remote server?
1.2
0
1
2,217
17,470,073
2013-07-04T12:14:00.000
0
0
1
0
python,google-app-engine
20,981,660
1
false
1
0
Like dragonx wrote every handler which was run, every global variable, import is cached on GAE so how long your instance is running so big she is. You can reconfigure your app settings to faster creating new instances and killing old's. That will give you a little chance to minimize that error. That error doesn't have to be populated because of memory leaks. Many things affect to that so you should check your code, try to reconfigure your instance settings and maybe you should change your instance type to higher.
1
4
0
Why does this happen? I run a task which uses a lot of memory - after the task has finished I would expect the memory to be released back to the instance. However, this doesn't happen. The memory just keeps going up and up on subsequent execution of the task until eventually I get a soft memory warning. What can I do about this? It just doesn't make sense. I have tried explicitly calling gc.collect() but this doesn't help.
GAE does not release memory after handling request?
0
0
0
135
17,471,949
2013-07-04T13:45:00.000
0
0
1
0
python,python-2.7,windows-7-x64
17,472,059
1
false
0
0
When the terminal is closed, your program will get a SIGHUP, which kill it by default. add a signal handler to handle the SIGHUP do whatever you want. and if you program write to the console after it has been close, you may also get SIGPIPE, handle it properly
1
1
0
I have to write data in memory to in a file to close my console application. How can i detect console closing event ?
How to catch when user close a console application via “X” button
0
0
0
722
17,475,035
2013-07-04T16:40:00.000
2
0
1
0
python,compilation
17,475,082
2
false
0
0
The difference between .pyo and .pyc is that .pyo is optimised and that means that you will not be able to use certain features like docstrings. .pyc is the whole deal, with no limitations.
2
7
0
I see that .pyc and .pyo file are both compiled python code. What is difference between them and when I should use one or another?
What is the difference between pyc and pyo files in Python?
0.197375
0
0
10,438
17,475,035
2013-07-04T16:40:00.000
11
0
1
0
python,compilation
17,475,272
2
false
0
0
.pyc files are python files compiled to byte code by the interpreter. They are generated normally when a file is imported. .pyo are compiled byte code without line numbers, assertions, and some other things (possibly doc strings) for optimzation purposes. when invoking the python interpreter, you may pass the -O or -OO option to generate a .pyo file. Using -O will throw out the line numbers, assertions, and some debugging info. -OO will result in a .pyo file also stripped of docstrings.
2
7
0
I see that .pyc and .pyo file are both compiled python code. What is difference between them and when I should use one or another?
What is the difference between pyc and pyo files in Python?
1
0
0
10,438
17,475,324
2013-07-04T17:03:00.000
1
0
0
0
python,django
17,475,364
5
false
1
0
Yes, just change the next parameter. In your return response, make sure that the dictionary that you pass in is has something like this : { 'next': '/<your_path_here>}/' }, make sure you commit the changes before adding the next parameter. You might want to change your view's get and post functions.
1
30
0
I am using Django DeleteView in a template and I've created a url & view. Is it possible to skip the process of loading the _confirm_delete template and just post the delete immediately.
Django DeleteView without confirmation template
0.039979
0
0
21,411
17,477,024
2013-07-04T19:24:00.000
1
0
1
0
python,linux
17,477,344
2
false
0
0
Just redirect stderr. python script.py 2> /var/log/python.log
1
1
0
Is it possible to dump all errors reported by the Python Interpreter into a log stored as say /var/log/python.log regardless of what script/command caused them? What would be the best way to do this if it's possible?
Dump All Python Interpreter Errors into a Log?
0.099668
0
0
669
17,478,055
2013-07-04T21:01:00.000
2
0
0
0
python,sublimetext2,sublimetext3
17,497,504
2
false
0
0
Depending on what your plugin does, it's very possible to write it in such a way that it is compatible with both ST2 and ST3. If most of the code is compatible, but there are portions that are not, you can use the version number (sublime.version()) to determine what version of ST is being used. I believe everything >= 3006 is ST3. If you do need to maintain separate branches, just direct users to the ST3 branch if they are using ST3. Package control, when it is updated, should support this, but I don't know how far wbond is on that.
2
0
0
I made a plugin for sublime text 2, and now sublime text 3 is out, I ported the plugin to work with sublime text 3. However, I left the sublime text 2 version up as the main version in the package control. Could I update my package in a way that it works on both sublime text 2 and sublime text 3?
Backwards compatible python plugin
0.197375
0
0
81
17,478,055
2013-07-04T21:01:00.000
0
0
0
0
python,sublimetext2,sublimetext3
17,714,260
2
false
0
0
As a followup, wbond has said recently that Package Control 2.0 should be coming out "soon" though I don't know how long that will be. On the list of things that is being changed is a new json format that will allow specifying if it works in ST2 and/or ST3.
2
0
0
I made a plugin for sublime text 2, and now sublime text 3 is out, I ported the plugin to work with sublime text 3. However, I left the sublime text 2 version up as the main version in the package control. Could I update my package in a way that it works on both sublime text 2 and sublime text 3?
Backwards compatible python plugin
0
0
0
81
17,479,480
2013-07-05T00:10:00.000
1
1
1
0
python,design-patterns,mocking
17,479,627
1
false
0
0
You discovered a new use case for DownloadController - "Let the user customize the callback". It sounds like you have control over the Downloadcontroller source. It could define a DownloadCallback class that exposes the events as methods but does nothing with them. The Controller would accept None (do nothing) or anything that implements the DownloadController interface. I think using mock for real code is more than a bit odd... it creates yet another dependency that needs to be met for users of your module.
1
1
0
The other day I was coding when suddenly I discovered myself struggling with a simple problem but confuse solution (at least in a pythonic way to go). The code was supposed to just download some files, for that, it would call some DownloadController passing it a callback so to received events such as init, progress, error and success. However, my code didn't need at all these events. With this came to my mind some solutions Change DownloadController to have a default callback=None and check for it so to ignore sending events in this case Have NullCallbackImpl which adheres to callback interface but do nothing (just pass on each event) First approach didn't like it because the code would be kind of messy and not well-design. So, I stick with the second approach... Questions: How good (maybe 'how bad') would it be to have a null_callback = mock.Mock()? (using python mock library from Michael Foord) Is there any library that do this? Or should I stick with creating a NullCallbackImpl implementing each method with a simple pass?
Which is the recommended way to use the Null Pattern in Python?
0.197375
0
0
67
17,483,132
2013-07-05T07:14:00.000
1
0
1
0
python
17,483,632
4
false
0
0
Usually it's not important to tune every line of code for utmost performance. As a rule of thumb, if you need to look up more than a few times, creating a set is usually worthwhile. However consider that pypy might do the linear search 100 times faster than CPython, then a "few" times might be "dozens". In other words, sometimes the constant part of the complexity matters. It's probably safest to go ahead and use a set there. You're less likely to find that a bottleneck as the system scales than the other way around. If you really need to microtune everything, keep in mind that the implementation, cpu cache, etc... can affect it, so you may need to remicrotune differently for different platforms, and if you need performance that badly, Python was probably a bad choice - although maybe you can pull the hotspots out into C. :)
3
1
0
If I instantiate/update a few lists very, very few times, in most cases only once, but I check for the existence of an object in that list a bunch of times, is it worth it to convert the lists into dictionaries and then check by key existence? Or in other words is it worth it for me to convert lists into dictionaries to achieve possible faster object existence checks?
Converting lists to dictionaries to check existence?
0.049958
0
0
70
17,483,132
2013-07-05T07:14:00.000
4
0
1
0
python
17,483,248
4
true
0
0
Dictionary lookups are faster the list searches. Also a set would be an option. That said: If "a bunch of times" means "it would be a 50% performance increase" then go for it. If it doesn't but makes the code better to read then go for it. If you would have fun doing it and it does no harm then go for it. Otherwise it's most likely not worth it.
3
1
0
If I instantiate/update a few lists very, very few times, in most cases only once, but I check for the existence of an object in that list a bunch of times, is it worth it to convert the lists into dictionaries and then check by key existence? Or in other words is it worth it for me to convert lists into dictionaries to achieve possible faster object existence checks?
Converting lists to dictionaries to check existence?
1.2
0
0
70
17,483,132
2013-07-05T07:14:00.000
0
0
1
0
python
17,483,477
4
false
0
0
random access (look up) in dictionary are faster but creating hash table consumes more memory. more performance = more memory usages it depends on how many items in your list.
3
1
0
If I instantiate/update a few lists very, very few times, in most cases only once, but I check for the existence of an object in that list a bunch of times, is it worth it to convert the lists into dictionaries and then check by key existence? Or in other words is it worth it for me to convert lists into dictionaries to achieve possible faster object existence checks?
Converting lists to dictionaries to check existence?
0
0
0
70
17,484,086
2013-07-05T08:09:00.000
0
0
0
1
linux,python-2.7,wifi,wpa
17,960,144
1
true
0
0
Well, a not-so-straightforward (yet the only possible) way to go about fulfilling your needs would be initiating a four-way handshake with the AP. Since you're coding in Python, Scapy would be your best option for crafting EAPOL message packets. You'll have to know the structure of the EAPOL packets though, and fully implement it in your code. You'll also have to recode, in Python, the functions for key generation, most (if not all) of which are PRFs **(Pseudo Random Functions); alternatively, you could import ready-compiled .DLL's to do the encoding for you. However, it would be enough to manage only the first 3 messages from the four-way handshake: If, after several connection attempts, the AP doesn't send the 3rd key message, then the MIC (Message Integrity Check) from the STA didn't match the one generated by the AP, and the password is thus invalid. Otherwise, it is. Note: wpa_supplicant follows the same procedure for authentication and connection, however it continues on for obtaining extra information like IP address and what not... That's why I said it's the only possible way.
1
1
0
I'm trying to validate the user's input of SSID and WPA Passphrase for a WPA connection. My program is a Python program running on an embedded Linux platform. I can validate an Access Point with SSID exists by parsing the output of a iwlist scan subprocess. Validating the Passphrase, however, is less straight forward. So far, the only solution I've come up with is to parse the output of wpa_supplicant -Dwext -iwlan0 -c/tmp/wpa_supplicant.conf looking for "pre-shared key may be incorrect" or the kernel message "OnDeAuth Reason code(15)" (which means WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT according to the wpa_supplicant source). Interpreting a handshake timeout as an invalid Passphrase seems plain wrong. Besides that, that approach requires waiting for some output from a subprocess and assumes the absence of error messages means the Passphrase is valid. Googling around this just returns me a lot of questions and advice on how to hack a WPA connection! There's no wpa_cli or iwevent in the yum repository for my target platform and I'm unsure how to go about getting a third-party python package running on my target. Question: What's the simplest way of validating the Wifi WPA Passphrase?
How to programatically validate WPA passphrase on Linux?
1.2
0
0
1,144
17,485,920
2013-07-05T09:49:00.000
2
1
1
0
python,file,python-3.x
17,486,121
3
false
0
0
First of all, the Python 2 str type has been renamed to bytes in Python 3, and byte literals use the b'' prefix. The Python 2 unicode type is the new Python 3 str type. To get the Python 3 file behaviour in Python 2, you'd use io.open() or codecs.open(); Python 3 decodes text files to Unicode by default. What you see is that for binary files, Python 3 gives you the exact same thing as in Python 2, namely byte strings. What changed then, is that the repr() of a byte string is prefixed with b and the print() function will use the repr() representation of any object passed to it except for unicode values. To print your binary data as unicode text with the print() function., decode it to unicode first. But then you could perhaps have opened the file as a text file instead anyway. The bytes type has some other improvements to reflect that you are dealing with binary data, not text. Indexing individual bytes or iterating over a bytes value gives you int values (between 0 and 255) and not characters, for example.
2
1
0
In Python 3, when I opened a text file with mode string 'rb', and then did f.read(), I was taken aback to find the file contents enclosed in single quotes after the character 'b'. In Python 2 I just get the file contents. I'm sure this is well known, but I can't find anything about it in the doco. Could someone point me to it?
Python 3 file input change in binary mode
0.132549
0
0
2,045
17,485,920
2013-07-05T09:49:00.000
0
1
1
0
python,file,python-3.x
17,494,245
3
false
0
0
Sometimes we need (needed?) to know whether a text file had single-character newlines (0A) or double character newlines (0D0A). We used to avoid confusion by opening the text file in binary mode, recognising 0D and 0A, and treating other bytes as regular text characters. One could port such code by finding all binary﷓mode reads and replacing them with a new function oldread() that stripped off the added material, but it’s a bit painful. I suppose the Python theologians thought of keeping ‘rb’ as it was, and adding a new ‘rx’ or something for the new behaviour. It seems a bit high-handed just to abolish something. But, there it is, the question is certainly answered by a search for ‘rb’ in Lennert’s document.
2
1
0
In Python 3, when I opened a text file with mode string 'rb', and then did f.read(), I was taken aback to find the file contents enclosed in single quotes after the character 'b'. In Python 2 I just get the file contents. I'm sure this is well known, but I can't find anything about it in the doco. Could someone point me to it?
Python 3 file input change in binary mode
0
0
0
2,045
17,486,322
2013-07-05T10:10:00.000
0
0
0
1
python,scipy,reinstall
17,488,424
1
true
0
0
How about sudo port uninstall python27?
1
0
1
I accidentally installed python 2.7 again on my mac (mountain lion), when trying to install scipy using macports: sudo port install py27-scipy ---> Computing dependencies for py27-scipy ---> Dependencies to be installed: SuiteSparse gcc47 cctools cctools-headers llvm-3.3 libffi llvm_select cloog gmp isl gcc_select ld64 libiconv libmpc mpfr libstdcxx ppl glpk zlib py27-nose nosetests_select py27-setuptools python27 bzip2 db46 db_select gettext expat ncurses libedit openssl python_select sqlite3 py27-numpy fftw-3 swig-python swig pcre I am still using my original install of python (and matplotlib and numpy etc), without scipy. How do I remove this new version? It is taking up ~2Gb space.
Installing python (same version) on accident twice
1.2
0
0
609
17,486,578
2013-07-05T10:23:00.000
1
0
1
0
python,setup.py,pypi
17,486,777
7
false
0
0
Yes, one zip-file/egg can provide multiple modules, so you can combine them into one file. I'm however highly skeptical to that being a good idea. You still need to install that zip-file, and it may still clash with other already installed versions, etc. So the first question to ask is what the aim is. Why do you want just one file? Is it for ease of install, or ease of distribution, or what? Having just one file will not really make the install easier, there are other, better ways. You can let the install download and install the dependencies automatically, that's easy to do. And having them in one zip-file still means you need to expand that zip-file and run setup.py, which isn't very userfriendly. So having just one file doesn't really solve many problems, so the question is which problem you are trying to solve.
1
44
0
It would be convenient when distributing applications to combine all of the eggs into a single zip file so that all you need to distribute is a single zip file and an executable (some custom binary that simply starts, loads the zip file's main function and kicks python off or similar). I've seen some talk of doing this online, but no examples of how to actually do it. I'm aware that you can (if it is zip safe) convert eggs into zip files. What I'm not sure about is: Can you somehow combine all your eggs into a single zip file? If so, how? How would you load and run code from a specific egg? How would you ensure that the code in that egg could access all the dependencies (ie. other eggs in the zip file)? People ask this sort of stuff a lot and get answers like; use py2exe. Yes, I get it, that's one solution. It's not the question I'm asking here though...
How can you bundle all your python code into a single zip file?
0.028564
0
0
43,916
17,487,208
2013-07-05T10:54:00.000
1
0
1
0
python,queue
17,487,423
2
false
0
0
Sure. Create a multiprocessing.Pool which will by default spawn one process per core. Then use the original process to run an HTTP service or something else that accepts jobs via some protocol. The main process then listens for new requests and submits them to the pool for async processing.
1
1
0
I need to create a python server that can accept multiple job requests. Then from those it requests, it processes each Job one at a time but the server can still accept new Jobs while processing a task. Does anyone have an suggestions on how to do this? Thanks
Python Server, Job Queue, Launch Multiprocessing Job
0.099668
0
0
455
17,487,923
2013-07-05T11:33:00.000
1
0
0
1
python,ipc,celery
17,991,236
2
true
0
0
I've found the solution. It's also a variation on Solution 2, use Thrift for RPC with the actual job code. The code is written in the target language and a Thrift IDL describes it to the Thrift compiler which can generate both client and server. The client is obviously Python code and the server is in the target language. Any similar alternative to Thrift will do, like other RPC code generators. Thanks for all the answers, I hope this ends up helping someone someday.
1
3
0
I'm trying to call compiled/interpreted code from a Celery task. The code is written in something other than Python. I want to know if there is a better solution to the problem than the ones I'm thinking of. Solution 1. Start another process and execute/interpret the piece of code I'm interested in. This has the overhead of creating and killing a process. For a very small task, that overhead may be too high. Solution 2. Use a Listener process that can execute code from a target language. It could listen on a local socket for function signatures (aka add(2,2), execute and return the result on the same socket. The listener could also implement something like a process/thread pool to handle multiple tasks efficiently. Solution 3 (thanks to AndrewS). Building a worker process (connected to the broker). It implies rewriting the Celery worker into the target language. This is the most expensive version of the three in terms of development effort.
Celery task executing code from another programming language
1.2
0
0
1,334
17,489,178
2013-07-05T12:41:00.000
2
0
1
0
python,emacs
33,941,090
2
false
0
0
Things got a little simpler since Emacs 24.4. There's now a M-x superword-mode that has the desired effect.
1
6
0
In python mode, when I forward-word. The cursor jumps from H to d (Hello_World). But in another mode(shell-mode or c-mode), the cursor jumps from H to _. I want the result which i get in Python mode, even in the other mode. What should I do? PS: I saw a similar question before, I have searched, but I could't find it.
Hello_World is a word in Python, it is different in an other mode. How I change it?
0.197375
0
0
201
17,491,720
2013-07-05T14:54:00.000
0
0
0
0
python,mysql,django,phpmyadmin
17,491,830
1
false
1
0
You can use the to_field attribute of a ForeignKey. Django should detect this automatically if you use ./manage.py inspectdb, though.
1
0
0
I have an existing MySQL database that I set up on PMA, it has FKs that references columns that are not primary keys. Now I am trying to move the database to Django and am having trouble because when I try to set up d Foreign Keys in django it automatically references the Primary Key of the table that I am attempting to reference so the data doesnt match because column A and column B do not contain the same info. Is there a way to tell django what column to reference?
Moving database from PMA to Django
0
1
0
62
17,495,581
2013-07-05T19:20:00.000
0
0
0
0
python,sql-server,csv,pymssql
17,495,797
1
false
0
0
Do you need to do this programmatically or is this a one-off export? If the latter, the easiest way by far is to use the SSMS export wizard. In SSMS, select the database, right-click and select Tasks->Export Data.
1
0
0
What is the easiest way to export the results of a SQL Server query to a CSV file? I have read that the pymssql module is the preferred way, and I'm guessing I'll need csv as well.
Export SQL Server Query Results to CSV using pymssql
0
1
0
1,521
17,495,732
2013-07-05T19:31:00.000
1
0
1
0
python,autocomplete,pycharm,panda3d
19,691,166
1
false
0
0
For me it worked just selecting in Settings > Project Interpreter the panda python interpreter (python.exe, not ppython.exe.). If you wanna use ppython.exe you have to rename to something starting with "python" like pythonpanda.exe, since Pycharm only considers an interpreter something that starts with "python". Anyway, ppython and python are supposed to be the same. EDIT Another thing that can make it work, is using another python interpreter (the standard, virtualenv, whatever) and placing a path file in a folder within the PYTHONPATH. In other words: Create a text file named panda3d.pth Write two lines path\to\pandafolder path\to\pandafolder\bin Save it in the site-packages of your python interpreter Configure Pycharm to use this interpreter
1
2
0
Has anybody got auto-completion for the Panda3d library working with PyCharn? It seems PyCharm cannot automatically create the Python skeletons for this library, so I would also be happy if I could at least manually define those stubs in PyCharm. But I found no solution to this yet. Any ideas how to tell PyCharm what Python modules and classes are there in a "binary" library?
Auto-Completion for Panda3d in PyCharm
0.197375
0
0
1,566
17,499,343
2013-07-06T03:17:00.000
4
1
1
0
python
17,499,406
1
true
0
0
There is a single item in PEP8 that clearly has potential performance consequences: Code should be written in a way that does not disadvantage other implementations of Python (PyPy, Jython, IronPython, Cython, Psyco, and such). That is, PEP8 recommends that code be written such that it performs well across a variety of Python implementations. This is a bit hand-wavy, of course (do you have to try all the available implementations?). Other than that, nothing in PEP8 stands out as likely to impact performance or anything measurable apart from the storage space required for the code itself (e.g. four-space indentation).
1
2
0
is PEP8 simply a style guide, or does it actually help the interpreter make optimizations to run your code faster? I'm simply curious since I really like PEP8 and wanted to know of any other benefits other than more readable code.
Does following the PEP8 guidelines make your code run faster than if you did not follow it?
1.2
0
0
247
17,499,757
2013-07-06T04:49:00.000
1
0
0
1
python,linux,bash,vim
17,502,075
2
false
0
0
You should be using Vim's Python API, not an external Python script. see :h python. You can access all that info directly through its functions. You can evaluate a vim command with vim.command() to interface with the clipboard. There are other ways to get at the clipboard using e.g. PyGTK, or perhaps more directly through python-xlib, but would probably be more difficult.
1
1
0
I have configured a keyboard shortcut using xbindkeys to run a python script. Now, while editing any vim file if that user press that keyboard shortcut- I want my python script to run this command to paste the path and line no to the system clipboard- :let @+=expand("%") . ':' . line(".") Then I want my script to copy that path from the system clipboard and process it further Can you please suggest me a good solution for this. Thanks In advance
Run a vim command from a python script
0.099668
0
0
876
17,506,195
2013-07-06T19:12:00.000
2
0
1
0
python,naming-conventions,set,discrete-mathematics
17,506,255
1
true
0
0
For what it is worth, I also follow the idioms of the programming language in question. So I would use the Python naming conventions even for mathematical concepts. It is far more likely that someone reading Python code will expect and recognize the standard naming conventions. From the point of view of a discrete mathematician, you see set as a very important data type worthy of distinguishing. As a Python programmer, they are just another tool in the toolbox to me - meant to be used whenever I need an unordered collection of unique instances.
1
2
0
I'm very acquainted to Discrete Mathematics concepts in which, as you may know, sets must be specified with a single uppercase letter in range (A-Z). I was wondering if this rule or convention should be taken into account when declaring sets in Python or when coding. I have a point of view where it totally adds up but I also have a point of view where it doesn't. People are used to implement the same data structures over and over. Most programmers would think an array or lists, dictionaries and sets are the same thing. They are sets in a way but they're obviously different on what you can achieve with each of them and as a result you have different catalogs of built-in functions to deal with. That's why I'd like sets to stand out in coding and stick to the mathematical convention, at least in Python. I think if I bump into someone else's code and I find these sort of declarations, it would make sense to me and it'd say something positive about the coder. I'd like to stick to the mathematical concept even when programming but just wanted to know what your thoughts or opinions might be on this matter. When Math meets Code, which conventions survive? Thank you in advance.
How best to name sets in Python?
1.2
0
0
475
17,507,004
2013-07-06T20:49:00.000
3
1
0
0
c++,python,game-engine,language-interoperability
17,507,117
2
true
0
1
In the specific case of python, you have basically three options (and this generally applies across the board): Host python in C++: From the perspective of the C++ programme, the python interpreter is a C library. On the python side, you may or may not need to use something like ctypes to expose the C(++) api. Python uses C++ code as DLLs/SOs - C++ code likely knows nothing of python, python definitely has to use a foreign function interface. Interprocess communication - basically, two separate processes run, and they talk over a socket. These days you'd likely use some kind of web services architecture to accomplish this.
1
8
0
I know that many large-scale applications such as video games are created using multiple langages. For example, it's likely the game/physics engines are written in C++ while gameplay tasks, GUI are written in something like Python or Lua. I understand why this division of roles is done; use lower-level languages for tasks that require extreme optimization, tweaking, efficiency and speed, while using higher-level languages to speed up production time, reduce nasty bugs ect. Recently, I've decided to undertake a larger personal project and would like to divy-up parts of the project similar to above. At this point in time, I'm really confused about how this interoperability between languages (especially compiled vs interpreted) works. I'm quite familiar with the details of going from ANSCII code test to loading an executable, when written in something like C/C++. I'm very curious at how something like a video game, built from many different languages, works. This is a large/broad question, but specifically I'm interested in: How does the code-level logic work? I.e. how can I call Python code from a C++ program? Especially since they don't support the same built-in types? What does the program image look like? From what I can tell, a video game is running in a single process, so what does the runtime image look like when running a C/C++ program that calls a Python function? If calling code from an interpreted language from a compiled program, what are the sequence of events that occur? I.e If I'm inside my compiled executable, and for some reason have a call to an interpreted language inside a loop, do I have to wait for the interpreter every iteration? I'm actually finding a hard time finding information on what happening at the machine-level, so any help would be appreciated. Although I'm curious in general about interoperation of software, I'm specifically interested in C++ and Python interaction. Thank you very much for any insight, even if it's just pointing me to where I can find more information.
How interoperability works
1.2
0
0
1,114
17,507,005
2013-07-06T20:49:00.000
2
0
1
1
python,macos,python-idle
17,507,189
2
true
0
0
You can use a shell script to do what you need on osx. Instructions to open a python interpreter in terminal: First create a file called python.command Open the file in any text editor and copy and paste the following #!/bin/bash python If you want to open the IDLE Standalone App do the following (repeat step 1,2 but paste the following) but make sure your path is correct: #!/bin/bash open -a /Applications/Python\ 2.7/IDLE.app
2
0
0
I want to create a shortcut for IDLE on my mac so that I don't need to go through the terminal. Is there a way to do this? I was trying Automator but I'm not that familiar with it. Thanks.
Shortcut to python IDLE on mac os
1.2
0
0
3,751
17,507,005
2013-07-06T20:49:00.000
-1
0
1
1
python,macos,python-idle
17,507,212
2
false
0
0
You can use spotlight to open IDLE: Press CMD (Apple) + SPACE, type "idle" and hit ENTER... my preferred way to open any programs on the mac
2
0
0
I want to create a shortcut for IDLE on my mac so that I don't need to go through the terminal. Is there a way to do this? I was trying Automator but I'm not that familiar with it. Thanks.
Shortcut to python IDLE on mac os
-0.099668
0
0
3,751
17,507,395
2013-07-06T21:39:00.000
0
0
0
0
python,amazon-web-services,amazon-sqs
17,906,399
1
false
1
0
It depends on your identity requirements. If it's ok for your clients to have AWS accounts, you can give their accounts permission to send messages to your queue. If you want your own identity, then yes, you would need to build a service layer infront of AWS to broker API requests
1
0
0
Sorry about the awkward title. I am building a Python API. Part of it involves sending and receiving data to an Amazon SQS to communicate with some stuff on an EC2 instance. I don't want to distribute the API with my amazon keys in it though. What is the correct way around an issue like this? Do I have to write a separate layer that sits in front of SQS with my own authentication or is there a way to add permissions to amazon keys such that uses could just send and receive messages to SQS but couldn't create additional queues or access any other web services?
What is the correct way to expose an AWS in an API without giving out your keys?
0
0
1
106
17,507,723
2013-07-06T22:39:00.000
2
0
1
0
python,mysql,multithreading,python-2.7,multiprocessing
17,507,806
1
true
0
0
You can use a variable like a counter that is a process or thread counter. So you can check this counter and you can use lock when counter bigger than 1.
1
1
0
I am writing the back end of an Online Judge ( code checker) in python 2.7 which takes submissions from database(using mysql) evaluates the submission and writes the result back to database.I am running multi processes and each process runs multiple threads.For time being I am printing the evaluations status and other stuff directly to STDOUT. I haven't even put lock on printing(which is cumbersome because there are many print statements).Although I know lock is necessary in this condition.But initially my evaluator had only one process which had only one thread.I did not put lock that time and was redirecting STDOUT and STDERR to file from command line.But now the case is different.Also such log would difficult to be read and finding the error and other things if my evaluator crashes.Is there some neat way of logging in this case ??
Logging in multi-processing and multi-threading python program?
1.2
0
0
225
17,509,446
2013-07-07T05:03:00.000
0
0
0
0
python,django,amazon-web-services,amazon-elastic-beanstalk
17,511,404
1
false
1
0
Apache's AllowOverride is set to None by default. You have to do some .ebextensions touches to change the default AllowOverride on your DocumentRoot folder. You can verify this by connecting to your instance through ssh and check the httpd config.
1
3
0
I'm trying to remove the www from the url, and normally I do this by using a .htaccess file with a rewrite rule. I don't know where to put this file in my elastic beanstalk folder structure, or where to have it created. I've tried placing my .htaccess in 1. /var/www/html 2. django application folder 3. the same folder as the wsgi 4. the django templates folder 5. in the root of my project folder. None of these have made any difference. I would be interested either where to place the .htaccess file, or another way to remove the www that might be django specific.
where to place .htaccess on elastic beanstalk python
0
0
0
731
17,509,478
2013-07-07T05:10:00.000
1
0
0
0
python,qt,pyqt
17,510,954
1
true
0
1
Use QGraphicsScene and QGraphicsView to display your scene. Use scene->addPixmap to add the image. Use QRubberBand to select the region as you said. Use view->mapToScene to convert viewport coordinates obtained from QRubberBand to the scene coordinates. Add lines using scene->addLine Add small circle items to lines intersection points using scene->addEllipse. This function returns QGraphicsEllipseItem* object. You should use circles with (0, 0) center. Use item->setPos to move each circle in the proper place. Use item->setFlag(QGraphicsItem::ItemIsSelectable) to make circle items selectable. You can now select items with mouse clicks. Use view->dragMode(QGraphicsView::RubberBandDrag) if you want to enable items selection using automatic QRubberBand. Use QGraphicsScene::selectedItems to obtain selected items. You can then use item->pos() to obtain items positions.
1
0
0
I've to output few points in an interactively selected region of an image. I'm not familiar with PyQt to select the appropriate elements for the task. Please suggest the right way to do it. Currently, this is what I intend to do : Load the image. Use QImage (QPixMap?) to display the image. Select a rectangular region in the image. Use QRubberBand to select the region. Draw a grid in the region. Use QLines? Make the grid points (interesctions) selectable. No idea. Any pointers to snippets using the required classes will be greatly helpful. Thanks !
How to select an area and fill it with a grid in PyQt?
1.2
0
0
934
17,511,310
2013-07-07T10:26:00.000
1
1
1
0
python,python-3.x,pyobject
17,511,486
1
false
0
0
Do you really want a (1) PyObject, as in what Python calls object, or (2) an object of some subtype? That you "need an object with functions attached" seems to indicate you want either methods or attributes. That needs (2) in any case. I'm no expert on the C API, but generally you'd define your own PyTypeObject, then create an instance of that via PyObject_New (refcount and type field are initialized, other fields you might add are not).
1
1
0
I wonder how I can create a PyObject in C++ and then return it to Python. Sadly the documentation is not very explicit about it. There is no PyObject_Create so I wonder whether allocating sizeof(PyObject) via PyObject_Malloc and initializing the struct is sufficient. For now I only need an object with functions attached.
Create a PyObject with attached functions and return to Python
0.197375
0
0
360
17,512,930
2013-07-07T14:18:00.000
10
0
1
0
python,pycharm
35,367,842
5
false
0
0
On Pycharm 5.0.4... Open the file (i.e. by double clicking in explorer) Navigate to File->Settings... Expand the Project tab on the left and select 'project interpreter' from the options that appear beneath Set your project interpreter from the dropdown menu, and you should be able now to run your file without creating a project
2
41
0
Relatively new to Python and PyCharm and as such most of the work. I'm doing is single files and therefore is not organized into projects. Is there a way to configure Pycharm to be used to open single files and not use projects? Similarly, is it possible to just run a single page/file?
How to work within individual files rather than projects in PyCharm
1
0
0
19,729
17,512,930
2013-07-07T14:18:00.000
0
0
1
0
python,pycharm
27,328,585
5
false
0
0
You can also create a .py file and implement it within a PyCharm project by dragging it into the editor. This method also allows you to use a separate text editor to create your .py file.
2
41
0
Relatively new to Python and PyCharm and as such most of the work. I'm doing is single files and therefore is not organized into projects. Is there a way to configure Pycharm to be used to open single files and not use projects? Similarly, is it possible to just run a single page/file?
How to work within individual files rather than projects in PyCharm
0
0
0
19,729
17,513,036
2013-07-07T14:31:00.000
1
0
1
0
python,memory,file-io,pickle
45,125,257
10
false
0
0
This may seem trivial, but try to use the 64bit Python if you are not.
2
34
0
I have a program where I basically adjust the probability of certain things happening based on what is already known. My file of data is already saved as a pickle Dictionary object at Dictionary.txt. The problem is that everytime that I run the program it pulls in the Dictionary.txt, turns it into a dictionary object, makes it's edits and overwrites Dictionary.txt. This is pretty memory intensive as the Dictionary.txt is 123 MB. When I dump I am getting the MemoryError, everything seems fine when I pull it in.. Is there a better (more efficient) way of doing the edits? (Perhaps w/o having to overwrite the entire file everytime) Is there a way that I can invoke garbage collection (through gc module)? (I already have it auto-enabled via gc.enable()) I know that besides readlines() you can read line-by-line. Is there a way to edit the dictionary incrementally line-by-line when I already have a fully completed Dictionary object File in the program. Any other solutions? Thank you for your time.
Pickle dump huge file without memory error
0.019997
0
0
56,800
17,513,036
2013-07-07T14:31:00.000
4
0
1
0
python,memory,file-io,pickle
30,084,777
10
false
0
0
I had memory error and resolved it by using protocol=2: cPickle.dump(obj, file, protocol=2)
2
34
0
I have a program where I basically adjust the probability of certain things happening based on what is already known. My file of data is already saved as a pickle Dictionary object at Dictionary.txt. The problem is that everytime that I run the program it pulls in the Dictionary.txt, turns it into a dictionary object, makes it's edits and overwrites Dictionary.txt. This is pretty memory intensive as the Dictionary.txt is 123 MB. When I dump I am getting the MemoryError, everything seems fine when I pull it in.. Is there a better (more efficient) way of doing the edits? (Perhaps w/o having to overwrite the entire file everytime) Is there a way that I can invoke garbage collection (through gc module)? (I already have it auto-enabled via gc.enable()) I know that besides readlines() you can read line-by-line. Is there a way to edit the dictionary incrementally line-by-line when I already have a fully completed Dictionary object File in the program. Any other solutions? Thank you for your time.
Pickle dump huge file without memory error
0.07983
0
0
56,800
17,514,348
2013-07-07T17:15:00.000
0
0
0
0
python,django,security,django-models
17,514,616
2
false
1
0
django.contrib.auth uses the username field to identify a user, not the email address, so there is no conflict if two users have the same email address. Also, since the email address is not required, it is therefore blank or null in the database (neither of which make for good unique keys). And for your other question - the password reset will reset the password of the user who requested it, because it is requested by user name. Having two accounts with the same address can be quite handy. For example, perhaps one is an admin account and the other is a normal user.
1
6
0
I am using Django's default User model and the email is not unique, now I have multiple users with the same email address. You can have User_A with email address [email protected], and then a new user User_B can register with the same email address [email protected]. This doesn't make sense in any programming universe, and it will cause confusion with email-sending functionality, and possible wrong password resets (if a password reset link is sent, with two users sharing the same email address). This doesn't hold an obvious security vulnerability as I see it because only the original user has control of the original email address, so the attacker will not receive the reset emails. However, this could result in the original user User_A being locked out of his original account (if he forgets his password) and being prevented of issuing a password reset because Django attempts to reset the new user User_B only. Obviously User_A wants access to his account, not to User_B's account. What is the justification? Obviously the password reset functionality is linked with the email, so if I reset the password based on the email, which user (upon following the password reset link) will be reset? How can I make the email field unique?
Why does Django's User Model set the email field as non-unique?
0
0
0
2,484
17,515,574
2013-07-07T19:36:00.000
0
0
0
1
python,google-app-engine,error-handling
17,520,267
1
true
1
0
When I was taking some screenshots as tony asked in the comments, I found the solution. These errors are all HEAD requests. Since my app doesn't support them, they generate a 405 HTTP response code which is shown on the dashboard as error but then in the logs they don't get the error icon. They just seem to be fine at first sight.
1
0
0
I have the following problem: I can see some mysterious errors on the Appengine Dashboard but when I go to the logs I can't find any relevant entries. Otherwise the URIs are working fine when I request them. If I click on the links on the dashboard which take me to the logs with a prefilled regexp filter, the logs are empty. I only have one guess: When a request takes longer to load and the user closes the browser window/tab, before the page has been loaded, theese kind of errors are generated but not logged. But I can't prove this assumption. This guess is based on what I see sometimes when developing locally with the SDK. I use the python SDK. I only have one live version of the app. Do you maybe have any clues what happens here? Thanks.
Appengine errors not appearing in logs
1.2
0
0
63
17,517,718
2013-07-08T00:27:00.000
1
0
1
0
python
17,518,071
2
false
0
0
unicodes don't have a charset; they are pure text. Only convert to a bytestring when storing or transmitting in a medium where only bytes are accepted.
1
0
0
I am working on a project which aims to fetch some data from some websites and then stores into database. But these websites contains different charsets such as utf-8, gbk. The fetched data is unicode so i wonder when to convert to string is the right way. I convert to string immediately for now, but it seems that the python suggests to keep unicode as long as possible, i can't figure out why? Because we always don't know the charset of the unicode object.
When to convert unicode to string?
0.099668
0
0
152
17,517,961
2013-07-08T01:16:00.000
0
0
0
0
python,tkinter
17,518,474
1
false
0
1
No, you do not have to destroy the screen and redraw it. You can easily insert widgets into the current window when a button is clicked. There's nothing special about being run from a button click -- the code is the same as your initialization code.
1
0
0
I am aiming to change the a part of the Tkinter screen when a button is clicked. Do I have to destroy the screen then redraw it (to create the illusion that only a part is being changed?) Or can I keep the button there and somehow only change one part (like the graphics.) Thanks!
Changing Tkinter Screen when button is clicked?
0
0
0
881
17,518,614
2013-07-08T03:00:00.000
2
1
1
1
python
17,518,734
1
true
0
0
You can use pip -e install <path-to-package> to install a package in editable mode. Then, you can make changes to the source code, and not have to install it again. This is best done, as always, in a virtualenv, so it is isolated from the rest of your system.
1
1
0
I have the source code to a python package that is typically installed using pup or easy-install. How do I locally install the code after I've made changes? I'd like to be able to run commands on the terminal as if I've installed it with pip and then reinstall/have it detect code changes to try it again.
Testing Python Packages
1.2
0
0
78
17,522,223
2013-07-08T08:37:00.000
0
0
0
0
python,tkinter,wxpython,pyqt,pygtk
17,525,347
5
false
0
1
I only got expirience with Qt-based Python GUI-toolkits, and found them to be very powerful, well documented and simple to use (as long as you stay away from model-view framework). And they can do all the things you mentioned. So my recomendation would be PyQt or PySide. PySide's advantage is it's license - LGPL, so if your stuff is proprietary - go for PySide. PySide has some troubles however, as it is basically abandoned as of writing this, so you will have to dodge some bugs (nothing realy critical IMO). PyQt is more actively maintained and developed, but it's GPL or commercial (about 400 euros). So if your stuff is free, you should choose PyQt. And yes, use ORM, if possible. Just my 2 cents.
2
1
0
I know this question has been asked before but those questions typically lack specific details and result in answers that say something like "It depends what you are trying to do..." so the main gist of this app is that it retrieves remote data (ex. text) and object (ex. images). Since PHP and python are the two programming languages I feel comfortable with I felt python was more suited for desktop gui apps. I'm creating a desktop music player and here are some of the technical specs I want to include: A sign in construct that authenticates user credentials (Like spotify, skype, league of legends) against a remote database (This will be in mysql.) My thinking is to create a web api for the client to query via HTTP/HTTPS GET/POST A client side SQLite database that stores the filename, filepath and id3 tags of the song so upon launching, the application displays each song in a row with the song length, artist, album, genre (Like iTunes) Retrieve remote images and display them within the application's frame (Like skype displays a person's profile picture.) Must be cross-platform (At least in Windows and Mac), look native in different OS's but the native look and feel should be easily overridden with custom styles (Ex. rounded buttons with gradients.) Compilation for Windows and Mac should be relatively straightforward Of the popular python gui toolkits like PyQt, PyGTK, Tkinter, wxPython, Pyjamas, PyGObject and PySide which are well suited for my application and why? Why are the others not well suited for these specs? Which have good documentation and active communities?
Considerations for python gui toolkit for app that queries remote database?
0
0
0
1,760
17,522,223
2013-07-08T08:37:00.000
2
0
0
0
python,tkinter,wxpython,pyqt,pygtk
17,523,987
5
false
0
1
Both PySide and WxPython support all five of your requirements. WxPython uses actual native widgets and also has custom extensions and widgets built on top. It has goodies like wx.CallAfter which'll allow you to run your background tasks in a separate thread and hop back on the UI thread easily. PySide has a nicer API but draws its own widgets that imitate the underlying OS's UI. It's not as mature as WxPython and packaging it with tools like cx_freeze and PyInstaller is slightly more involved. Also I recommend that you use an ORM like peewee over plain Sqlite3 for the data storage, it makes managing the data a lot easier and plays well with the freezing tools.
2
1
0
I know this question has been asked before but those questions typically lack specific details and result in answers that say something like "It depends what you are trying to do..." so the main gist of this app is that it retrieves remote data (ex. text) and object (ex. images). Since PHP and python are the two programming languages I feel comfortable with I felt python was more suited for desktop gui apps. I'm creating a desktop music player and here are some of the technical specs I want to include: A sign in construct that authenticates user credentials (Like spotify, skype, league of legends) against a remote database (This will be in mysql.) My thinking is to create a web api for the client to query via HTTP/HTTPS GET/POST A client side SQLite database that stores the filename, filepath and id3 tags of the song so upon launching, the application displays each song in a row with the song length, artist, album, genre (Like iTunes) Retrieve remote images and display them within the application's frame (Like skype displays a person's profile picture.) Must be cross-platform (At least in Windows and Mac), look native in different OS's but the native look and feel should be easily overridden with custom styles (Ex. rounded buttons with gradients.) Compilation for Windows and Mac should be relatively straightforward Of the popular python gui toolkits like PyQt, PyGTK, Tkinter, wxPython, Pyjamas, PyGObject and PySide which are well suited for my application and why? Why are the others not well suited for these specs? Which have good documentation and active communities?
Considerations for python gui toolkit for app that queries remote database?
0.07983
0
0
1,760
17,522,492
2013-07-08T08:53:00.000
5
1
1
0
python,oop,scientific-computing
17,598,977
2
true
0
0
Your general idea would work, here are some more details that will hopefully help you to proceed: Create an abstract Data class, with some generic methods like load, save, print etc. Create concrete subclasses for each specific form of data you are interested in. This might be task-specific (e.g. data for natural language processing) or form-specific (data given as a matrix, where each row corresponds to a different observation) As you said, create an abstract Analysis class. Create concrete subclasses for each form of analysis. Each concrete subclass should override a method process which accepts a specific form of Data and returns a new instance of Data with the results (if you think the form of the results would be different of that of the input data, use a different class Result) Create a Visualization class hierarchy. Each concrete subclass should override a method visualize which accepts a specific instance of Data (or Result if you use a different class) and returns some graph of some form. I do have a warning: Python is abstract, powerful and high-level enough that you don't generally need to create your own OO design -- it is always possible to do what you want with mininal code using numpy, scipy, and matplotlib, so before start doing the extra coding be sure you need it :)
1
8
0
As a biology undergrad i'm often writing python software in order to do some data analysis. The general structure is always : There is some data to load, perform analysis on (statistics, clustering...) and then visualize the results. Sometimes for a same experiment, the data can come in different formats, you can have different ways to analyses them and different visualization possible which might or not depend of the analysis performed. I'm struggling to find a generic "pythonic" and object oriented way to make it clear and easily extensible. It should be easy to add new type of action or to do slight variations of existing ones, so I'm quite convinced that I should do that with oop. I've already done a Data object with methods to load the experimental data. I plan to create inherited class if I have multiple data source in order to override the load function. After that... I'm not sure. Should I do a Analysis abstract class with child class for each type of analysis (and use their attributes to store the results) and do the same for Visualization with a general Experiment object holding the Data instance and the multiple Analysis and Visualization instances ? Or should the visualizations be functions that take an Analysis and/or Data object(s) as parameter(s) in order to construct the plots ? Is there a more efficient way ? Am I missing something ?
Object-oriented scientific data processing, how to cleverly fit data, analysis and visualization in objects?
1.2
0
0
2,039
17,522,521
2013-07-08T08:55:00.000
1
0
0
0
python-2.7,openpyxl
24,183,661
2
false
0
0
I had the same problem when saving the file with openpyxl: formulas removed. But I pointed out that some intermediate formulas were still there. After some tests, it appears that, in my case, all formulas which are displaying blank result (nothing) are cleaned when the save occured, unlike the formulas with an output in the cell, which are preserved. ex : =IF((SUM(P3:P5))=0;"";(SUM(Q3:Q5))/(SUM(P3:P5))) => can be removed when saving because of the blank result ex : =IF((SUM(P3:P5))=0;"?";(SUM(Q3:Q5))/(SUM(P3:P5))) => preserved when saving for my example I'm using openpyxl-2.0.3 on Windows. Open and save function calls are : self._book = load_workbook("myfile.xlsx", data_only=False) self._book.save("myfile.xlsx")
1
0
0
im using openpyxl to edit an excel file that contains some formulas in certain cells. Now when i populate the cells from a text file, im expecting the formula to work and give me my desired output. But what i observe is that the formulas get removed and the cells are left blank.
Openpyxl: Formulas getting removed when saving file
0.099668
1
0
1,400
17,525,595
2013-07-08T11:33:00.000
1
0
0
0
python,ipython,jinja2,ipython-notebook
17,526,180
4
false
1
0
Using the inline-modus of ipython notebook, ipython notebook --pylab inline you can execute your matplotlib-scripts in a browser interactively (thus generating your plots). Then go to File -> Print View (in the notebook-menu, NOT the browser menu) and save the generated html-File (via the browser menu). This will include all the plots you generated before as well as the python code. Of course, you cannot modify these html-Files anymore without the notebook-server in the background. Is this what you mean?
1
4
0
I am working on a scientific python project performing a bunch of computations generating a lot of data. The problem comes when reports have to be generated from these data, with images embedded (mostly computed with matplotlib). I'd like to use a python module or tool to be able to describe the reports and "build" HTML pages for these reports (or any format supported by a browser). I was thinking about generating an ipython notebook but I was unable to find if there is a way to do so (except creating the json but I'm doubtful about this approach). The other way is using Sphinx a bit like the matplotlib but I am not sure how I could really fine-tune the layouts of my various pages. The last option is to use jinja2 templates (or django-templates or any template engine working) and embed matplotlib code inside. I know it's vague but was unable to find any kind of reference.
Scientific Reporting in Python
0.049958
0
0
1,861
17,525,882
2013-07-08T11:50:00.000
0
0
0
0
python,matplotlib,unicode,python-2.x
42,853,468
2
false
0
0
In Python3, there is no need to worry about all that troublesome UTF-8 problems. One note that you will need to set a Unicode font before plotting. matplotlib.rc('font', family='Arial')
1
5
1
Can't get the titles right in matplotlib: 'technologieën in °C' gives: technologieÃn in ÃC Possible solutions already tried: u'technologieën in °C' doesn't work neither does: # -*- coding: utf-8 -*- at the beginning of the code-file. Any solutions?
How to pass Unicode title to matplotlib?
0
0
0
6,904
17,528,657
2013-07-08T14:03:00.000
2
1
0
0
c++,python,list
17,529,258
5
false
0
1
There is no real equivalent, and it would be extremely difficult to provide one. Python and C++ are radically different languages, and providing one really wouldn't make much sense in the context of C++. The most important differences are that everything in Python is dynamically allocated, and is an "object", and that Python uses duck typing. FWIW: one very early library (before templates) in C++ did offer containers of Object*, with derived classes to box int, double, etc. Actual experience showed very quickly that it wasn't a good idea. (And I'm curious: does any one else remember it? And particularly, exactly what it was called---something with NHS in it, but I can't remember more.)
2
15
0
Could you please tell me what is the closest data type in C++ to python list? If there is nothing similar, how would you build it in C++?
Python list equivalent in C++?
0.07983
0
0
21,803
17,528,657
2013-07-08T14:03:00.000
5
1
0
0
c++,python,list
17,529,154
5
false
0
1
Actually no C++ container is equivalent to Python's list, which is partially a result of the very different object models of C++ and Python. In particular, the suggested and upvoted std::list is IMHO not even close to Python's list type, a I'd rather suggest std::vector or maybe std::deque. That said, it isn't clear what exactly it is that you want and how to "build it" strongly depends on what exactly "it" is, i.e. what you expect from the container. I'd suggest you take a look at the C++ containers std::vector, std::deque and std::list to get an overview. Then look at things like Boost.Any and Boost.Variant that you can combine with them, maybe also one of the smart pointers and Boost.Optional. Finally, check out Boost.Container and Boost.Intrusive. If the unlikely case that none of these provide a suitable approximation, you need to provide a better explanation of what your actual goals are.
2
15
0
Could you please tell me what is the closest data type in C++ to python list? If there is nothing similar, how would you build it in C++?
Python list equivalent in C++?
0.197375
0
0
21,803
17,533,094
2013-07-08T18:02:00.000
3
0
1
0
python,installation,package,enthought,canopy
45,376,116
5
false
0
0
sometimes installing packages can be hard for enthought canopy . You could install all python packages using pip install mrjob command on the its own canopy command prompt Go to tools tab on the canopy editor , Left click on the canopy command prompt , Finally pip install <package name> and hit Enter key
1
4
0
I'm really new to coding, programming, Python, and just computers in general, so I need some help with Canopy. I've been having pretty consistent troubles installing any packages to Canopy; some stuff is in the internal package manager,but whenever it isn't, it's really confusing. I guess I'll list a specific installation. I'm trying to install "pywcs" (link provided below) to my Win7 64-bit machine. I have Cygwin if that helps at all. I do not know how to go about this; the stuff I found online is pretty confusing, and Cygwin easy_install (filename) never seems to work. Any step-by-step solutions?
Installing a package to Canopy
0.119427
0
0
14,628
17,533,631
2013-07-08T18:35:00.000
3
0
0
0
python,django,web
17,533,814
3
false
1
0
Even though the details are wrong (there's no app.py in new Django projects), the question is still valid. __init__.py is imported implicitly when importing a sub-module. So if something in __init__.py executes automatically with side effects, you might run into unintended consequences. Doing everything in app.py incurs a longer import, but separates package init from app init logic.
2
0
0
In Django 1.4 and above : There is a new file called app.py in every django application. It defines the scope of the app and some initials required when loaded. Why don't they use __init__.py for the purpose? Any advantage over __init__.py approach? Can you link to some official documentation for the same?
What is the purpose of app.py in django apps?
0.197375
0
0
2,402
17,533,631
2013-07-08T18:35:00.000
2
0
0
0
python,django,web
17,535,359
3
true
1
0
As all the links you have provided clearly show, this is nothing at all to do with Django itself, but a convention applied by the third-party app django-oscar.
2
0
0
In Django 1.4 and above : There is a new file called app.py in every django application. It defines the scope of the app and some initials required when loaded. Why don't they use __init__.py for the purpose? Any advantage over __init__.py approach? Can you link to some official documentation for the same?
What is the purpose of app.py in django apps?
1.2
0
0
2,402
17,535,252
2013-07-08T20:18:00.000
2
0
0
0
python,wxpython
17,535,320
1
true
0
1
Just keep track of the line that you are on/or has been updated and call EnsureVisible on the text control. (Also ensure you are using Append rather than Set to add new text). Correction, (now I have access to the help files), I was getting mixed up with MakeCellVisible from Grid controls: YourTextCtrl.ShowPositon(YourTextCtrl.GetLastPosition()) should do the job nicely. Even better if you call SetInsertionPointEnd() on your text control before the text is inserted, (by using WriteText), then your problem goes away.
1
0
0
I have a scrollable wx.textcontrol widget that updates during the course of the program. Whenever the text is updated,the scrollbar resets to the top of the screen. I don't want that to happen, but I can't figure out how to stop it. Does any of you know?
Scroll bar problems
1.2
0
0
70
17,536,394
2013-07-08T21:36:00.000
1
0
0
0
python,numpy,machine-learning,scipy,scikit-learn
28,424,354
2
false
0
0
One way to overcome the inability of HashingVectorizer to account for IDF is to index your data into elasticsearch or lucene and retrieve termvectors from there using which you can calculate Tf-IDF.
1
3
1
TFIDFVectorizer takes so much memory ,vectorizing 470 MB of 100k documents takes over 6 GB , if we go 21 million documents it will not fit 60 GB of RAM we have. So we go for HashingVectorizer but still need to know how to distribute the hashing vectorizer.Fit and partial fit does nothing so how to work with Huge Corpus?
How can i reduce memory usage of Scikit-Learn Vectorizers?
0.099668
0
0
4,523
17,536,758
2013-07-08T22:03:00.000
1
0
1
0
python,scala,equivalent
17,538,468
5
false
0
0
Similarly, IDEA has its "Quick Documentation Look-up" command, which works for Scala as well as Java (-Doc) JARs and source-code documentation comments.
2
11
1
I'm proficient in Python but a noob at Scala. I'm about to write some dirty experiment code in Scala, and came across the thought that it would be really handy if Scala had a function like help() in Python. For example, if I wanted to see the built-in methods for a Scala Array I might want to type something like help(Array), just like I would type help(list) in Python. Does such a thing exist for Scala?
Scala equivalent of Python help()
0.039979
0
0
2,972
17,536,758
2013-07-08T22:03:00.000
0
0
1
0
python,scala,equivalent
55,942,086
5
false
0
0
In scala , you can try using the below ..( similar to the one we have in python ).. help(RDD1) in python will give you the rdd1 description with full details. Scala > RDD1.[tab] On hitting tab you will find the list of options available to the specified RDD1, similar option you find in eclipse .
2
11
1
I'm proficient in Python but a noob at Scala. I'm about to write some dirty experiment code in Scala, and came across the thought that it would be really handy if Scala had a function like help() in Python. For example, if I wanted to see the built-in methods for a Scala Array I might want to type something like help(Array), just like I would type help(list) in Python. Does such a thing exist for Scala?
Scala equivalent of Python help()
0
0
0
2,972
17,536,779
2013-07-08T22:05:00.000
0
1
1
0
python,argv,tidesdk,sys
17,544,560
2
false
0
0
Looks like you have another sys.py in your python path.
2
0
0
I'm trying to read the arguments passed to a Python script called with Ti.Process.createProcess. When I run the following code: import sys sys.argv I get the error: File "", line 2, in <module> AttributeError: 'module' object has no attribute 'argv' It looks like the sys object doesn't have an argv attribute. Am I doing something wrong? any suggestions?
TideSDK Python get arguments with sys.argv
0
0
0
283
17,536,779
2013-07-08T22:05:00.000
0
1
1
0
python,argv,tidesdk,sys
17,558,670
2
false
0
0
I found the error. I was testing the code using this code: <script type="text/python" src="script.py"></script> and <script type="text/python"> import sys print sys.argv </script> And I received the error: File "", line 2, in <module> AttributeError: 'module' object has no attribute 'argv' But when I run: var path = Ti.API.getApplication().getResourcesPath(); var p = Ti.Process.createProcess(['python', path + '\search_client.py', param1, param2]); p.setOnReadLine(function(data){doStuff(data)}); p.launch(); I get the correct result. So, in TideSDK, a python script has access to the sys.argv element only when it is excecuted as a "Process" but not when it's excecuted as a "<script>".
2
0
0
I'm trying to read the arguments passed to a Python script called with Ti.Process.createProcess. When I run the following code: import sys sys.argv I get the error: File "", line 2, in <module> AttributeError: 'module' object has no attribute 'argv' It looks like the sys object doesn't have an argv attribute. Am I doing something wrong? any suggestions?
TideSDK Python get arguments with sys.argv
0
0
0
283
17,539,441
2013-07-09T03:31:00.000
0
0
0
0
python-2.7,wxpython
17,550,349
2
false
0
1
You would use a wx.grid.Grid in most cases. You could use a wx.ListCtrl or an ObjectListView widget too. The idea is to put the widgets inside of sizers. So you could have a top level BoxSizer in vertical orientation that contains another sizer or sizers. In this case, I would create a sizer to hold the buttons and nest that sizer in the top level sizer. Then add the table (i.e. grid) to the top level sizer and you're done.
2
0
0
I have a frame with buttons and plotting options and wanted to include a table as well in that frame. Is there any example or suggestion on how to do it? Thanks.
How to insert a table inside a frame?
0
0
0
88
17,539,441
2013-07-09T03:31:00.000
0
0
0
0
python-2.7,wxpython
17,547,609
2
false
0
1
The wxpython demo is full of examples of all differant controls.
2
0
0
I have a frame with buttons and plotting options and wanted to include a table as well in that frame. Is there any example or suggestion on how to do it? Thanks.
How to insert a table inside a frame?
0
0
0
88
17,541,225
2013-07-09T06:15:00.000
1
0
0
0
python,sqlalchemy
17,542,024
2
true
0
0
session.query(Table1.user_id).outerjoin(Table2).filter(Table2.user_id == None)
1
1
0
I have two tables with a common field I want to find all the the items(user_id's) which present in first table but not in second. Table1(user_id,...) Table2(userid,...) user_id in and userid in frist and second table are the same.
find missing value between to tables in sqlalchemy
1.2
1
0
225
17,546,608
2013-07-09T11:04:00.000
1
0
0
0
python,amazon-s3
17,759,017
1
true
1
0
Make sure that the expiration time of the link is set to a very short time. Then make sure that you are communicating with the user via SSL, and that the link provided is SSL. When using an SSL connection, both the data from the page and the URL are encrypted, and no one 'sniffing' the data should be able to see anything. The only other way to put a real lock down on a file like that would be to then aggressively check the log files generated by the S3 bucket, and check the link for abuse. The problem however is that the traffic for your link may take several hours to make it into logs, but dependant on how long you want these links to last that time delay may be acceptable. Then assuming you find abuse, such as several different IP addresses hitting the link, you can stop the hits by renaming the file on S3. The ultimate is for your server to grab the data off S3 and spoon feed it to the customer. Then it is impossible for anyone to get the file unless you authenticate them and they remain in the session. The big downer of course is that you are taxing your server, and are defeating half the reason S3 is cool, namely you don't have to serve the file, S3 does. But if your server is on Amazon EC2, there is no cost in pulling from S3, only the download to the customer would be charged. Additionally EC2 instances can access and download data from S3 at local network levels of speed, and like I said its free.
1
0
0
I am trying to give user a temporary link to download files from Amazon S3 bucket in python. I am using generate_url method which generates the url for a specified time peiod. My concern is when this link is created,anyone including the desired user can hit this url in that time period and get the files.How can I prevent other people from getting access to the files ?
How to generate a secure temporary url to download file from Amazon S3?
1.2
0
1
1,631
17,546,628
2013-07-09T11:05:00.000
0
0
0
0
python-3.x,sqlite,ssl,compilation,non-admin
17,979,292
2
false
0
0
I don't use that distro, but Linux Mint (it's based on Ubuntu). In my case before the compilation of Python 3.3.2 I've installed the necessary -dev libraries: $ sudo apt-get install libssl-dev $ sudo apt-get install libbz2-dev ... Then I've compiled and installed Python and those imports work fine. Hope you find it useful León
1
1
0
I want to build Python 3.3.2 from scratch on my SLE 11 (OpenSUSE). During the compilation of Python I got the message that the modules _bz2, _sqlite and _ssl have not been compiled. I looked for solutions with various search engines. It is often said that you have to install the -dev packages with your package management system, but I have no root access. I downloaded the source packages of the missing libs, but I have no idea how to tell Python to use these libs. Can somebody help me?
How to build python 3.3.2 with _bz2, _sqlite and _ssl from source
0
1
0
444
17,548,159
2013-07-09T12:27:00.000
3
0
0
1
c++,python,linux
17,549,425
1
true
0
0
If it were me, I'd try to change the CFD code to be a library instead of an application, and then I'd expose it to Python. Then I'd write a Python script that would invoke the library and get the results, iterating as needed. If the CFD code doesn't take very long to run a single iteration, this will be more efficient than launching the CFD standalone program over and over. And perhaps more importantly it will allow exchange of rich data between the CFD code and the supervisor, rather than only text files.
1
1
0
I run a lot of computational fluid dynamics (CFD) calculations. For many reasons, I would like to write a program which will monitor the output of the log file given by the CFD solver and adjust its control parameters accordingly. I have a few ideas but would like to ask for advice as to what would be the best way to do this. My thoughts: could run the program constantly and import the convergence parameters at a fixed time interval or when the log file changes could use some system or platform specific utilities to monitor the CFD process the CFD runs in parallel on the same machine so (probably) will need a way to control the parallel processes (the CFD code I'm using is OpenFOAM which utilises OpenMPI to parallelise its processes) For completeness, I run on Ubuntu 12.04 and would prefer the program to be written in C/C++ or alternatively Python. Thanks a lot
CFD monitoring program
1.2
0
0
366
17,549,279
2013-07-09T13:20:00.000
0
0
1
0
python,mobile,unity3d,nltk
17,551,204
1
false
0
1
Traditional/classic Python is implemented in C. This makes it easy to integrate into any environment that has support for compiled C. I'm unfamiliar with Unity, but here are some general guidelines on how you would do it with standard iOS and Android. On iOS, you would just add all of the Python C source files (minus the ones that have a 'main' function) to your project in Xcode. On Android, you would add all of the C source files (again, minus the ones that have a 'main' function) to your project in the JNI part of your project and would use ndk-build to build a native shared library that would be part of your app. Are you limited to Python? If not, you might want to have a look at Lua as it's much smaller (fewer C source files) and might be quicker to get going.
1
0
0
Sorry for the sort of general question, but I'm having a hard time figuring out how to start this. I'm trying to incorporate some natural language toolkit code in Python with a mobile app I'm developing in Unity. It's a very small amount of code, but it's critical for the functioning of the app. Do I need to have the python code running on some kind of server? How would I go about doing this? I'm very new to python and mobile development. Thanks.
How can I incorporate Python code in a mobile app?
0
0
0
292
17,553,182
2013-07-09T16:13:00.000
5
0
1
1
python,macos,stdout,py2app
17,566,504
3
false
0
0
Where the stdout and stderr streams are redirect to depends on how you run the application, and on which OSX release you are. When you run the application from the Terminal ("MyApp.app/Contents/MacOS/MyApp") the output ends up in the terminal window. When you run the application by double clicking, or using the open(1) command, the output ends up in Console.app when using OSX before 10.8 and is discarded on OSX 10.8. I have a patch that redirects output to the logs that Console.app reads even for OSX 10.8, but that is not in a released version at this point in time. P.S. I'm the maintainer of py2app.
1
4
0
So I have a python application that is being bundled into a .app using py2app. I have some debugging print statements in there that would normally print to stdout if I was running the code in the terminal. If I just open the bundled .app, obviously I don't see any of this output. Is any of this actually being printed somewhere even though I don't see it?
Where does stuff "print" to when not running application from terminal?
0.321513
0
0
1,553
17,554,093
2013-07-09T17:04:00.000
4
0
1
1
python,virtualenv
17,554,381
2
true
0
0
Virtualenvs are not a packaging mechanism. There is no reason a virtualenv should ever leave the computer it was created on. It won't work, the virtualenv is 100% specific to your OS, CPU architecture, Python version, etc. There are a number of solutions for packaging. The old and still current way is specifying dependencies in setup.py, and running setup.py install on the target machine. Note that this can happen inside a virtualenv, you just have to create the virtualenv and run setup.py in there. Both virtualenv and the standard library venv in 3.3 provide ways of doing this automatically after virtualenv creation. If you absolutely must create a binary distribution (e.g. because you need an extension module and the end user doesn't have a compiler), you need an egg or a wheel or one of the .py-to-binary converters (py2exe, PyInstaller, cx_Freeze, etc.). You will need access to an OS X machine to create that. And at least the wheel and the egg are usually installed anyway, so using them doesn't save you any of this hassle. That's because they are formats for binary distribution, their primary purpose is pushing the build step from the end user to the developers, not to remove the installation step. In summary: Just create a script which creates a virtualenv and installs your application as well as the required libraries.
1
2
0
I'm writing a program on a computer running Ubuntu with an x86-64 processor that needs to run on a computer running OS X with an x86 processor. I'm probably not going to be able to do any kind of library installation, so a venv is pretty much the only option I know of. How can I make one targeted for that platform? If I can't, is there a better way to ship the libraries with the program?
How can I make a Python virtualenv meant for another platform?
1.2
0
0
1,454
17,555,111
2013-07-09T18:01:00.000
1
0
0
0
python,qt,pyside
17,557,946
1
true
0
1
QLabel QTextDocument QTextEdit Almost all of the options above, can be configured to be "Read-only" or even unclickable by making them disabled. QTextStream is also a really useful class. Hope that helps.
1
0
0
What is the best way to a text based output in a Qt widget? what I mean by this is... like in win RAR or some windows installers where there is a drop down arrow showing more details and it shows live text output of files modified and things of that nature. how would I go about doing that in a Qt app? I was thinking maybe a none editable multiple line text box... but I'm not sure, because I don't wan't it to be editable. any help on this would be greatly appreciated.
how to make a Qt text output widget?
1.2
0
0
590
17,557,489
2013-07-09T20:24:00.000
2
0
1
0
python,user-interface,tkinter
17,560,333
3
false
0
1
Tkinter has a way to link widgets and data. You can create an instance of StringVar, and assign it to the textvariable attribute of a label. Whenever you change the value of the variable, the label will automatically update.
2
2
0
I am aiming to make a money counter for the game i am programming. For example, if I buy something (in the game) I want my money label to update with the new value once this happens. How would I go about this besides creating a loop that checks every second to see if my variable has changed? Thanks so much!
Updating Label when variable changes in Tkinter
0.132549
0
0
858
17,557,489
2013-07-09T20:24:00.000
0
0
1
0
python,user-interface,tkinter
17,557,564
3
false
0
1
Ping the money counter with a function whenever an action such as buying or selling something occurs
2
2
0
I am aiming to make a money counter for the game i am programming. For example, if I buy something (in the game) I want my money label to update with the new value once this happens. How would I go about this besides creating a loop that checks every second to see if my variable has changed? Thanks so much!
Updating Label when variable changes in Tkinter
0
0
0
858
17,557,813
2013-07-09T20:41:00.000
34
1
0
0
python,reporting,pytest
17,595,687
3
true
1
0
I think you also need to specify the directory/file you want coverage for like py.test --cov=MYPKG --cov-report=html after which a html/index.html is generated.
1
26
0
This is not a technical question at all really. However, I can not locate my .HTML report that is supposed to be generated using: py.test --cov-report html pytest/01_smoke.py I thought for sure it would place it in the parent location, or the test script location. Does neither and I have not been able to locate. So I am thinking it is not being generated at all?
Py.Test : Reporting and HTML output
1.2
0
0
41,617
17,559,967
2013-07-09T23:24:00.000
5
0
0
0
python,flask,pythonanywhere
17,579,664
4
false
1
0
PythonAnywhere Dev here. You also have your access log. You can click through this from your web app tab. It shows you the raw data about your visitors. I would personally also use something like Google Analytics. However you don't need to do anything to be able to just see your raw visitor data. It's already there.
1
9
0
I just deployed my first ever web app and I am curious if there is an easy way to track every time someone visits my website, well I am sure there is but how?
how do I track how many users visit my website
0.244919
0
0
11,232
17,560,658
2013-07-10T00:43:00.000
1
0
1
0
python,regex
24,908,840
4
false
0
0
For detecting 2-or-more consecutive letters the regex becomes: (\w)\1+
1
6
0
I want to find words that have consecutive letter pairs using regex. I know for just one consecutive pair like zoo (oo), puzzle (zz), arrange (rr), it can be achieved by '(\w){2}'. But how about two consecutive pairs: committee (ttee) three consecutive pairs: bookkeeper (ookkee) edit: '(\w){2}' is actually wrong, it finds any two letters instead of a double letter pair. My intention is to find the words that have letter pairs, not the pairs. By 'consecutive', I mean there is no other letter between letter pairs.
python: how to find consecutive pairs of letters by regex?
0.049958
0
0
12,433
17,561,212
2013-07-10T01:48:00.000
88
0
1
0
python,ipython,jupyter-notebook
38,229,513
5
false
0
0
You can press I twice to interrupt the kernel. This only works if you're in Command mode. If not already enabled, press Esc to enable it.
2
110
0
I've started to use the IPython Notebook and am enjoying it. Sometimes, I write buggy code that takes massive memory requirements or has an infinite loop. I find the "interrupt kernel" option sluggish or unreliable, and sometimes I have to restart the kernel, losing everything in memory. I also sometimes write scripts that cause OS X to run out of memory, and I have to do a hard reboot. I'm not 100% sure, but when I've written bugs like this before and ran Python in the terminal, I can usually CTRL+C my scripts. I am using the Anaconda distribution of IPython notebook with Firefox on Mac OS X.
Is there an equivalent to CTRL+C in IPython Notebook in Firefox to break cells that are running?
1
0
0
163,281
17,561,212
2013-07-10T01:48:00.000
5
0
1
0
python,ipython,jupyter-notebook
41,617,417
5
false
0
0
To add to the above: If interrupt is not working, you can restart the kernel. Go to the kernel dropdown >> restart >> restart and clear output. This usually does the trick. If this still doesn't work, kill the kernel in the terminal (or task manager) and then restart. Interrupt doesn't work well for all processes. I especially have this problem using the R kernel.
2
110
0
I've started to use the IPython Notebook and am enjoying it. Sometimes, I write buggy code that takes massive memory requirements or has an infinite loop. I find the "interrupt kernel" option sluggish or unreliable, and sometimes I have to restart the kernel, losing everything in memory. I also sometimes write scripts that cause OS X to run out of memory, and I have to do a hard reboot. I'm not 100% sure, but when I've written bugs like this before and ran Python in the terminal, I can usually CTRL+C my scripts. I am using the Anaconda distribution of IPython notebook with Firefox on Mac OS X.
Is there an equivalent to CTRL+C in IPython Notebook in Firefox to break cells that are running?
0.197375
0
0
163,281
17,564,244
2013-07-10T06:56:00.000
2
0
1
0
c#,java,php,python,uniqueidentifier
17,564,354
1
true
0
0
For python mappings you could use (grouptype, groupranking, groupname) as a dictionary key or you could reduce the size of the dictionaries by splitting something like a dictionary with a key of grouptype -> groupranking -> groupname. For generating a unique url what is wrong with grouptype.rank.name or the same with / as a seperator - you could use the valid url type functions to replace invalid chars in each with %nn format. You could use urllib.quote('/'.join([baseurl, grouptype, groupranking, groupname]) to generate such a path or even baseurl + urllib.urlencode({'grouptype':grouptype,'groupranking':groupranking,'groupname':groupname}) - the latter will result in the typical query format of baseurl?grouptype=Whatever&....
1
1
0
I have the following three pieces of information. A group name, a group type, and group ranking. As a quick example "Mom's cats", "Cats", "Top10" The example is way off from what I'm doing with this, but you get the basic idea. The group name is a large selection of possible values (like around 20k) and the group type and group ranking are smaller amounts (like 10 each) Trying to find a better way to come up with a short unique identifier for these group of things rather than having to use a sha1 with a huge ugly URL. Any better ideas? Open to all language solutions, so just pinning a lot of programmers here since I can't think of a better tag to assign to this. Thanks. EDIT: One solution that I found elsewhere a while back stated about taking the last few characters in the SHA-1 and converting them to a decimal value. Not sure how reliable this idea is and the chance of collision. EDIT2: Using mongoDB and storing this sha1 value in the DB along with the members to make querying easy at the moment. Trying to find an alternative solution to creating an autoincrement field in a seperate table/collection which means a lot more queries when running updating scripts.
Try to compress Sha1 down in size, maybe a better option to make unique identifier
1.2
0
0
217
17,564,385
2013-07-10T07:05:00.000
1
1
1
0
python,bit-manipulation,low-level,high-level
17,564,913
3
false
0
0
Almost anything using transmission protocols will end up using bitwise operation at some point - a set of flags that are all true or false will normally be combined into a single byte for up to 8 flags to save on bandwidth and short of having a dictionary of 255 values to decode it - don't laugh I have seen it done in more than one language in one case with very large number of if else statments - when at most a few bitwise operations were all that was needed.
2
4
0
I'm having trouble understanding just why I would want to use bitwise operators in a high-level language like Python. From what I have learned of high- vs low-level languages is that high-level ones are typically designed to that you don't have to worry too much about the machine code going into a computer. I don't see the point of manipulating a program bit-by-bit in a language that, to my knowledge, was designed to avoid it.
What are the advantages to using bitwise operations over boolean operations in Python?
0.066568
0
0
1,812
17,564,385
2013-07-10T07:05:00.000
4
1
1
0
python,bit-manipulation,low-level,high-level
17,564,596
3
false
0
0
There's definitely a use for bitwise operations in Python. Aside from or-ing flags, like mgilson mentions, I used them myself for composing packet headers for CAN messages. Very often, the headers for a lower-level message protocol are composed of fields that have a length that is not a multiple of 8 bits, so you would need bitwise operators if you want to change one field only. Python being a higher-level language does not mean you cannot do low-level stuff with it!
2
4
0
I'm having trouble understanding just why I would want to use bitwise operators in a high-level language like Python. From what I have learned of high- vs low-level languages is that high-level ones are typically designed to that you don't have to worry too much about the machine code going into a computer. I don't see the point of manipulating a program bit-by-bit in a language that, to my knowledge, was designed to avoid it.
What are the advantages to using bitwise operations over boolean operations in Python?
0.26052
0
0
1,812
17,569,007
2013-07-10T11:03:00.000
7
0
0
0
python,user-interface,python-2.7,timer,tkinter
17,570,984
5
true
0
1
I think what you need is this . from Tkinter import * import time class StopWatch(Frame): """ Implements a stop watch frame widget. """ def __init__(self, parent=None, **kw): Frame.__init__(self, parent, kw) self._start = 0.0 self._elapsedtime = 0.0 self._running = 0 self.timestr = StringVar() self.makeWidgets() def makeWidgets(self): """ Make the time label. """ l = Label(self, textvariable=self.timestr) self._setTime(self._elapsedtime) l.pack(fill=X, expand=NO, pady=2, padx=2) def _update(self): """ Update the label with elapsed time. """ self._elapsedtime = time.time() - self._start self._setTime(self._elapsedtime) self._timer = self.after(50, self._update) def _setTime(self, elap): """ Set the time string to Minutes:Seconds:Hundreths """ minutes = int(elap/60) seconds = int(elap - minutes*60.0) hseconds = int((elap - minutes*60.0 - seconds)*100) self.timestr.set('%02d:%02d:%02d' % (minutes, seconds, hseconds)) def Start(self): """ Start the stopwatch, ignore if running. """ if not self._running: self._start = time.time() - self._elapsedtime self._update() self._running = 1 def Stop(self): """ Stop the stopwatch, ignore if stopped. """ if self._running: self.after_cancel(self._timer) self._elapsedtime = time.time() - self._start self._setTime(self._elapsedtime) self._running = 0 def Reset(self): """ Reset the stopwatch. """ self._start = time.time() self._elapsedtime = 0.0 self._setTime(self._elapsedtime) def main(): root = Tk() sw = StopWatch(root) sw.pack(side=TOP) Button(root, text='Start', command=sw.Start).pack(side=LEFT) Button(root, text='Stop', command=sw.Stop).pack(side=LEFT) Button(root, text='Reset', command=sw.Reset).pack(side=LEFT) Button(root, text='Quit', command=root.quit).pack(side=LEFT) root.mainloop() if __name__ == '__main__': main() P.S: Fit this in your code I just implemented the basic timer in tkinter.
2
4
0
I'm looking to add a timer for my simple math game. So far everything works just fine, the user gets questions when pressing the button and is given feedback on the answer. I want to add a timer for the user to see how much time it takes to answer the multiplication. This is the final part of my prototype to this mathgame. I want the timer to start when the user clicks "nytt tal" which means new number in swedish, and to stopp when the user clicks "svar" which means answer in swedish. Here is my code. from Tkinter import * import tkMessageBox import random import time import sys # Definition for the question asked to user def fraga1(): global num3 num3 = random.randint(1, 10) global num4 num4 = random.randint(1, 10) global svar1 svar1 = num3 * num4 label1.config(text='Vad blir ' + str(num3) + '*' + str(num4) + '?') entry1.focus_set() #The answer giving feedback based on answer def svar1(): mainAnswer = entry1.get() if len(mainAnswer) == 0: tkMessageBox.showwarning(message='Skriv in några nummer!') return if int(mainAnswer) != svar1: tkMessageBox.showwarning(message='Tyvärr det rätta svaret: ' + str(svar1)) else: tkMessageBox.showinfo(message='RÄTT!! :)') #The quit button definition def quit(): global root root.destroy() #Definition for the timer this part doesnt work def start(): global count_flag fraga1() count_flag = True count = 0.0 while True: if count_flag == False: break label['text'] = str(count) time.sleep(0.1) root.update() count += 0.1 #Window code root = Tk() root.title("multiplikations tidtagning") root.geometry('800x500') count_flag = True # Welcome message in labels label2 = Label(root, text="Hej!\n Nu ska vi lösa lite matteproblem!") label2.config(font=('times', 18, 'bold'), fg='black', bg='white') label2.grid(row=0, column=0) #Instructions how to play in labels label3 = Label(root, text="Instruktioner!\n För att starta ett spel tryck på nyttspel") label3.config(font=('times', 12, 'bold'), fg='black', bg='white') label3.grid(row=2, column=2) #other label label1 = Label(root) label1.grid(row=2, column=0) # entry widget for the start button entry1 = Entry(root) entry1.grid(row=3, column=0) # restart gives a new question entry1.bind('', func=lambda e:checkAnswer()) #Buttons fragaBtn = Button(root, text='Nytt tal', command=fraga1) fragaBtn.grid(row=4, column=0) svarButton = Button(root, text='Svar', command=svar1) svarButton.grid(row=4, column=1) quit_bttn = Button(root, text = "Avsluta", command=quit) quit_bttn.grid(row=5, column=0) root.mainloop()
Python timer in math game Tkinter
1.2
0
0
3,643
17,569,007
2013-07-10T11:03:00.000
0
0
0
0
python,user-interface,python-2.7,timer,tkinter
39,337,514
5
false
0
1
Use a global variable storing current time when person presses start. Then when the user presses svar in your function svar, just fetch current time, substract them from one another and you get time taken, then reset the global var to 0 also and voila, you have the time taken
2
4
0
I'm looking to add a timer for my simple math game. So far everything works just fine, the user gets questions when pressing the button and is given feedback on the answer. I want to add a timer for the user to see how much time it takes to answer the multiplication. This is the final part of my prototype to this mathgame. I want the timer to start when the user clicks "nytt tal" which means new number in swedish, and to stopp when the user clicks "svar" which means answer in swedish. Here is my code. from Tkinter import * import tkMessageBox import random import time import sys # Definition for the question asked to user def fraga1(): global num3 num3 = random.randint(1, 10) global num4 num4 = random.randint(1, 10) global svar1 svar1 = num3 * num4 label1.config(text='Vad blir ' + str(num3) + '*' + str(num4) + '?') entry1.focus_set() #The answer giving feedback based on answer def svar1(): mainAnswer = entry1.get() if len(mainAnswer) == 0: tkMessageBox.showwarning(message='Skriv in några nummer!') return if int(mainAnswer) != svar1: tkMessageBox.showwarning(message='Tyvärr det rätta svaret: ' + str(svar1)) else: tkMessageBox.showinfo(message='RÄTT!! :)') #The quit button definition def quit(): global root root.destroy() #Definition for the timer this part doesnt work def start(): global count_flag fraga1() count_flag = True count = 0.0 while True: if count_flag == False: break label['text'] = str(count) time.sleep(0.1) root.update() count += 0.1 #Window code root = Tk() root.title("multiplikations tidtagning") root.geometry('800x500') count_flag = True # Welcome message in labels label2 = Label(root, text="Hej!\n Nu ska vi lösa lite matteproblem!") label2.config(font=('times', 18, 'bold'), fg='black', bg='white') label2.grid(row=0, column=0) #Instructions how to play in labels label3 = Label(root, text="Instruktioner!\n För att starta ett spel tryck på nyttspel") label3.config(font=('times', 12, 'bold'), fg='black', bg='white') label3.grid(row=2, column=2) #other label label1 = Label(root) label1.grid(row=2, column=0) # entry widget for the start button entry1 = Entry(root) entry1.grid(row=3, column=0) # restart gives a new question entry1.bind('', func=lambda e:checkAnswer()) #Buttons fragaBtn = Button(root, text='Nytt tal', command=fraga1) fragaBtn.grid(row=4, column=0) svarButton = Button(root, text='Svar', command=svar1) svarButton.grid(row=4, column=1) quit_bttn = Button(root, text = "Avsluta", command=quit) quit_bttn.grid(row=5, column=0) root.mainloop()
Python timer in math game Tkinter
0
0
0
3,643
17,569,671
2013-07-07T17:45:00.000
0
0
0
0
system,qpython
31,173,913
3
false
0
1
Install the latest from the Google Play store. I'm not getting this error using QPython (classic, not QPython3).
1
2
0
Install QPython from Google Play store Open QPython, slide right and click "Console" Try some code, starting with import androidhelper u0_a98@android:/ $ python Python 2.7.2 (default, Jun 3 2013, 20:01:13) [GCC 4.4.3] on darwin Type "help", "copyright", "credits" or "license" for more information. import androidhelper Traceback (most recent call last): File "", line 1, in File "/storage/sdcard0/com.hipipal.qpyplus/lib/site-packages/androidhelper.py", line 43, in import sl4a ImportError: No module named sl4a I'm running Cyanogenmod 10.0.0, Android 4.1.2. Any idea how to import androidhelper successfully?
Why does qpython say "No module named sl4a"?
0
0
0
3,999
17,571,438
2013-07-10T13:06:00.000
5
1
1
0
python,pytest
66,893,962
11
false
0
0
It's important to keep in mind, while trying to fix pytest ordering "issue", that running tests in the same order as they are specified seems to be the default behavior of pytest. It turns out that my tests were out of that order because of one of these packages - pytest-dependency, pytest-depends, pytest-order. Once I uninstalled them all with pip uninstall package_name, the problem was gone. Looks like they have side effects
2
71
0
I am using pytest. I have two files in a directory. In one of the files there is a long running test case that generates some output. In the other file there is a test case that reads that output. How can I ensure the proper execution order of the two test cases? Is there any alternative other than puting the test cases in the same file in the proper order?
Test case execution order in pytest
0.090659
0
0
68,944
17,571,438
2013-07-10T13:06:00.000
-7
1
1
0
python,pytest
55,065,859
11
false
0
0
Make Sure you have installed pytest-ordering package. To confirm go to Pycharm settings>>Project Interpreter >> and look for pytest-ordering : If it is not available install it. Pycharm settings>>Project Interpreter >> Click on + button and search pytest-ordering install it. Voila!! It will definitely work.
2
71
0
I am using pytest. I have two files in a directory. In one of the files there is a long running test case that generates some output. In the other file there is a test case that reads that output. How can I ensure the proper execution order of the two test cases? Is there any alternative other than puting the test cases in the same file in the proper order?
Test case execution order in pytest
-1
0
0
68,944
17,574,547
2013-07-10T15:19:00.000
2
1
0
0
python,cuda,pycuda,mailing-list
17,581,063
1
false
0
0
One reason would be that Pycuda is compiling the kernel before uploading it. As far as I remember thought that should happen only the very first time it executes it. One solution could be to "warm up" the kernel by executing it once and then start the profiling procedure.
1
1
1
I have a working conjungate gradient method implementation in pycuda, that I want to optimize. It uses a self written matrix-vector-multiplication and the pycuda-native gpuarray.dot and gpuarray.mul_add functions Profiling the program with kernprof.py/line_profiler returned most time (>60%) till convergence spend in one gpuarray.dot() call. (About .2 seconds) All following calls of gpuarray.dot() take about 7 microseconds. All calls have the same type of input vectors (size: 400 doubles) Is there any reason why? I mean in the end it's just a constant, but it is making the profiling difficult. I wanted to ask the question at the pycuda mailing list. However I wasn't able to subscribe with an @gmail.com adress. If anyone has either an explanation for the strange .dot() behavior or my inability to subscribe to that mailing list please give me a hint ;)
pycuda.gpuarray.dot() very slow at first call
0.379949
0
0
748
17,577,137
2013-07-10T17:29:00.000
0
0
1
0
python,file
48,249,781
4
false
0
0
I, as well as other persons in this thread, are left with the question, "Well what is finally true?" Now, supposing that files are left open in a premature program termination -- and there are a lot of such cases besides exceptions due to file handling -- the only safe way to avoid this, is to read the whole (or part of the) file into a buffer and close it. Then handle the contents in the buffer as needed. This is esp. the case for global search, changes, etc. that have to be done on the file. After changes are done, one can then write the whole buffer to the same or other file at once, avoiding the risk to leave the the newly created file open -- by doing a lot readings and writings -- which is the worst case of all!
1
32
0
Do open files (and other resources) get automatically closed when the script exits due to an exception? I'm wondering if I need to be closing my resources during my exception handling. EDIT: to be more specific, I am creating a simple log file in my script. I want to know if I need to be concerned about closing the log file explicitly in the case of exceptions. since my script has a complex, nested, try/except blocks, doing so is somewhat complicated, so if python, CLIB, or the OS is going to close my text file when the script crashes/errors out, I don't want to waste too much time on making sure the file gets closed. If there is a part in Python manual that talks about this, please refer me to it, but I could not find it.
Do files get closed during an exception exit?
0
0
0
19,923
17,578,253
2013-07-10T18:29:00.000
0
0
0
0
javascript,python,html
17,578,385
3
false
1
0
Although your question isn't very clear. I'm guessing that you are trying to access the javascript console. In Google Chrome: Press F12 Go to the 'console' tab In Mozilla Firefox with Firebug installed: Open Firebug Go to the 'console' tab From the console you can execute javascript query's (calling functions, accessing variables etc.). I hope this answered your question properly.
1
1
0
I'm not exactly sure how to phrase my question but I'll give it my best shot. If I load up a webpage, in the HTML it executes a JavaScript file. And if I view the page source I can see the source of that JavaScript (though it's not very well formatted and hard to understand). Is there a way to run the JavaScript from e.g. Python code, without going through the browser? i.e if I wanted to access a particular function in that JavaScript, is there a clean way to call just that from a Python script, and read the results? For example... a webpage displays a number that I want access to. It's not in the page source because it's a result from a JavaScript call. Is there a way to call that JavaScript from Python?
Can I scrape data from web pages when the data comes from JavaScript?
0
0
1
119
17,578,630
2013-07-10T18:49:00.000
0
0
1
0
python,mysql,database,multithreading
17,578,684
1
false
0
0
How should I deal with the database connection? Create it in main, then pass it to the logging thread, or create it directly in the logging thread? I would perhaps configure your logging component with the class that creates the connection and let your logging component request it. This is called dependency injection, and makes life easier in terms of testing e.g. you can mock this out later. If the logging component created the connections itself, then testing the logging component in a standalone fashion would be difficult. By injecting a component that handles these, you can make a mock that returns dummies upon request, or one that provides connection pooling (and so on). How you handle database issues robustly depends upon what you want to happen. Firstly make your database interactions transactional (and consequently atomic). Now, do you want your logger component to bring your system to a halt whilst it retries a write. Do you want it to buffer writes up and try out-of-band (i.e. on another thread) ? Is it mission critical to write this or can you afford to lose data (e.g. abandon a bad write). I've not provided any specific answers here, since there are so many options depending upon your requirements. The above details a few possible options.
1
1
0
I've got a fairly simple Python program as outlined below: It has 2 threads plus the main thread. One of the threads collects some data and puts it on a Queue. The second thread takes stuff off the queue and logs it. Right now it's just printing out the stuff from the queue, but I'm working on adding it to a local MySQL database. This is a process that needs to run for a long time (at least a few months). How should I deal with the database connection? Create it in main, then pass it to the logging thread, or create it directly in the logging thread? And how do I handle unexpected situations with the DB connection (interrupted, MySQL server crashes, etc) in a robust manner?
Architechture of multi-threaded program using database
0
1
0
84
17,578,668
2013-07-10T18:51:00.000
1
0
1
0
python,python-2.7
17,578,834
3
true
0
0
You can read the file line by line. For each line you can then eval it, or use json.loads to unpack it.
1
0
0
I have wrote a list in to a file, how can i get it back as old array list. list looks like this ['82294', 'ABDUL', 'NAVAS', 'B', 'M', 'MSCS', 'CUKE', '30', 'Kasargod', 'CU', 'Kerala', 'Online', 'PG-QS-12', '15', 'June,', '2013', '12.00', 'Noon', '-', '02.00', 'PM\n', '29'] ['82262', 'ABDUL', 'SHAFWAN', 'T', 'H', 'MSCS', 'CUKE', '30', 'Kasargod', 'CU', 'Kerala', 'Online', 'PG-QS-12', '15', 'June,', '2013', '12.00', 'Noon', '-', '02.00', 'PM\n', '29'] when i read the file, it does consider as a string list, for eg: consider first list: var[0][0] should be 82294 not ' i am a python noob,
Get array list from file
1.2
0
0
161