Q_CreationDate
stringlengths
23
23
Title
stringlengths
11
149
Question
stringlengths
25
6.53k
Answer
stringlengths
15
5.1k
Score
float64
-1
1.2
Is_accepted
bool
2 classes
N_answers
int64
1
17
Q_Id
int64
0
6.76k
2013-06-28 11:53:34.140
Django Dynamic Scraper Project does not run on windows even though it works on Linux
I am trying to make a project in dynamic django scraper. I have tested it on linux and it runs properly. When I try to run the command: syndb i get this error /*****************************************************************************************************************************/ python : WindowsError: [Error 3] ...
Step # 1 download django-dynamic-scraper-0.3.0-py2.7.tar.gz file Step # 2 Unzip it and change the name of the folder to: django-dynamic-scraper-0.3.0-py2.7.egg Step # 3 paste the folder into C:\Python27\Lib\site-packages
0
false
1
2,622
2013-06-28 14:05:42.840
Celery Logs into file
Can someone please help and tell me how to get the celery task debug details to a log file? I have a requirement to have the details of celery task logged into a .log file. Can you please make some suggestions on how this can be done without impacting the performance of the task?
If you want to log everything, you can use the following command -f celery.logs You can also specify different log levels as well. For suppose if you want log warning and errors add like following. --loglevel=warning -f celery.logs
0.999909
false
1
2,623
2013-06-29 02:14:37.223
is there a way to synchronize write to a file among different processes (not threads)
My project requires being run on several different physical machines, which have shared file system among them. One problem arising out of this is how to synchronize write to a common single file. With threads, that can be easily achieved with locks, however my program consists of processes distributed on different mac...
Just a thought... Couldn't you put a 'lock' file in the same directory as the file your trying to write to? In your distributed processes check for this lock file. If it exists sleep for x amount and try again. Likewise, when the process that currently has the file open finishes the process deletes the lock file? So...
0
false
1
2,624
2013-06-29 16:01:35.203
Python: Create and return an SQLite DB as a web request result
In my python/django based web application I want to export some (not all!) data from the app's SQLite database to a new SQLite database file and, in a web request, return that second SQLite file as a downloadable file. In other words: The user visits some view and, internally, a new SQLite DB file is created, populate...
I'm not sure you can get at the contents of a :memory: database to treat it as a file; a quick look through the SQLite documentation suggests that its API doesn't expose the :memory: database to you as a binary string, or a memory-mapped file, or any other way you could access it as a series of bytes. The only way to a...
1.2
true
1
2,625
2013-07-01 00:51:08.183
Canopy: Changing the way auto-completion works
I want to be able to customize auto-completion in canopy, so it behaves like sublime. Is it possible? And if so, where do i find the APIs?
Canopy currently doesn't expose the API to customize auto-completion. But, what exactly do you mean by making it behave like sublime?
0
false
1
2,626
2013-07-01 09:08:20.830
What does it mean when people say CPython is written in C?
From what I know, CPython programs are compiled into intermediate bytecode, which is executed by the virtual machine. Then how does one identify without knowing beforehand that CPython is written in C. Isn't there some common DNA for both which can be matched to identify this?
Python isn't written in C. Arguably, Python is written in an esoteric English dialect using BNF. However, all the following statements are true: Python is a language, consisting of a language specification and a bunch of standard modules Python source code is compiled to a bytecode representation this bytecode could i...
1.2
true
1
2,627
2013-07-01 20:21:54.750
starting a python 3.3. script at ubuntu startup
The standard python version of ubuntu 13.04 is python 2.7. I know that I can call a python script of version 3.3 by calling python3.3 or python3 in terminal instead of only "python", which starts the version 2.7... e.g. python3 myscript.py But now I have a version 3.3. script in the system start routine and can only te...
The shebang line #!/usr/bin/python3 should work if sh, bash, etc. is trying to launch your script. It it is being run from another script as python myscript.py you'll have to find that script and get it to launch the script using python3 myscripy.py
1.2
true
1
2,628
2013-07-01 22:44:46.690
How can I get Python to watch a USB port for any device?
On a windows OS, how can I get python to detect if anything is plugged in to a specific USB location on the computer. For example "Port_#0002.Hub_#0003" I've tried pyUSB which worked fine for detecting a specific device, but I couldn't seem to figure out how to just check a specific port/hub location for any kind of de...
What about polling? Create a Python app that enumerates a list of attached USB devices every couple of seconds or so. Keep a list/dictionary of your initially detected devices, and compare to that to determine what was attached/detached since your last polling iteration. This isn't the best approach, and enumerating a...
0
false
1
2,629
2013-07-02 10:37:12.083
Does database connection return to pool if a thread holding it dies?
I am using python 2.7 and Mysql. I am using multi-threading and giving connections to different threads by using PooledDB . I give db connections to different threads by pool.dedicated_connection().Now if a thread takes a connection from pool and dies due to some reason with closing it(ie. without returning it to the p...
No, it does not. You have to tell the server on the other side that the connection is closed, because it can't tell the difference between "going away" and "I haven't sent my next query yet" without an explicit signal from you. The connection can time out, of course, but it won't be closed or cleaned up without instru...
1.2
true
1
2,630
2013-07-03 11:26:54.530
How to create field through func in openerp?
Hi I have created a button oin my custom openerp module. I wanted to add func to this button to create a field. I have added the function but how to add functionality for creating fields . please help
You can create field on function, you have to create field in object 'ir.model.fields' if you are create simple field like float. char, boolean then you have to give value Field Name, Label, Model, for which object you want to create field , if many2one or many2many field then you have to give Object Relation field to....
0
false
1
2,631
2013-07-03 15:18:14.487
When using magic %paste in ipython, how can i get it to just paste the copied code, rather than paste and execute, so that it can be edited
When using magic %paste in ipython, it executes pasted code, rather than just pasting. How can i get it to just paste the copied code so that it can be edited?
There is a solution for this issue in ipython, if you are not concerned with indentation, Just run %autoindent to Automatic indentation OFF.
0.386912
false
2
2,632
2013-07-03 15:18:14.487
When using magic %paste in ipython, how can i get it to just paste the copied code, rather than paste and execute, so that it can be edited
When using magic %paste in ipython, it executes pasted code, rather than just pasting. How can i get it to just paste the copied code so that it can be edited?
You have two options: To edit it by hand, run %cpaste. Then you can paste it in with standard terminal options (try Ctrl-Shift-V), and edit it. Enter -- on a line to finish. To change it as text in your code, run %paste foo. It will store the clipboard contents in foo.
0.673066
false
2
2,632
2013-07-03 19:09:23.743
Python Matching License Plates
I am working on a traffic study and I have the following problem: I have a CSV file that contains time-stamps and license plate numbers of cars for a location and another CSV file that contains the same thing. I am trying to find matching license plates between the two files and then find the time difference between th...
What you're asking is about a fuzzy search, from what it sounds like. Instead of checking string equality, you can check if the two string being compared have a levenshtein distance of 1 or less. Levenshtein distance is basically a fancy way of saying how many insertions, deletions or changes will it take to get from...
0.101688
false
1
2,633
2013-07-03 20:24:11.953
Large training and testing data in libsvm
I'm using Libsvm in a 5x2 cross validation to classify a very huge amount of data, that is, I have 47k samples for training and 47k samples for testing in 10 different configurations. I usually use the Libsvm's script easy.py to classify the data, but it's taking so long, I've been waiting for results for more than 3 h...
easy.py is a script for training and evaluating a classifier. it does a metatraining for the SVM parameters with grid.py. in grid.py is a parameter "nr_local_worker" which is defining the mumber of threads. you might wish to increase it (check processor load).
0
false
1
2,634
2013-07-04 03:53:33.850
Semi-transparent 2d VTK text background
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 ...
just use vtktexture, vtkimagedata & add your own image as texture background to the vtkrenderer by reducing the opacity like a watermark. thats it
0
false
1
2,635
2013-07-04 11:38:38.650
after working in local server, how to move OpenERP on a remote server?
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 t...
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, includi...
1.2
true
1
2,636
2013-07-05 08:09:50.053
How to programatically validate WPA passphrase on Linux?
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. ...
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 i...
1.2
true
1
2,637
2013-07-05 10:23:42.123
How can you bundle all your python code into a single zip file?
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 thi...
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 ...
0.058243
false
1
2,638
2013-07-05 10:54:40.177
Python Server, Job Queue, Launch Multiprocessing Job
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
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.
0.201295
false
1
2,639
2013-07-06 20:49:07.663
How interoperability works
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 t...
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 ...
1.2
true
1
2,640
2013-07-07 10:26:31.007
Create a PyObject with attached functions and return to Python
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 attache...
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 c...
0.386912
false
1
2,641
2013-07-07 17:45:02.103
Why does qpython say "No module named sl4a"?
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 androidhelp...
Install the latest from the Google Play store. I'm not getting this error using QPython (classic, not QPython3).
0
false
1
2,642
2013-07-08 01:16:15.657
Changing Tkinter Screen when button is clicked?
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!
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.
0
false
1
2,643
2013-07-08 08:53:44.820
Object-oriented scientific data processing, how to cleverly fit data, analysis and visualization in objects?
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...
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 lang...
1.2
true
1
2,644
2013-07-08 18:02:01.633
Installing a package to Canopy
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 installat...
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
0.240117
false
1
2,645
2013-07-08 20:18:09.990
Scroll bar problems
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?
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(You...
1.2
true
1
2,646
2013-07-08 21:36:35.510
How can i reduce memory usage of Scikit-Learn Vectorizers?
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 Corpu...
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.
0.201295
false
1
2,647
2013-07-09 03:31:21.223
How to insert a table inside a frame?
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.
The wxpython demo is full of examples of all differant controls.
0
false
2
2,648
2013-07-09 03:31:21.223
How to insert a table inside a frame?
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.
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 nes...
0
false
2
2,648
2013-07-09 11:05:17.210
How to build python 3.3.2 with _bz2, _sqlite and _ssl from source
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 manageme...
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 ...
0
false
1
2,649
2013-07-09 13:20:50.313
How can I incorporate Python code in a mobile app?
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 ...
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 ...
0
false
1
2,650
2013-07-09 18:01:34.500
how to make a Qt text output widget?
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 ...
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.2
true
1
2,651
2013-07-09 23:24:20.163
how do I track how many users visit my website
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?
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.
0.470104
false
1
2,652
2013-07-10 00:43:01.907
python: how to find consecutive pairs of letters by regex?
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 wro...
For detecting 2-or-more consecutive letters the regex becomes: (\w)\1+
0.101688
false
1
2,653
2013-07-10 18:49:50.683
Architechture of multi-threaded program using database
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 MyS...
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 inject...
0
false
1
2,654
2013-07-10 18:51:44.473
Get array list from file
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...
You can read the file line by line. For each line you can then eval it, or use json.loads to unpack it.
1.2
true
1
2,655
2013-07-11 03:35:13.973
infinite error message python
I am in deep trouble at the moment. After every letter I type on my python command prompt in Linux, I get an error message: sys:1: GtkWarning: Attempting to store changes into `/u/rnayar/.recently-used.xbel', but failed: Failed to create file '/u/rnayar/.recently-used.xbel.L6ETZW': Too many open files Hence I can type...
Try opening and storing information from one file at a time? We dont have enough information to understand what is wrong with your code. We really dont have much more than "I tried to open 185 fits files" and "too many open files"
0
false
1
2,656
2013-07-11 05:49:04.430
How to detect the event when smart card scanned
I am working on smartcard based application with smartcard reader, here whenever I flash the card i should get the card UID, based on that I need to retrieve the details from database. For this need how do i start, whether i need to create service on windows which always run background or is there a way to detect an ev...
If you are using a USB or serial connection to connect your card reader to pc, .you can use datareceived event of Serial port class.
0
false
1
2,657
2013-07-11 13:44:28.150
Django runserver bound to 0.0.0.0, how can I get which IP took the request?
I'm running a temporary Django app on a host that has lots of IP addresses. When using manage.py runserver 0.0.0.0:5000, how can the code see which of the many IP addresses of the machine was the one actually hit by the request, if this is even possible? Or to put it another way: My host has IP addresses 10.0.0.1 and 1...
If your goal is to ensure the load balancer is working correctly, I suppose it's not an absolute requirement to do this in the application code. You can use a network packet analyzer that can listen on a specific interface (say, tcpdump -i <interface>) and look at the output.
0
false
1
2,658
2013-07-11 15:44:24.963
how to identify the type of files having no extension?
To do a work i want to identify the type of file. But the files are without extension.The files may be txt,jpeg,mp3,pdf etc. Using c or c++ or python how can i check whether it is a jpeg or pdf or mp3 file?
Some files, such as .exe, .jpg, .mp3, contain a header (first few bytes of the file). You can inspect the header and infer the file type from that. Of course, some files, such as raw text, depending on their encoding, may have no header at all.
0.201295
false
1
2,659
2013-07-12 02:35:20.123
Checking login status at every page load in CherryPy
I am in the midst of writing a web app in CherryPy. I have set it up so that it uses OpenID auth, and can successfully get user's ID/email address. I would like to have it set so that whenever a page loads, it checks to see if the user is logged in, and if so displays some information about their login. As I see it, t...
Nevermind, folks. Turns out that this isn't so bad to do; it is simply a matter of doing the following: Write a function that does what I want. Make the function in to a custom CherryPy Tool, set to the before_handler hook. Enable that tool globally in my config.
1.2
true
1
2,660
2013-07-13 05:51:32.860
Enable programmatic billing for Amazon AWS through API (python)
Was wondering if anyone knew how if it was possible to enable programmatic billing for Amazon AWS through the API? I have not found anything on this and I even went broader and looked for billing preferences or account settings through API and still had not luck. I assume the API does not have this functionality but ...
Currently, there is no API for doing this. You have to log into your billing preference page and set it up there. I agree that an API would be a great feature to add.
1.2
true
1
2,661
2013-07-14 06:52:44.200
Using a hash function as a key in a dictonary in python
I have a project I'm creating (in python 3.3) and I'm trying to figure out if there is a efficient (or prettier way) to do the following. I have a function that extracts binary/hex strings like the following (groups of bits are split for example purposes only) 0000 1111 0002 0001 0000 1111 0003 0001 0000 1111 0002 00...
Presumably you are actually using the bit values from the examples so why not just derive a dictionary from dictionary that has a new method getmasked which masks the value before looking it up...
0
false
1
2,662
2013-07-14 16:47:10.073
get image frames webcam from server with selenium python script
I need to take image frames from a webcam server using selenium python module. The frames webcam is show on the selenium browser ( using http:// .....html webpage) . The source code of the page show me it's done using some java script. I try to use: capture_network_traffic() and captureNetworkTraffic Not working , also...
First, what you'll need to do is navigate to the webpage with Selenium. Then, analyse the web page source HTML which the Javascript will have rendered by you navigating to the page, to get the image URL. You can do this with Selenium or with an HTML parser. Then you can easily download the image using wget or some othe...
1.2
true
1
2,663
2013-07-15 03:16:05.420
Python Send to and figure out POST
Recently, I've been attempting to figure out how I can find out what an unlabeled POST is, and send to it using Python. The issue of the matter is I'm attempting to make a chat bot entirely in Python in order to increase my knowledge of the language. For said bot, I'm attempting to use a chat-box that runs entirely on...
You need a server in order to be able to receive any GET and POST requests, one of the easier ways to get that is to set up a Django project, ready in minutes and then add custom views to handle the request you want properly.
0
false
1
2,664
2013-07-15 04:31:37.233
the idea behind chat website
I've been learning about Python socket, http request/reponse handling these days, I'm still very novice to server programming, I have a question regarding to the fundamental idea behind chatting website. In chatting website, like Omegle or Facebook's chat, how do 2 guys talk to each other? Do sockets on their own compu...
Most chats will use a push notification system. It will keep track of people within a chat, and as it receives a new message to the chat, it will push it to all the people currently in it. This protects the users from seeing each other.
0
false
2
2,665
2013-07-15 04:31:37.233
the idea behind chat website
I've been learning about Python socket, http request/reponse handling these days, I'm still very novice to server programming, I have a question regarding to the fundamental idea behind chatting website. In chatting website, like Omegle or Facebook's chat, how do 2 guys talk to each other? Do sockets on their own compu...
Usually they both connect to the server. There are a few reasons to do it this way. For example, imagine you want your users to see the last 10 messages of a conversation. Who's going to store this info? One client? Both? What happens if they use more than one PC/device? What happens if one of them is offline? Well, yo...
1.2
true
2
2,665
2013-07-15 19:54:33.090
Gathering information from few forms in django
I am creating simple search engine, so I have one input text field on the top of the page and buttom "search" next to it. That is all in one form, and "produce" for instance/q=search%20query. In sidebar I have panel with another form with filters, lets say from, to. I want to have a possibility of creating link like /q...
I just come up with an idea, that I can create in first form additional hidden fields, which can be synchronized with fields from second form by JavaScript. This will create small redundancy, however seems to be very easy to implement. Is it a good idea?
0
false
1
2,666
2013-07-15 21:56:21.440
how to get a part from a string with regular expression in python
A string "forum/123/topic/4567". How can I edit a regular expression to get '123' and '4567' separately? I have tried lots of methods on the Internet, but nothing works.
If you want just the numbers use r'0-9+'. That will give you separated sequences of integers from the input string.
0
false
1
2,667
2013-07-15 23:01:11.503
Releasing a python package - should you include doc and tests?
So, I've released a small library on pypi, more as an exercise (to "see how it's done") than anything else. I've uploaded the documentation on readthedocs, and I have a test suite in my git repo. Since I figure anyone who might be interested in running the test will probably just clone the repo, and the doc is already ...
It is not required but recommended to include documentation as well as unit tests into the package. Regarding documentation: Old-fashioned or better to say old-school source releases of open source software contain documentation, this is a (de facto?) standard (have a look at GNU software, for example). Documentation i...
0.999909
false
1
2,668
2013-07-16 04:11:27.010
DSTAT as a Python API ?
Is it possible, on a linux box, to import dstat and use it as an api to collect OS metrics and then compute stats on them? I have downloaded the source and tried to collect some metrics, but the program seems to be optimized for command line usage. Any suggestions as to how to get my desired functionality either usin...
The Dstat source-code includes a few sample programs using Dstat as a library.
0.673066
false
1
2,669
2013-07-16 12:05:49.523
How to write a command line program which can be accessed by a separate frontend?
I've been writing command line applications (mainly in Python) for quite a while now, and I've also been doing a bit of GUI programming using (Py)Qt. In the GUI program's I've written, the programs logic and the GUI were often quite integrated. I am now wondering however, how I could write a GUI front end, for the pure...
A simple, probably naïve way could be to structure your CLI program such that its main function accepts your command line arguments, so that you could import it and call it with the options set in the GUI. I've never tried it, my guess is that it could work with simple "pure" CLI programs (ie, you run it, it does its j...
0
false
1
2,670
2013-07-16 14:00:21.490
Trying to send an EOF signal (Ctrl+D) signal using Python via Popen()
I'm trying to get Python to send the EOF signal (Ctrl+D) via Popen(). Unfortunately, I can't find any kind of reference for Popen() signals on *nix-like systems. Does anyone here know how to send an EOF signal like this? Also, is there any reference of acceptable signals to be sent?
EOF isn't really a signal that you can raise, it's a per-channel exceptional condition. (Pressing Ctrl+D to signal end of interactive input is actually a function of the terminal driver. When you press this key combination at the beginning of a new line, the terminal driver tells the OS kernel that there's no further i...
1.2
true
1
2,671
2013-07-16 21:04:26.767
Do I need to SSH into EC2 instance in order to start custom script with arguments, or there are some service that I don't know
I need to create an application that will do the following: Accept request via messaging system ( Done ) Process request and determine what script and what type of instance is required for the job ( Done ) Launch an EC2 instance Upload custom script's (probably from github or may be S3 bucket) Launch a script with a ...
You can use knife-bootstrap. This can be one way to do it. You can use AWS SDK to do most of it Launch an instance Add a public IP (if its not in VPC) Wait for instance to come back online use knife bootstrap to supply script, setup chef-client, update system Then use chef cookbook to setup your machine
0.201295
false
1
2,672
2013-07-17 20:01:46.113
python program structure and use of global variables
I have a program completed that does the following: 1)Reads formatted data (a sequence of numbers and associated labels) from serial port in real time. 2)Does minor manipulations to data. 3)plots data in real time in a gui I wrote using pyqt. 4)Updates data stats in the gui. 5)Allows post analysis of the data after col...
A reasonably good rule of thumb is that if what you are doing needs more than 20 lines of code it is worth considering using an object oriented design rather than global variables, and if you get to 100 lines you should already be using classes. The purists will probably say never use globals but IMHO for a simple lin...
0.673066
false
1
2,673
2013-07-17 20:37:46.960
how make a datetime object in year 0 with python
Exactly what the title says. If I try to it gives me a ValueError for the year value but I'd like to have a datetime with year 0. Is there any way to do this?
I don't think there is any way to do this. datetime.datetime.min says 1 is the min value for year.
0
false
2
2,674
2013-07-17 20:37:46.960
how make a datetime object in year 0 with python
Exactly what the title says. If I try to it gives me a ValueError for the year value but I'd like to have a datetime with year 0. Is there any way to do this?
from the docs The datetime module exports the following constants: datetime.MINYEAR The smallest year number allowed in a date or datetime object. MINYEAR is 1. datetime.MAXYEAR The largest year number allowed in a date or datetime object. MAXYEAR is 9999.
0.673066
false
2
2,674
2013-07-17 21:53:40.627
Concurrent Remote Procedure Calls to C++ Object
I would like to have a class written in C++ that acts as a remote procedure call server. I have a large (over a gigabyte) file that I parse, reading in parameters to instantiate objects which I then store in a std::map. I would like the RPC server to listen for calls from a client, take the parameters passed from the ...
Maybe factors can affect the selection. One solution is to use fastcgi. Client sends HTTP request to HTTP server that has fastCGI enabled. HTP server dispatch the request to your RPC server via the fastcgi mechanism. RPC server process and generates response, and sends back to http server. http server sends the respons...
0
false
1
2,675
2013-07-18 00:38:34.563
Import a list from a different file
Is there a way I can import a list from a different Python file? For example if I have a list: list1 = ['horses', 'sheep', 'cows', 'chickens', 'dog'] Can I import this list into other files? I know to import other functions you do from FileName import DefName This is a user defined list and I don't want to have the u...
I'll just export the lists in a file. Therefore every piece of code can read it.
1.2
true
2
2,676
2013-07-18 00:38:34.563
Import a list from a different file
Is there a way I can import a list from a different Python file? For example if I have a list: list1 = ['horses', 'sheep', 'cows', 'chickens', 'dog'] Can I import this list into other files? I know to import other functions you do from FileName import DefName This is a user defined list and I don't want to have the u...
One option is to dump that list into a temp file, and read it from your other python script. Another option (if one python script calls the other), is to pass the list as an argument (e.g. using sys.argv[1] and *args, etc).
0
false
2
2,676
2013-07-18 08:33:07.277
Determine free RAM in Python
I would like my python script to use all the free RAM available but no more (for efficiency reasons). I can control this by reading in only a limited amount of data but I need to know how much RAM is free at run-time to get this right. It will be run on a variety of Linux systems. Is it possible to determine the free...
You could just read out /proc/meminfo. Be aware that the "free memory" is usually quite low, as the OS heavily uses free, unused memory for caching. Also, it's best if you don't try to outsmart your OS's memory management. That usually just ends in tears (or slower programs). Better just take the RAM you need. If you w...
1.2
true
1
2,677
2013-07-18 17:38:35.663
Is it possible to generate reports with dynamic columns in OpenERP?
I need to understand if it is possible to create reports with X number of columns. X will come from the amenities a hotel have for example. So it will change depending on the hotel selected from a wizard before generating the report. Lets say Hotel XYZ has 5 amenities I need a report with 5 columns where I will show th...
I hope you can use webkit reporting. Any other openerp reporting tools have its limitations for creating dynamic columns.
0
false
1
2,678
2013-07-18 18:55:40.403
Possible to copy/paste from IPython Notebook to other apps?
I'm new to Ipython Notebook. I can cut and paste from other apps into my notebooks, but how do I copy/paste code out of notebook into a different app? I'm accessing a Linux VNC session via Chicken. I can cut/paste with wild abandon between OSX/Linux using both command X/C/V and/or middle mouse button. I can also cop...
You have to select and copy code using normal Ctrl-C Ctrl-V. 'Edit/Copy Cell' is a specific action in javascript that does a little more and that browser security policy prevent us to bind with clipboard.
1.2
true
1
2,679
2013-07-19 21:15:23.070
Can I limit write access of a program to a certain directory in osx? Also set maximum size of the directory and memory allocated
I am writing code with python that might run wild and do unexpected things. These might include trying to save very large arrays to disk and trying to allocate huge amounts of memory for arrays (more than is physically available on the system). I want to run the code in a constrained environment in Mac OSX 10.7.5 with ...
import os stats = os.stat('possibly_big_file.txt') if (stats.st_size > TOOBIG): print "Oh no....."
0
false
1
2,680
2013-07-20 02:21:44.493
how to deploy apps developed in virtual env
I have a flask based app, and it's now running with virtualenv on my dev machine. Now I want to deploy it to my virtual host. Sadly, this virtual host is running flask 0.6, and I want flask 0.10. I don't have enough privilege to upgrade it. Can I just upload my whole virtual environment, and to use my own version of f...
Uploading your virtualenv probably won't work. There is a good chance that something in the virtualenv is dependent on the exact file paths and versions that won't match from your machine to the virtual host. You can upload the virtualenv tool, make a new virtualenv, and then install the version of flask you want insi...
0
false
1
2,681
2013-07-20 11:51:49.347
Implementing Universal Search in a Django Application
We have a large Django application made up of a large number of different views (some of which contain forms). As with most large applications, we use a base layout template that contains the common layout elements across the applications (mainly a header and a footer), which the templates for all of our views extend....
It seems like you just need to create another SearchView which takes the query and displays the results. I am not sure if the results have to be displayed differently depending on which page the search has been performed from but it does not seem like. The form would not have anything to do with the other views. Yo...
0
false
1
2,682
2013-07-20 23:09:20.597
How to setup the Mac terminal for Programming with Python?
I would like to know from you guys how you have set up your Mac terminal for python programming. I havent done anything big so far (have used ide's until now) with python in terminal but I think that you can do all kinds of fancy things (automatic fill up functions, colors, ...). Any suggestions?? Thanks you guys!
Assuming that Python is already on your computer: Go to /Applications folder Then open Utilities Double Click Terminal to open it and get a command line type 'python' in the command prompt Your all set!
1.2
true
1
2,683
2013-07-22 03:04:16.567
Un-normalized Gaussian curve on histogram
I have data which is of the gaussian form when plotted as histogram. I want to plot a gaussian curve on top of the histogram to see how good the data is. I am using pyplot from matplotlib. Also I do NOT want to normalize the histogram. I can do the normed fit, but I am looking for an Un-normalized fit. Does anyone here...
Another way of doing this is to find the normalized fit and multiply the normal distribution with (bin_width*total length of data) this will un-normalize your normal distribution
0.386912
false
1
2,684
2013-07-22 05:02:26.440
how to make dynamic field creation capability in openerp module?
Hi I have created an openerp module using Python (eclipse) . I want to add a feature in my form so that admin will be able to create his own fields whenever and whatever he wants . I needed some guidance of how this will be done . As I am new to openerp , any help will be good to me . Thanks Hopes for advice
I can't think of any easy way of doing this. When OpenERP connects to a database it sets up a registry containing all models and all the fields and as part of this, loads the fields into the database, performs database refactoring etc. The idea is that it is simple to inherit existing models and add your fields that ...
0
false
1
2,685
2013-07-22 09:01:26.800
Constraints on fitting parameters with Python and ODRPACK
I'm using the ODRPACK library in Python to fit some 1d data. It works quite well, but I have one question: is there any possibility to make constraints on the fitting parameters? For example if I have a model y = a * x + b and for physical reasons parameter a can by only in range (-1, 1). I've found that such constrain...
I'm afraid that the older FORTRAN-77 version of ODRPACK wrapped by scipy.odr does not incorporate constraints. ODRPACK95 is a later extension of the original ODRPACK library that predates the scipy.odr wrappers, and it is unclear that we could legally include it in scipy. There is no explicit licensing information for ...
1.2
true
1
2,686
2013-07-24 03:07:45.647
Websocket connection between two servers
Im using python tornado as web server and I have a backend server and a frontend server. I want to create browser-frontend-backend connection. Can anyone help me how to do this? I know how to create websocket connection between frontend and browser but I have no idea how to connect my frontend server to backend server...
WebSocket was designed for low-latency bidirectional browser<->service communication. It's placed on top of TCP/IP and brings along some overhead. It was designed to solve all the problems that you simply do not have when it's about front-end<->back-end communication, because there we're talking about a defined environ...
0
false
1
2,687
2013-07-24 11:40:07.833
Edit a file outside the web root
I have developed a python desktop application and application itself having setup page to change some configurations in the application and it is saved as a configuration file. Now I need do to give web interface to change those configurations by using web browser remotely. But I need to change the same configuration f...
Probably by bind mounts (assuming Linux), so that the file is in it's original location as well as in the web root. Or by priviledge separation. The web root sends a query to some worker job, that has access to all the needed files.
1.2
true
1
2,688
2013-07-25 19:50:21.123
How to stop a running program on PyDev
I am afraid that my question may be duplicate, but I could not find good answers for my question in stackoverflow. I use PyDev under Eclipse. And I often run my programs by opening a Python Console (Ctrl+Alt+Enter on the editor) for quick-and-easy debugging. The thing is I do not know how to stop the running program on...
Ctrl+Alt+F9 should terminate all launches, which will do the job for you.
0.386912
false
1
2,689
2013-07-26 12:53:53.883
move a stereoscopic video on the screen
I would like to move a (stereoscopic) video on a computer screen automatically. Think of the video as the ball in a Pong game. The problem is that it should be a stereoscopic 3D video. So the video size itself is kind of small. I did this kind of movements with pictures or drawing object, but I don't know how to do it ...
I'd try to use a decent video client (mplayer, vlc). They can present the video in lots of ways, hopefully your stereoscopic issue can be solved by them. Then I would let the client present a single window (not fullscreen) which I then would move around using window manager controls. If you must not have window decora...
0
false
1
2,690
2013-07-26 14:47:51.247
Sublime text 2 snippets
Is there any way to access current scope (class name or function name) inside a snippet? I am trying to write a snippet for super(CurrentClassName, self).get(*args, **kwargs) but seems like I can't really replace CurrentClassName with actual class name. Does anyone know how to do that?
Sorry snippets are primarily meant for reusability; you can do precisely as you say above but cannot insert specific things - you would have to write your own plugin in order to add this functionality as it would require things like a specific way of selecting things to modify and replace which would be specific to it.
1.2
true
1
2,691
2013-07-26 18:15:32.070
Python Fabric config file (~/.fabricrc) is not used
I'm developing a task where I need to have a few pieces of information specific to the environment. I setup the ~/.fabricrc file but when I run the task via command line, the data is not in the env variable I don't really want to add the -c config to simplify the deployment. in the task, I'm calling env.cb_account a...
Overrode the "env" variable via parameter in the function. Dumb mistake.
0
false
1
2,692
2013-07-27 19:15:37.097
How do the for / while / print *things* work in python?
What i mean is, how is the syntax defined, i.e. how can i make my own constructs like these? I realise in a lot of languages, things like this will be built into the compiler / spec, and so it's dealt with by the compiler (at least that how i understand it to work). But with python, everything i've come across so far h...
while, print, for etc. are keywords. That means they are parsed by the python parser whilst reading the code, stripped any redundant characters and result in tokens. Afterwards a lexer takes those tokens as input and builds a program tree which is then excuted by the interpreter. Said so, those constructs are used only...
0.101688
false
1
2,693
2013-07-29 18:27:15.983
How to call a *.jsl script from python script
I have a python script running. I want to call *.jsl script in my running python script and want to make use of it's output in python. May I know how can I do that?
Make sure jmp.exe is available in your system environment so that if you type "jmp.exe" in the command line, it would launch jmp. Then have your *.jsl ready. use python procees to run this command "jmp.exe *.jsl" and that would open jmp and run the *.jsl script and then you can import whatever you generate from jmp bac...
0
false
1
2,694
2013-07-30 19:04:05.710
Bundling reads or caching collections with Pymongo
I'm currently running into an issue in integrating ElasticSearch and MongoDB. Essentially I need to convert a number of Mongo Documents into searchable documents matching my ElasticSearch query. That part is luckily trivial and taken care of. My problem though is that I need this to be fast. Faster than network time, I...
pymongo is thread safe, so you can run multiple queries in parallel. (I assume that you can somehow partition your document space.) Feed the results to a local Queue if processing the result needs to happen in a single thread.
0
false
1
2,695
2013-07-31 01:14:52.767
Making a 3 Colour FITS file using aplpy
I am trying to make a three colour FITS image using the $aplpy.make_rgb_image$ function. I use three separate FITS images in RGB to do so and am able to save a colour image in png, jpeg.... formats, but I would prefer to save its as a FITS file. When I try that I get the following error. IOError: FITS save handler n...
I don't think there is enough information for me to answer your question completely; for example, I don't know what call you are making to perform the "image" "save", but I can guess: FITS does not store RGB data like you wish it to. FITS can store multi-band data as individual monochromatic data layers in a multi-exte...
1.2
true
1
2,696
2013-07-31 01:42:49.017
Django-CMS Type Error "a float is required"
I'm deploying my first Django app on a BlueHost shared server. It is a simple site powered by Django-CMS, and portions of it are working, however there are some deal-breaking quirks. A main recurring one reads TypeError, a float is required. The exception location each time is .../python/lib/python2.7/site-packages/dj...
As I wondered, the problem was that I was accessing the site using my temporary link from BlueHost, which the function throwing the error could not handle. When my clients finally pointed their domain name at the server this problem and a few others (CSS inconsistencies in the Django admin, trouble with .htaccess) disa...
1.2
true
1
2,697
2013-07-31 04:00:19.577
PyQT treewidgets with different context menu options
i have 2 treewidgets placed in a frame in mainwindow. how can i have 2 different set of context menu options for the 2 treewidgets? i need individual set of right click options for the treewidgets.Thanks in advance..
Every QWidget has a contextMenuPolicy property which defines what to do when context menu is requested. A simpliest way to do what you need is like this: Create QAction objects that call methods you want. Add these actions to your tree widgets using widget.addAction() Call widget.setContextMenuPolicy(QtCore.Qt.Actions...
1.2
true
1
2,698
2013-08-01 03:42:55.880
What is the best way to track / record the current programming project u work on
I have been in this problem for long time and i want to know how its done in real / big companies project. Suppose i have the project to build a website. now i divide the project into sub tasks and do it. But u know that suppose i have task1 in hand like export the page to pdf. Now i spend 3 days to do that , came accr...
Every time you revisit code, make a list of the information you are not finding. Then the next time you create code, make sure that information is present. It can be in comments, Wiki, bugs or even text notes in a separate file. Make the notes useful for other people, so private notebooks aren't a good idea except for ...
0
false
1
2,699
2013-08-01 15:35:31.143
Python Multiprocessing Management
I'm fairly familiar with the python multiprocessing module, but I'm unsure of how to implement this setup. My project has this basic flow: request serial device -> gather response -> parse response -> assert response -> repeat It is right now a sequential operation that loops over this until it has gather the desired n...
Here's one way to implement your workflow: Have two multiprocessing.Queue objects: tasks_queue and results_queue. The tasks_queue will hold device outputs, and results_queue will hold results of the assertions. Have a pool of workers, where each worker pulls device output from tasks_queue, parses it, asserts, and puts...
0.201295
false
1
2,700
2013-08-02 05:45:24.023
Will the first source in PYTHONPATH always be searched first?
Will the sources in PYTHONPATH always be searched in the very same order as they are listed? Or may the order of them change somewhere? The specific case I'm wondering about is the view of PYTHONPATH before Python is started and if that differs to how Python actually uses it.
PYTHONPATH passed to sys.path there any module can modify it before importing another modules.
0
false
1
2,701
2013-08-02 17:04:08.050
Allowing python use modules from other python installation
I normally use python 2.7.3 traditionally installed in /usr/local/bin, but I needed to rebuild python 2.6.6 (which I did without using virtualenv) in another directory ~/usr/local/ and rebuild numpy, scipy, all libraries I needed different versions from what I had for python 2.7.3 there... But all the other packages th...
Reinstall them. It may seem like a no-brainer to reuse modules (in a lot of cases, you can), but in the case of modules that have compiled code - for long term systems administration this can be an utter nightmare. Consider supporting multiple versions of Python for multiple versions / architectures of Linux. Some modu...
1.2
true
1
2,702
2013-08-04 17:26:10.177
Python regexp: get all group's sequence
I have a regex like this '^(a|ab|1|2)+$' and want to get all sequence for this... for example for re.search(reg, 'ab1') I want to get ('ab','1') Equivalent result I can get with '^(a|ab|1|2)(a|ab|1|2)$' pattern, but I don't know how many blocks been matched with (pattern)+ Is this possible, and if yes - how?
I think you don't need regexpes for this problem, you need some recursial graph search function
0.265586
false
1
2,703
2013-08-04 22:45:26.173
How to add custom events to tornado
I have a tornado application that will serve data via websocket. I have a separate blocking thread which is reading input from another application and pushing an object into a Queue and another thread which has a blocking listener to that Queue. What I would like is for the reader thread to somehow send a message to to...
If I'm understanding your question correctly, all you need to do is call IOLoop.add_callback from the thread that is reading from the queue. This will run your callback in the IOLoop's thread so you can write your message out on the client websocket connections.
0.386912
false
1
2,704
2013-08-04 23:09:11.810
Should I use regex or just DOM/string manipulation?
Sometimes I am not sure when do I have to use one or another. I usually parse all sort of things with Python, but I would like to focus this question on HTML parsing. Personally I find DOM manipulation really useful when having to parse more than two regular elements (i.e. title and body of a list of news, for example)...
People shy away from doing regexes to search HTML because it isn't the right tool for the job when parsing tags. But everything should be considered on a case-by-case basis. You aren't searching for tags, you are searching for a well-defined string in a document. It seems to me the simplest solution is just a regex or ...
0.386912
false
1
2,705
2013-08-05 04:50:35.980
how to set name of a field dynamically in openerp?
Hi I am working on an openerp module . I want to make a field dynamically . I want to take a name of a field from user and then create a field to it . How this can be done ? Can I do it with fields.function to return name, char type ? Plz help
You can create Fields Dynamically by the help of class self.pool.get('ir.model.fields') Use Create Function.
0
false
2
2,706
2013-08-05 04:50:35.980
how to set name of a field dynamically in openerp?
Hi I am working on an openerp module . I want to make a field dynamically . I want to take a name of a field from user and then create a field to it . How this can be done ? Can I do it with fields.function to return name, char type ? Plz help
Do you mean you want a dynamic field on the form/tree view or in the model? If it is in the view then you override fields_view_get, call super and then process the returned XML for the form type you want adding in the field or manipulating the XML. ElementTree is your friend here. If you are talking about having a dyn...
0.386912
false
2
2,706
2013-08-05 18:34:41.497
How could i totally secure a connection between two nodes?
I'm building an authentication server in python and was wondering about how I could secure a connection totally between two peers totally? I cannot see how in any way a malicious user wouldn't be able to copy packets and simply analyze them if he understands what comes in which order. Admitting a client server schema. ...
What you are asking about is part of what's commonly called "key management." If you google the term, you'll find lots of interesting reading. You may well discover that there are other parts of key management that your solution needs to address, like revocation and rotation. In the particular part of key management ...
0.386912
false
1
2,707
2013-08-05 20:12:04.460
Using Python To Access E-mail (Lotus Notes)
Basically, I need to write a Python script that can download all of the attachment files in an e-mail, and then organize them based on their name. I am new to using Python to interact with other applications, so I was wondering if you had any pointers regarding this, mainly how to create a link to Lotus Notes (API)?
You can do this in LotusScript as an export of data. This could be an agent that walks down a view in Notes, selects a document, document attachments could be put into a directory. Then with those objects in the directory(ies) you can run any script you like like a shell script or whatever. With LotusScript you can gr...
0
false
1
2,708
2013-08-05 22:27:59.263
How do I manage metainformation in a horizontally scaled game server?
I apologize in advance for how long this explanation is, I don't know how to make it more concise because I imagine almost all of this is relevant. Sorry! I'm designing a game server in Python with Twisted (probably not relevant, as this is an architecture question). The general idea is that players connect and are pla...
There are many solutions to implement a shared database. It depends on your technology stack, network architecture, programming language(s), etc. This is too broad of a question to be answered in a few paragraphs. Pick one approach and go with it, but make your code modular enough to replace your approach with anoth...
0.386912
false
1
2,709
2013-08-05 23:48:51.413
how to avoid linebreakers from unicode string read from text file in python
How do I remove line breakers i.e. '\n' from a unicode text read from text file using python? Also, how do I test if values of a list is linebreaker or not in unicode string?
Unicode strings have the same methods as standard strings, you can remove '\n' with line.replace(r'\n','') and check if it exists with '\n' in unc
0
false
1
2,710
2013-08-06 11:48:43.437
How to either sort a wxsizer or remove items without destroying them?
I have a wxpython grid sizer that is sizing sublists of bitmap buttons. The master list I would like to create just once because creating these buttons takes a considerable amount of time, and thus I do not want to destroy them. My idea is to somehow remove all of the buttons from the sizer, make a new list of the but...
So I found out that the detach method is what I'm looking for! I would still be interested to know of a way to sort a sizer's item list though, without detaching all of the items and then re attaching a sublist.
0
false
3
2,711
2013-08-06 11:48:43.437
How to either sort a wxsizer or remove items without destroying them?
I have a wxpython grid sizer that is sizing sublists of bitmap buttons. The master list I would like to create just once because creating these buttons takes a considerable amount of time, and thus I do not want to destroy them. My idea is to somehow remove all of the buttons from the sizer, make a new list of the but...
You can't sort the sizer items in place. It would be possible to write your own function for doing this, of course, but it would use wxSizer::Detach() and Insert() under the hood anyhow.
1.2
true
3
2,711
2013-08-06 11:48:43.437
How to either sort a wxsizer or remove items without destroying them?
I have a wxpython grid sizer that is sizing sublists of bitmap buttons. The master list I would like to create just once because creating these buttons takes a considerable amount of time, and thus I do not want to destroy them. My idea is to somehow remove all of the buttons from the sizer, make a new list of the but...
You should be able to call the Layout method on the parent of the sizer, this will make it recalculate the shown items.
0
false
3
2,711
2013-08-06 20:14:57.490
Is there a way to store python objects directly in mongoDB without serializing them
I have read somewhere that you can store python objects (more specifically dictionaries) as binaries in MongoDB by using BSON. However right now I cannot find any any documentation related to this. Would anyone know how exactly this can be done?
Assuming you are not specifically interested in mongoDB, you are probably not looking for BSON. BSON is just a different serialization format compared to JSON, designed for more speed and space efficiency. On the other hand, pickle does more of a direct encoding of python objects. However, do your speed tests before yo...
0.591696
false
1
2,712
2013-08-06 20:40:05.783
How to install twistedweb python library on a web server
I have a small application written in python using TwistedWeb. It is a chat server. Everything is configured right now as for localhost. All I want is to run this python script on a server(shared server provided by Fatcow.com). I mean that the script will be working all the time and some clients will connect/disconnect...
I have contacted Fatcow.com support. They do not support SSH connections and do not support Python 2.7 with Twisted library, especially python socket application as server. So it is dead end. Question resolved.
1.2
true
1
2,713