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
9,864,493
2012-03-25T22:01:00.000
3
0
1
0
python,regex,regex-lookarounds
9,923,353
2
true
0
0
If you do bar(?=ber) on "barber", "bar" is matched, but "ber" is not captured.
1
5
0
Is there an ability to make a lookahead assertion non-capturing? Things like bar(?:!foo) and bar(?!:foo) do not work (Python).
regular expression matching a string that is followed with another string without capturing the latter
1.2
0
0
3,196
9,864,843
2012-03-25T23:01:00.000
2
0
0
0
python,qt,model,pyqt,pyqt4
9,864,880
1
true
0
1
Set the QTableModel as the model for each QListView, and use QListView.setModelColumn to choose which column they each display.
1
2
0
Salut, community! Briefly. I wrote usual model over QAbstractTableModel and using it in usual way for QTableView. But I think I need to use some columns of this model for the few QListViews in QWizard to fill main table in the right way (for user). For example: use the column2 as the QListView's model on the page1 of the wizard; column3 for page2 for its QListView etc. Please, help me to understand just two things: Am I on the right way? If yes then how can I make it simply and explicitly?
QAbstractTableModel as a model for one QTableView and few QListViews
1.2
0
0
371
9,866,104
2012-03-26T03:02:00.000
4
1
0
0
python,ruby,regex,email
9,866,851
2
false
1
0
I would look to a more non-technical solution. You could split out the 3500 names and post them to Amazon Mechanical Turk as a HIT, paying 1 cent for each. Then instead writing code to scrape Google, you write code to create the hits and let real people do the "scraping" of the company websites. Don't know if that will work for you but that's probably what I'd do. Hope that helps! Brandon
1
0
0
My boss has given me a list of around 3500 companies and wants the generic contact email for each of them by tomorrow. I know this sounds retarded, and it is, but our client is demanding it. The approach I'd like to take is this: Carry out a google search for company name Identify company website and redirect to it Step through website links to find a contact us / about us page Locate and return the first email address on the page I've done a bit of python here and there, but nothing web based or with regex... though I get the basic ideas I don't know if I would be able to execute this in the next 12 hours. If anyone has any help on how I could script this with python or ruby I would be very appreciative......
Extract company contact details from google
0.379949
0
0
1,967
9,866,319
2012-03-26T03:37:00.000
1
0
0
0
python,mysql
9,868,793
3
true
0
0
If autocommit is turned off in the reader as well, then it will be doing the reads inside a transaction and thus not seeing the writes the other script is doing.
2
2
0
I have a small issue(for lack of a better word) with MySQL db. I am using Python. So I have this table in which rows are inserted regularly. As regularly as 1 row /sec. I run two Python scripts together. One that simulates the insertion at 1 row/sec. I have also turned autocommit off and explicitly commit after some number of rows, say 10. The other script is a simple "SELECT count(*) ..." query on the table. This query doesn't show me the number of rows the table currently has. It is stubbornly stuck at whatever number of rows the table had initially when the script started running. I have even tried "SELECT SQL_NO_CACHE count(*) ..." to no effect. Any help would be appreciated.
Python MySQL- Queries are being unexpectedly cached
1.2
1
0
392
9,866,319
2012-03-26T03:37:00.000
0
0
0
0
python,mysql
9,867,231
3
false
0
0
My guess is that either the reader or writer (most likely the writer) is operating inside a transaction which hasn't been committed. Try ensuring that the writer is committing after each write, and try a ROLLBACK from the reader to make sure that it isn't inside a transaction either.
2
2
0
I have a small issue(for lack of a better word) with MySQL db. I am using Python. So I have this table in which rows are inserted regularly. As regularly as 1 row /sec. I run two Python scripts together. One that simulates the insertion at 1 row/sec. I have also turned autocommit off and explicitly commit after some number of rows, say 10. The other script is a simple "SELECT count(*) ..." query on the table. This query doesn't show me the number of rows the table currently has. It is stubbornly stuck at whatever number of rows the table had initially when the script started running. I have even tried "SELECT SQL_NO_CACHE count(*) ..." to no effect. Any help would be appreciated.
Python MySQL- Queries are being unexpectedly cached
0
1
0
392
9,868,711
2012-03-26T08:16:00.000
2
1
1
0
python,eclipse,pydev
13,807,754
4
false
0
0
On a Mac, I can get to the PyDev settings via: Eclipse β†’ Preferences β†’ PyDev (in tree) β†’ Editor (subtree) In my case, I wanted to change hash tag comments from nearly invisible grey to a better color. It worked like a charm.
2
12
0
In Eclipse, how can I change default font for Python code in the editor (PyDev plugin)? I navigate to menu Window β†’ Preference β†’ General β†’ Appearance β†’ Colors & Fonts, but I don't find which item would affect the Python code font.
How do I change the default font for Python code in Eclipse?
0.099668
0
0
16,217
9,868,711
2012-03-26T08:16:00.000
2
1
1
0
python,eclipse,pydev
9,883,196
4
false
0
0
Following the guidance of gecco, I found out the item in General β†’ Appearance β†’ Colors & Fonts which affects Python code fonts. It's Text Font in the Basic folder.
2
12
0
In Eclipse, how can I change default font for Python code in the editor (PyDev plugin)? I navigate to menu Window β†’ Preference β†’ General β†’ Appearance β†’ Colors & Fonts, but I don't find which item would affect the Python code font.
How do I change the default font for Python code in Eclipse?
0.099668
0
0
16,217
9,869,262
2012-03-26T09:01:00.000
2
0
0
0
python,plone,zope,zodb
9,869,343
4
false
0
0
Both werkzeug and paste provide ordereddicts. You could no doubt pickle them for your purposes.
1
3
0
I am doing some PloneFormGen work. Currently PloneFormGen stores entered form entries internally as tuples without associated column information. If new columns (form fields) are added then the existing data becomes invalid. This could be easily avoided storing data in ordered dictionaries, which retain both entered column order and column ids. Does ZODB have data type equivalent of ordered dictionary? If possible even with matching API (Python dict-like item manipulation and access)?
ZODB equivalent of ordered dict (odict?)
0.099668
0
0
676
9,871,108
2012-03-26T11:16:00.000
0
0
0
0
python,ajax,pyramid
12,723,197
2
true
1
0
I use long polling now and it seems like the best thing to use for me
1
0
0
I am trying to write a simple website. Here is the requirement. The site needs to be made with Pyramid web framework There needs to be a thread that contains 3 variables and the values of the variables will keep on changing. The site needs to pick these values up and display them without reloading the page. I know I need to use some form of AJAX. Please suggest me some ways to do this. Even links to some tutorials will be appreciated. Thanks
Variable value display without page reload
1.2
0
0
98
9,872,029
2012-03-26T12:22:00.000
1
0
0
1
python,google-app-engine,types
9,885,834
1
true
1
0
When browser renders html it thinks that <type 'str'> is a (unknown) tag, so it renders it as <type 'str'></type>, hence it becomes part of your page markup... You can see this with Firebug or any similar tool.
1
0
0
For debug use I want to show the type of a variable in Google App Engine. In traditional environment, I will use "print type( x )" to do it. But in GAE I just don't know why I can't use self.response.out.write( str( type( x ) ) ) to echo it in the browser. I got confused because I did transform the <type 'type'> to < type 'str' >. Since that doesn't work I have to use self.response.out.write( str( type( x) == type( "123" ) ) ) instead of directly echoing the type. So what did I miss in thinking? I am also using logging module to echo the type which works well. But I still want to know why self.response.out.write( ) doesn't work. Thanks all for help!!
how to show an object's type in google app engine
1.2
0
0
89
9,872,984
2012-03-26T13:25:00.000
2
0
0
0
combobox,wxpython
9,874,476
1
true
0
1
If you need to update a list in a combobox, use it's SetItems(myNewList) method. I would keep a dictionary of the various lists you need and use that to populate the second combobox based on the selection in the first.
1
0
0
Can someone give me some direction as to the proper control to use to update the items in a combobox if a certain item is selected in another combobox? Thanks.
What is the proper control for updating a combobox
1.2
0
0
119
9,873,626
2012-03-26T14:05:00.000
3
0
1
0
python,algorithm
9,873,885
5
false
0
0
Use a loop (int i=0; i < m; i++) Then to get the indexes you want, Ceil(i*m/n).
1
12
1
I have a vector/array of n elements. I want to choose m elements. The choices must be fair / deterministic -- equally many from each subsection. With m=10, n=20 it is easy: just take every second element. But how to do it in the general case? Do I have to calculate the LCD?
Choose m evenly spaced elements from a sequence of length n
0.119427
0
0
11,243
9,874,959
2012-03-26T15:26:00.000
2
0
0
1
python,django,google-app-engine
9,875,058
4
false
1
0
Google only allows you to send emails from a domain name that they control in the google app engine. So you will either have to send it from the test domain they give you, a gmail account, or you need to use their name servers for your domain name.
1
3
0
I have created one Django Application,also hosted it on the google app engine. I can send emails from django application, but after hosting it to app engine I cant do that.I really stuck with this problem, so please tell me if there is any solution for using django email functions in Google app engine. I have tried appengine_django but it not working. Django version 1.3.1 python version 2.6.5
How to send emails from django App in Google App Engine
0.099668
0
0
1,520
9,876,967
2012-03-26T17:40:00.000
3
0
0
1
python,qsub,sungridengine
15,344,911
8
false
0
0
This is SGE buffering the output of your process, it happens whether its a python process or any other. In general you can decrease or disable the buffering in SGE by changing it and recompiling. But its not a great thing to do, all that data is going to be slowly written to disk affecting your overall performance.
1
5
0
I have an SGE script to execute some python code, submitted to the queue using qsub. In the python script, I have a few print statements (updating me on the progress of the program). When I run the python script from the command line, the print statements are sent to stdout. For the sge script, I use the -o option to redirect the output to a file. However, it seems that the script will only send these to the file after the python script has completed running. This is annoying because (a) I can no longer see real time updates on the program and (b) if my job does not terminate correctly (for example if my job gets kicked off the queue) none of the updates are printed. How can I make sure that the script is writing to the file each time it I want to print something, as opposed to lumping it all together at the end?
SGE script: print to file during execution (not just at the end)?
0.07486
0
0
4,083
9,881,995
2012-03-27T01:00:00.000
1
0
1
0
python,osx-lion,python-imaging-library,macports
9,882,005
1
true
0
0
It is saying that Image is not a module. Either it doesn't exist or it isn't in Python's path or the directory in which your script is.
1
1
0
I just updated my OS from Snow Leopard to LION 10.7.3, and I usually run this python script using IDLE. However, when I try running it, I get this error.. Traceback (most recent call last): File "/Users/Brian/Desktop/BitmapBuilder.py", line 1, in import os, shutil, Image, brianutils, sys ImportError: No module named Image Any help would be much appreciated, thanks in advance!
Error in running my Python Script
1.2
0
0
157
9,884,022
2012-03-27T05:51:00.000
0
0
0
0
python,windows
9,896,301
1
true
0
0
Try running CellProfiler.py --help directly from the command line. This will work, if you've installed Python via the installer, which registers the .py file extension as executable, and therefore Windows searches in PATH if you try to execute one.
1
0
0
This seems to be a common problem, but I cant seem to fin a solution that works. My PATH is set with C:\Python26\Scripts;C:\Python26\Lib and PYTHONPATH is similarly set. Any suggestions would be very much appreciated. python CellProfiler.py --help python: cant open file 'CellProfiler.py': [Errno 2] No such file or directory.
Command Prompt cant open file in Python26\Scripts
1.2
0
0
296
9,884,132
2012-03-27T06:03:00.000
5
0
1
0
python,iterator,iteration,terminology,iterable
52,202,768
17
false
0
0
Iterables have a __iter__ method that instantiates a new iterator every time. Iterators implement a __next__ method that returns individual items, and a __iter__ method that returns self . Therefore, iterators are also iterable, but iterables are not iterators. Luciano Ramalho, Fluent Python.
1
528
0
What is the most basic definition of "iterable", "iterator" and "iteration" in Python? I have read multiple definitions but I am unable to identify the exact meaning as it still won't sink in. Can someone please help me with the 3 definitions in layman terms?
What exactly are iterator, iterable, and iteration?
0.058756
0
0
377,113
9,884,764
2012-03-27T07:02:00.000
3
0
1
0
python,console,ipython,metaclass
9,888,047
3
true
0
0
It's not done the way you're imagining. ipython reads your command prompt input as a line of text, so it has a chance to check if it ends with a question mark before it passes it on to eval (or whatever). If it does, it runs help(name) instead of what you typed. AST looks a little heavy-duty, but you can get a feel for how this works by checking out the module code. It gives you a lightweight interpreter that you can extend with syntax of this sort if you want.
2
3
0
So i was thinking that in order to implement such a feature in a console application , where appending a question mark at the end of a function name will pour out it's doc string , i would have probably used a feature like metaclasses , where upon definition/import , i'd duplicate all the module member names and produce new ones just for typing out doc strings. Then i noticed that you don't need actual parenthesis to call the helper functions and python doesn't actually allow you to put a question mark at the end of the function name anyway.... So is this done in python or am i just wasting my time trying to figure this out? Thanks in advance
how does IPython's ? (question mark) operator actually work?
1.2
0
0
2,132
9,884,764
2012-03-27T07:02:00.000
1
0
1
0
python,console,ipython,metaclass
13,134,147
3
false
0
0
Have a look at the IPython.core.inputsplitter module for the code that parses the raw input line for things like ?, !, /, %, etc.
2
3
0
So i was thinking that in order to implement such a feature in a console application , where appending a question mark at the end of a function name will pour out it's doc string , i would have probably used a feature like metaclasses , where upon definition/import , i'd duplicate all the module member names and produce new ones just for typing out doc strings. Then i noticed that you don't need actual parenthesis to call the helper functions and python doesn't actually allow you to put a question mark at the end of the function name anyway.... So is this done in python or am i just wasting my time trying to figure this out? Thanks in advance
how does IPython's ? (question mark) operator actually work?
0.066568
0
0
2,132
9,886,494
2012-03-27T09:13:00.000
0
1
0
0
python,django,shipping,satchmo
14,647,712
1
true
0
0
it seems like the tieredweight shipping module is what I need here.
1
0
0
I'm taking over a Satchmo site and need it to charge a different shipping rate for international versus local postage. Any idea what I need to do to enable this?
Different national and international shipping rate in Satchmo?
1.2
0
0
84
9,887,174
2012-03-27T09:53:00.000
1
0
1
0
python,python-2.7
9,887,500
1
true
0
0
To "convert" it into a file: Write the bytearray to disk without changing anything (be sure to open the file for writing with "wb"). To access its content without saving to disk, embed it into a stringio object (which mimics an open file) and access it with zipfile.
1
0
0
I have a bytearray object in Python 2.7 that I got from a query to an SQL server and I know that it is a zip file. What I need to do now is access the data in the zip file. How can I convert the bytearray into the file and safe it to the hard disc? How can I access the data in the zip file directly in Python?
How to convert bytearray into a zip file
1.2
0
0
823
9,887,223
2012-03-27T09:56:00.000
2
0
0
0
python,unicode,urllib2,urlopen
9,889,366
2
true
0
0
What you need is u"http://www.besondere-raumdΓΌfte.de/".encode('idna'). Please note how the source string is a Unicode constant (the u prefix). The result is an URL usable with urlopen(). If you have a domain name with non-ASCII characters and the rest of the URL contains non-ASCII characters, you need to .encode('idna') the domain part and iri2uri() the rest.
1
2
0
I cannot request url "http://www.besondere-raumdΓΌfte.de" with urllib2.urlopen(). I tried to encode string using urllib.urlencode with utf-8, idna, ascii But still doesn't work. Raises URLError: <urlopen error unknown url type.
How to request a url with non-unicode carachters on main domainname (not params) in Python?
1.2
0
1
2,142
9,887,663
2012-03-27T10:22:00.000
0
0
1
0
python,colors,pixel,python-2.6
9,887,823
2
false
0
0
No, The std libraries can't tell you anything about your screen
1
1
0
I am in a situation where importing non-standard python libraries is not suitable. Is it possible to grab the pixel colour at a given location on the screen (x,y) using only the standard python (2.6) libraries in Windows?
Find the colour of a pixel at a given location without importing non-standard libraries
0
0
0
329
9,890,730
2012-03-27T13:42:00.000
2
0
1
0
python
9,891,022
2
true
0
0
Here is a reference from the official python manual: A weak reference to an object is not enough to keep the object alive: when the only remaining references to a referent are weak references, garbage collection is free to destroy the referent and reuse its memory for something else. A primary use for weak references is to implement caches or mappings holding large objects, where it’s desired that a large object not be kept alive solely because it appears in a cache or mapping.
1
0
0
What is WeakValueDictionary from weakref ? I know it allows to store items in dictionary without garbage collector caring about them but when should they be used? I don't know the example of the situation where we would want to bypass garbage collector in python.
WeakValueDictionary in python
1.2
0
0
706
9,892,351
2012-03-27T15:12:00.000
3
0
0
0
android,python,sl4a
9,892,477
3
false
1
1
Try the official Android emulator. If the APKs include native libraries, chances are those are compiled for ARM only. Google's emulator emulates the ARM instruction set. To make sure, rename the APK to ZIP and look inside. The structure of the lib folder, if any, will give you an idea.
1
0
0
I am currently developing a Android Application. I couldn't install the Android Python APKs like the sl4a.apk and the PythonInterpreter.apk on my Android x86 emulator. I read that it is possible to recompile the APKs with NDK but I have not found a closer decription, yet. Has anybody experience with this and could provide a small tutorial? Best Regards
SL4A Android x86 installation
0.197375
0
0
1,441
9,893,317
2012-03-27T16:04:00.000
0
0
1
0
python,pypy
68,372,961
3
false
0
0
install Chocolatey choco install python.pypy -y
2
15
0
I was wondering how to use PyPy 1.8 on Windows XP 32-bit. I downloaded the zip file off the website and installed it into a My Documents file. Initially, I thought it was similar to psyco in that I had to "import psyco," but I found that PyPy.exe acted like the Python command line instead. I tried dragging my scripts into the PyPy.exe to run them, but it didn't seem to work at all. Attempting to use the "python" command within PyPy yielded a "global name 'python' is not defined." So I was hoping if someone can assist me in making PyPy run because I'm pretty much out of ideas. The documentation on the PyPy website confused me mainly and was not very helpful. Ans: I found that I could simply right-click the script and "Open with" Pypy.exe to make it work. Not sure why it didn't work with the drag since I thought that was equivalent. Thanks everyone.
How to use PyPy on Windows?
0
0
0
24,210
9,893,317
2012-03-27T16:04:00.000
9
0
1
0
python,pypy
9,895,099
3
true
0
0
Maybe I'm not following what you're trying to do, but isn't it just a question of opening a command prompt and running pypy myscriptname ? Assuming you've got all the paths for PyPy and your script straight, anyway (e.g. your script's in PyPy's folder).
2
15
0
I was wondering how to use PyPy 1.8 on Windows XP 32-bit. I downloaded the zip file off the website and installed it into a My Documents file. Initially, I thought it was similar to psyco in that I had to "import psyco," but I found that PyPy.exe acted like the Python command line instead. I tried dragging my scripts into the PyPy.exe to run them, but it didn't seem to work at all. Attempting to use the "python" command within PyPy yielded a "global name 'python' is not defined." So I was hoping if someone can assist me in making PyPy run because I'm pretty much out of ideas. The documentation on the PyPy website confused me mainly and was not very helpful. Ans: I found that I could simply right-click the script and "Open with" Pypy.exe to make it work. Not sure why it didn't work with the drag since I thought that was equivalent. Thanks everyone.
How to use PyPy on Windows?
1.2
0
0
24,210
9,894,979
2012-03-27T17:59:00.000
0
0
0
0
python,user-interface,text-based
9,895,140
3
false
0
1
For basic toolkit, I think tkinter which comes with python is okay. If you want to have graphical toolkit with more functionality, I would suggest you to take a look at wxpython which is cross-platform compatible.
1
1
0
Quick to learn is pretty important, but I need just some basic GUI tools, for Ubuntu OS but would be nice to have multi-OS compatibility. Any suggestions? The basic dynamics of the intended game just include a text input and some set reaction frames. Thanks in advance.
Python GUI Toolkit for Text-Based Game?
0
0
0
1,725
9,896,687
2012-03-27T19:53:00.000
1
1
0
1
python,64-bit,pygame,wxwidgets,enthought
11,151,178
1
true
0
0
I had the same problem. The only way around it that has worked for me is to uninstall your EPD version ($ sudo remove-EPD-7.2-1, or whichever version you have) and reinstall the 32 bit version. Wx comes as part of the EPD package, so once you have downloaded the 32 bit version there is no need to download and install wx.
1
1
0
For some reason my 64 bit EPD can't import wx. I also tried to install the wxPython2.8-osx-unicode-py2.7 version from the wx site. It installed successfully, but is no where to be found on my harddrive. I checked the sitepackes for 2.7 and the EPD 7.2.2. where all the modules usually should be installed. I am confused. This raises a similar question. How can I install modules that are not part of EPD ? I also didn't have luck to install other modules. And every time I try to import older modules it doesn't work as well. Often I get error message that architectures in universal rapper is wrong. For example pygame doesn’t have a 64 bit version that works with 2.7, so I installed the 32 bit version. If I try to do the trick arch -i386 /Path to python , I get "Bad CPU type in executable". I am running a 64bit version of Python on a 64 bit Mac OS. I wonder if the Enthougt 7.2 is equivalent with the 2.7 Python. And if not, what I assume, what the differences are. Any hints who can solve this, would be awesome. Thanks for your patients.
enthought python distribution wx
1.2
0
0
682
9,897,345
2012-03-27T20:38:00.000
14
0
1
0
python,serialization
12,095,050
8
false
0
0
Pickle is actually quite fast so long as you aren't using the (default) ASCII protocol. Just make sure to dump using protocol=pickle.HIGHEST_PROTOCOL.
1
33
1
I am trying to serialize a large (~10**6 rows, each with ~20 values) list, to be used later by myself (so pickle's lack of safety isn't a concern). Each row of the list is a tuple of values, derived from some SQL database. So far, I have seen datetime.datetime, strings, integers, and NoneType, but I might eventually have to support additional data types. For serialization, I've considered pickle (cPickle), json, and plain text - but only pickle saves the type information: json can't serialize datetime.datetime, and plain text has its obvious disadvantages. However, cPickle is pretty slow for data this large, and I'm looking for a faster alternative.
Pickle alternatives
1
0
0
35,941
9,897,647
2012-03-27T21:01:00.000
0
0
0
0
python,signals,urllib2,sigterm
9,897,777
1
false
0
0
urlopen returns a file-like object. Data is only sent over the network when you make a .read() request on this object. (Your OS does some buffering of network data, so this isn't strictly true, but it's close enough for all practical purposes.) So simply use the .read() method's capability to read data in chunks using a loop, perhaps 16K or 64K at a time, rather than retrieving the whole file at once. In your signal handler, then, you can close the file-like object and the file will stop downloading after the current chunk finishes. The smaller the chunk you use, the less latency there will be in stopping the download. I'd use a global variable to hold the reference to file-like object so it is accessible in your signal handler; in this case it seems like the simplest solution. If you should happen to try to read from the file-like object after closing it, you will get an exception, which you can handle gracefully.
1
0
0
I'm using urllib2.urlopen() to open sometimes potentially large files. I have a signal handler to catch SIGTERM, but is it possible to actually interrupt urlopen() when it's downloading a big file to close my program immediately, without waiting for the call to finish?
Python: interrupting urllib2.urlopen() with SIGTERM
0
0
1
396
9,899,180
2012-03-27T23:32:00.000
1
0
1
0
python,python-3.x,cloud
9,899,346
3
false
1
0
I haven't tried myself. You may want to check out ipython notebook.
1
0
0
Is there any way in a browser, to type python code into an input field, it will then be sent to a local server and executed and the result pushed back to the browser. Basically a browser hosted python notebook, where the code gets evaluated on a different machine. Is there any python package to do this. something like what ideone.com or picloud do, but opensource and that can install on your own server. Or any suggestions on how to do it, I have looked around already but have struggled to find something meaningful.
cloud scripting through browser and evaluate python on server
0.066568
0
1
92
9,899,313
2012-03-27T23:48:00.000
2
1
1
0
python,beautifulsoup,mechanize
9,899,341
1
false
0
0
Use a dict or set. Consider computing a checksum of each item. This brings you toward what's known as Content Addressable Storage, which is where the checksum actually is stored as if it were the item's "name", and a separate index is stored which maps things like filenames or song names to the checksums or data blocks. The problem with the CAS approach in your particular case is that it may not be possible for you to get a checksum computed on the remote side for new content--that's how programs like rsync avoid copying duplicate data.
1
1
0
This isn't as much of a specific problem as something I am looking for more of a "Pythonic" philosophical answer to. Namely, what's the best way to keep track of unique items and ensure duplicates don't arise? For example, I am writing a script to scrape a website for links to songs on SoundCloud so I can automatically download them. If I want to automate this program with, say, cron, what's the most efficient way to ensure that I am downloading only content I don't have already? Or if I downloaded images, how could I make sure that there aren't any duplicates, or have some sort of process that searches for and removes duplicates efficiently? Kind of open ended, so contribute as little or as much as you please. Thanks.
What is the most efficient way to keep track of unique downloaded files in a Python program?
0.379949
0
0
214
9,905,587
2012-03-28T10:26:00.000
0
0
0
0
python,qt4.7
9,910,376
1
false
0
1
Thank you, I solved, when clicked the QtoolButton send two different triggered signal, then my slot ran twice, it was enough to add decorator before the definition of the slot @pyqtSignature("")
1
0
0
Hi in my application I have several gui developped with QT4.7, in some of them I use QToolButton for interaction, everything work nicely, except that when I click over each of the QToolButton, the slot linked to his triggered signal is called twice, I have no more Ideas about a olution to that, can you help me please, thanks in advance
trigger signal of QToolButton autorepeat the action
0
0
0
305
9,905,743
2012-03-28T10:36:00.000
0
0
1
1
python,subprocess,packaging,pip,distutils
9,918,260
2
false
0
0
If you don’t have a real reason to avoid subprocesses (i.e. lack of platform support, not just aesthetics (β€œI see no point”)), then I suggest you should just not care and run in a subprocess. There are a few ways to achieve what you request, but they have their downsides (like having to catch exceptions and reporting errors).
1
6
0
I am writing a script to automate the packaging of a 'home-made' python module and distributing it on a remote machine. i am using Pip and have created a setup.py file but i then have to call the subprocess module to call the "python setup.py sdist" command. i have looked at the "run_setup" method in distutils.core but i am trying to avoid using the subprocess module alltogether. (i see no point in opening a shell to run a python command if i am already in python...) is there a way to import the distutils module into my script and pass the setup information directly to one of its methods and avoid using the shell command entirely? or any other suggestions that may help me thanks
How do i run the python 'sdist' command from within a python automated script without using subprocess?
0
0
0
1,605
9,906,938
2012-03-28T11:52:00.000
1
0
1
0
python,jupyter
34,956,900
7
false
0
0
you can right click on the ipython windows and select "Default". you can set your default configuration from there.
1
29
0
It is possible to make persistent changes to settings for default settings on Windows 7? I would like to change font-size and shell size.
Change Jupyter QtConsole settings
0.028564
0
0
16,567
9,909,987
2012-03-28T14:46:00.000
0
0
1
0
python,data-structures,genetic-algorithm
9,910,954
3
false
0
0
I think sticking with the strings is a good idea. You can easily chop strings into pieces. if you need to act on them as a list, you can convert it with "list(str)". Once you have a list, you can alter it and turn it back into a string using "''.join(lst)". Personally, I wouldn't use a long or another integer type to store as bits. It may be more space efficient, but the headache of working with the data when you want to do a recombination would be considerable. Mutations would be problematic as well if the mutation consist of something other than a bit flip. Plus, the code would be much harder to read. Just my 2 cents. Hope that helps you out.
1
3
0
I am implementing a GA in Python and need to store a sequence of ones and zeros, so I am representing my data as binaries. What is the best data structure for that? A simple string?
Which data types for genetic algorithms in Python?
0
0
0
1,028
9,910,788
2012-03-28T15:27:00.000
0
0
0
1
python,windows-services,waitress
13,188,519
1
false
0
0
Hmm, March, a bit late. You can't debug without more info. I'd turn the logging all the way to debug, if not already done. I'd also check the NT event log. The only things coming to mind are the firewall, and extra restrictions on apps in server. If possible, try adding an exception for your app.
1
1
0
So I've written a windows service in python which starts a subprocess that runs a Waitress server, monitors a directory for changes, and restarts the server when a change is detected. On Windows 7, everything works fine. On Windows Server 2003, where I have to deploy this server, the server fails to bind to its port. I've tried running the service as several different users, including NetworkService, but nothing seems to work. There's nothing in the waitress logs, either. How can I even debug this?
Trouble running waitress as a service on Windows Server 2003
0
0
0
659
9,910,989
2012-03-28T15:38:00.000
1
0
1
0
python,python-collections
9,911,027
1
false
0
0
Sure. Write __eq__ and __ne__ methods that perform this comparison.
1
1
0
I have written a custom mapping class that inherits from collections.Mapping. Is there an easy way to test if an instance's data is equal to another mapping object, e.g. dict?
Test if collections.Mapping is equal to other mapping, or dict
0.197375
0
0
323
9,912,121
2012-03-28T16:47:00.000
0
1
0
1
python,windows,process,kill
9,912,713
1
false
0
0
Why are you assured that your CGI script are still working when you try to kill it? Web server starts one instance of CGI script for one request and when script finishes it... just finishes.
1
0
0
I'm obtaining a PID, using python, of a CGI script, however, the PID is not valid i.e. can't Taskkill it from CL. I get: "Process: no process found with pid xxxx" where xxxx is the pid I thought maybe I have to kill a parent python shell instance, but os.ppid doesn't work in windows. So then I installed psutil python module and can now get parent PID, but it just shows the parent as the actual WebServer (Abyss), which I don't think I want to kill, since it is the http process that I notice runs constantly and not just a CGI interpreter instance. Using psutil I CAN get the process status of the actual script, using the pid returned by os.getpid(), and see that it is running. So the pid works for purposes of process information retrieval using psutil. But this gets me no further to obtaining the actual PID I need to kill the script, using EITHER Taskkill on the CL or via kill() from psutil! What exactly is a cgi shell script from a process perspective, and if it is not a process, why is os.getpid() returning a pid?
Determing PID of CGI Script on Windows
0
0
0
222
9,913,193
2012-03-28T18:02:00.000
0
0
1
0
python,import,module,compiled
9,913,300
6
false
0
0
In import use the pyc file name,python will automatically load it.
2
21
0
I can't seem to figure out how to import a compiled .pyc module into my code so I can use it within my main script. Is this even possible?
Is it possible to import a compiled python file?
0
0
0
35,577
9,913,193
2012-03-28T18:02:00.000
1
0
1
0
python,import,module,compiled
28,891,674
6
false
0
0
Yes, but caveat that with make sure to start python with the "-O" option! In my personal experience, if all you have is that .pyc or .pyo file, running "python.exe" without the flag and trying to import will fail, however running python.exe -O and then trying to import as normal should work.
2
21
0
I can't seem to figure out how to import a compiled .pyc module into my code so I can use it within my main script. Is this even possible?
Is it possible to import a compiled python file?
0.033321
0
0
35,577
9,914,165
2012-03-28T19:13:00.000
1
0
0
0
python,logging
12,219,717
1
true
1
0
Just for future reference for people... I tried loggly out and was generally very pleased with them. While I never did any formal benchmarking tests (with our without them). Any performance issues were not noticeable to me.
1
1
0
I'm getting ready to deploy an app to Heroku and I'm considering adding Loggly as a plugin. I love the idea of being able to aggregate and search my logs more easily, but I'm a bit concerned about what kind of performance hit I might take because of it. Any experiences (good or bad) out there with Loggly? Just as a note: I'm using Python with Django 1.3
Loggly performance
1.2
0
0
398
9,914,985
2012-03-28T20:14:00.000
0
0
1
1
python,environment-variables
9,915,173
1
false
0
0
You can always export PYSTARTUP="whatever" on the shell before starting your script. You can also put PYSTARTUP="whatever" in front of the command you want to run, e.g. PYSTARTUP="whatever" python something.py
1
0
0
We have an in-house developed network-based application that is based on python, it provides a command-line environment in the same way like python does. I also have a local python installation on my machine. Sometimes for simple python tasks, i prefer using my local python install... Is possible to to have a different PYSTARTUP env variable for each of installation?
different PYSTARTUP variables for different python installations
0
0
0
184
9,915,062
2012-03-28T20:20:00.000
0
0
0
0
python,database,shelve
9,915,108
1
false
0
0
Shelves are mappings, and mappings have an update() method.
1
0
0
I have several Shelve i.e. .db files that I wish to merge together into one single database. The only method I could think of was to iterate through each database rewriting each iteration to the new database, but this takes too long. Is there a better way to do this?
How can I merge Shelve files/databases?
0
1
0
320
9,915,870
2012-03-28T21:24:00.000
5
0
1
0
python,utf-8
9,915,912
1
true
0
0
You're getting the correct result, the Unicode codepoint for Γ± is U+00f1. It's just that Python won't display the Unicode character directly. Try it in a print statement and see what you get.
1
1
0
I'm trying to do this in Python: 'Fi\xc3\xb1a'.decode('utf-8') I expect the result to be FiΓ±a. But the result is actually: u'Fi\xf1a' No idea what is going on, some help on this would be much appreciated. Thanks!
UTF-8 decoding error in Python
1.2
0
0
218
9,916,571
2012-03-28T22:28:00.000
1
0
0
0
python,django,multithreading,mod-wsgi
9,916,735
2
false
1
0
You shouldn't be worrying about this kind of stuff. These slots are stored in a database right? The database should handle all the locking mechanisms for you, just make sure you run everything under a transaction and you will be fine.
1
1
0
I have a django app which is used for managing registrations to a survey. There are fixed number of slots and I want to "reserve" slots for users when they sign up. In one of my views, I get the next available slot and reserve it (or redirect the user if there are no slots available.) I want to protect against the case where two user's signing up at the same time get registered for the same slot because the the method "get_next_available_slot" returned the same slot for both users. For this I am trying to understand the use of processes and threads with Django's views. 1) Is each request handled in a separate thread and will using python threading module's LOCK() take care of exclusive access? 2) I am running apache on RHEL with modwsgi. How do I configure Apache/modwsgi to ensure a more easy and simple solution to handle the above situation? I am not expecting a huge load on the web application at all. So I would like a simpler solution instead of a high performance one.
Questions about django thread safety
0.099668
0
0
194
9,916,873
2012-03-28T22:58:00.000
0
0
1
0
python,exception,gevent
17,853,380
2
false
0
0
You can use spawn_link_exception instead of spawn.
1
2
0
i'm working with an application written in python using gevent. i want it to exit immediately as a result of any exception that i haven't explicitly trapped. it looks like i'd have to patch the core gevent code. is there any way can i do this in my app, without patching gevent or greenlet?
how can i make gevent application exit immediately after any exception?
0
0
0
1,560
9,917,327
2012-03-28T23:54:00.000
2
0
0
0
python,image-processing,python-imaging-library
9,917,381
1
true
0
1
Make a mask which is the same size as the image2, mode 'L'. Fill it with gray values from 0 to 255, representing the alpha transparency you want. Use paste to put image2 into image1, using the gray image as the mask parameter.
1
0
0
I have two images (JPGs). Both are the same width but image2 is shorter than image1. I want to paste image2 on top of image1 (top aligned) and for each row in image2 I want to blend into image1 with a different alpha transparency value (to make it smoothly blend from bottom to top ). I'm using Python PIL and because I'm new to it can't figure out the best way to do this. Any suggestions?
Blending two images with PIL: Different sizes and different alpha transparency per row
1.2
0
0
2,127
9,917,464
2012-03-29T00:10:00.000
0
0
0
0
python,text,pygame
9,917,557
2
true
0
1
You're on the right track! Use a variable.
2
0
0
I am creating a copy of the game Pig. I have got a text based version of the game working. I am just updating it to pygame, adding graphics and sounds. I will eventually add in mouse toggles, but for now I am trying to update a score. I have display a 'player1 score', 'player2 score' out. I am trying to see how will it work to display text that is not constant. i got player1_text = font.render('player1 score', True,(0,0,0)) same for player2 I am assuming maybe that the first parameter -->'player1 score' I can pass a variable and if I update the variable. When i call pygame.update() it should work as I think it should. Just want some conformation or a tip on actually doing it.
Pygame: How would I go about setting a text object, BUT the text is meant to keep changing?
1.2
0
0
1,013
9,917,464
2012-03-29T00:10:00.000
2
0
0
0
python,text,pygame
10,002,172
2
false
0
1
Pygame Font objects are not meant to be updated and changed constantly. You will need to call render(text) each time your text changes. Render() will return a new surface, so you will need to blit that to your screen to make the change.
2
0
0
I am creating a copy of the game Pig. I have got a text based version of the game working. I am just updating it to pygame, adding graphics and sounds. I will eventually add in mouse toggles, but for now I am trying to update a score. I have display a 'player1 score', 'player2 score' out. I am trying to see how will it work to display text that is not constant. i got player1_text = font.render('player1 score', True,(0,0,0)) same for player2 I am assuming maybe that the first parameter -->'player1 score' I can pass a variable and if I update the variable. When i call pygame.update() it should work as I think it should. Just want some conformation or a tip on actually doing it.
Pygame: How would I go about setting a text object, BUT the text is meant to keep changing?
0.197375
0
0
1,013
9,917,971
2012-03-29T01:25:00.000
4
0
0
0
python,database,django,django-models
9,917,983
2
false
1
0
models enforces constraint via the database. choices enforces constraint via the code. Which you choose depends on who you want to select the choices.
2
2
0
Lets say I'd like to give an user options to pick from and ensure that the submitted values are available options. I've been reading the documentation and it seems to me that: if your values won't change then use choices -- if your data is dynamic then use models. I'm a bit unsure though, shouldn't models be chosen over choices since they enforce some kind of constraint in the DB?
Django - Choices vs Models (FKs)
0.379949
0
0
742
9,917,971
2012-03-29T01:25:00.000
7
0
0
0
python,database,django,django-models
9,920,914
2
false
1
0
Use models when you definitely need one of these: ability easily edit (add, delete) choice with no need to reload the code; ability to store additional info for any choice; easy many-to-many relation (and filtering by it) ability to work with dynamic subset of choices in different cases. Use choices otherwise.
2
2
0
Lets say I'd like to give an user options to pick from and ensure that the submitted values are available options. I've been reading the documentation and it seems to me that: if your values won't change then use choices -- if your data is dynamic then use models. I'm a bit unsure though, shouldn't models be chosen over choices since they enforce some kind of constraint in the DB?
Django - Choices vs Models (FKs)
1
0
0
742
9,918,646
2012-03-29T03:20:00.000
0
0
0
0
python,uno
67,111,357
17
false
0
0
This is a solution for MacOS with old xls files (e.g. Excel 97 2004). The best way I found to deal with this format, if excel is not an option, is to open the file in openoffice and save it to another format as csv files.
1
43
0
I have some *.xls (excel 2003) files, and I want to convert those files into xlsx (excel 2007). I use the uno python package, when I save the documents, I can set the Filter name: MS Excel 97 But there is no Filter name like 'MS Excel 2007', How can set the the filter name to convert xls to xlsx ?
how to convert xls to xlsx
0
1
0
99,140
9,918,903
2012-03-29T04:00:00.000
0
0
0
0
python,google-app-engine,file-conversion
11,282,356
1
false
1
0
You could export the canvas to an image (toDataURL) after the user creates or modifies the chart, and swap the two when calling the Conversion API.
1
1
0
I am trying to figure out the best way of allowing my users to create a family tree chart, view it on screen and then to be able to create a PDF of it. I am considering using ReportLab for the PDF generation, however then I have to have separate display and PDF code. So I was wondering if the Conversion API would be able to handle HTML with canvas (and therefore Javascript), I am guessing probably not, but I thought I would ask. I am a little more hopeful about it being able to generate HTML with SVG since it can be rendered without javascript.
Does the App Engine Conversion API for HTML to PDF support canvas or SVG?
0
0
0
254
9,919,509
2012-03-29T05:22:00.000
1
1
0
0
python,ms-word,pdf-generation,report,reportlab
9,930,989
3
false
0
0
I should point out you can do all the stuff you want in ReportLab by using the supporting PLATYPUS module. It lets you easily build documents out of objects in code. Alternatively, there is RML, a ReportLab way of building documents from an HTML-like markup language.
2
2
0
I want some help to generate a report in PDF/Doc(MS Word) format . I’m not able to find any module to generated report in doc, except β€œdocx” which I’m not able to comprehend. Actually I’m actual task is to generate the report in Doc only, but as I’m not able to find a module to work on it, I opt for PDF. I’m using β€œReport Lab” module, but I’m finding some limitation in that. It write anything based on co-ordinate system. The problem I’m facing with that the report is usually a string, whose length is not limited, so sometime it goes beyond the canvas( Pdf Page). Also there is not functionality I guess to do format font with Bold, Italics and Underline. If you know any module to generate report in PDF or Doc, please let me know. My requirement is: Able to add an image at an header. Change fonts and other properties, like Bold, Italics, and Underline Able to draw basic shape like line Write string, as a statement, as we are able to do with able to write into txt file using python(not on co-ordinate system basis)
Need help to generate report in PDF or Doc using python
0.066568
0
0
1,604
9,919,509
2012-03-29T05:22:00.000
1
1
0
0
python,ms-word,pdf-generation,report,reportlab
9,931,947
3
false
0
0
You could also try and generate LaTeX Code, which you then compile to PDF.
2
2
0
I want some help to generate a report in PDF/Doc(MS Word) format . I’m not able to find any module to generated report in doc, except β€œdocx” which I’m not able to comprehend. Actually I’m actual task is to generate the report in Doc only, but as I’m not able to find a module to work on it, I opt for PDF. I’m using β€œReport Lab” module, but I’m finding some limitation in that. It write anything based on co-ordinate system. The problem I’m facing with that the report is usually a string, whose length is not limited, so sometime it goes beyond the canvas( Pdf Page). Also there is not functionality I guess to do format font with Bold, Italics and Underline. If you know any module to generate report in PDF or Doc, please let me know. My requirement is: Able to add an image at an header. Change fonts and other properties, like Bold, Italics, and Underline Able to draw basic shape like line Write string, as a statement, as we are able to do with able to write into txt file using python(not on co-ordinate system basis)
Need help to generate report in PDF or Doc using python
0.066568
0
0
1,604
9,920,935
2012-03-29T07:32:00.000
0
0
0
0
python,excel,format,xlwt
10,001,613
2
false
0
0
You said: formatting with xlwt takes a lot of time and it is quite awkward to use Perhaps you are not using easyxf? If so, check out the tutorial that you can access via www.python-excel.org, and have a look at examples/xlwt_easyxf_simple_demo.py in your xlwt installation.
1
3
0
I have to create Excel spreadsheet with nice format from Python. I thought of doing it by: I start in Excel as it is very easy to format: I write in Excel the model I want, with the good format I read this from Python I create from Python an Excel spreadsheet with the same format In the end, the purpose is to create from Python Excel spreadsheets, but formatting with xlwt takes a lot of time, so I thought of formatting first in Excel to help. I have researched for easy ways to doing this but haven't found any. I can stick to my current working solution, using xlwt in Python to create formatted Excel, but it is quite awkward to use. Thanks for any reply
Easily write formatted Excel from Python: Start with Excel formatted, use it in Python, and regenerate Excel from Python
0
1
0
4,524
9,921,057
2012-03-29T07:41:00.000
0
0
1
0
java,python,math
9,921,123
2
false
0
0
You can use the built-in function round: round(3.5) gives 4.0 round(3.4) gives 3.0 round(3.6) gives 4.0
1
1
0
Does an analogue to Java's Math.rint exist in Python? If not, how can I achieve the same result?
Rounding numbers: Java's 'Math.rint' in Python
0
0
0
1,638
9,922,710
2012-03-29T09:35:00.000
2
0
0
0
python,plone
9,922,771
1
false
1
0
You can store hash ( eg md5 ) of your image content into a database, at upload time. When a new image is uploaded, you just have to match the current image's hash against those present in the database. The hash will be collision free mostly, however to be more sure, you can also store other attributes like filesize, image dimensions in the same database and compare them as a double check.
1
2
0
How can I check a duplicate file or image being uploaded into a Plone site. I am using Plone 4.1? Is there some feature or configuration changes that need to be done to achieve the same.I want this feature to check the entire site before uploading any file /image into the site. I am working on Linux OS. I am using the Zope server which gets installed with Plone 4.1.4.
How can I check a duplicate file or image being uploaded into a Plone site
0.379949
0
0
176
9,923,175
2012-03-29T10:03:00.000
0
1
0
1
python,gevent
9,923,444
2
false
0
0
first test cmd easy_install gevent if failed, just go google python setuptools and then installed it and easy_install gevent just let the setuptools to help you choose the suitable module
1
0
0
I'm new for python. How can I get gevent-py2.7-win64.egg, my system is win32, and I need a 64bit module of gevent
How can I get gevent-py2.7-win64.egg
0
0
0
377
9,924,169
2012-03-29T11:09:00.000
9
0
0
0
python,django,saas
9,925,190
4
false
1
0
A very basic, elementary example of how you would go about it. Suppose you have a simple app designed to solve a particular business case. For example, you created an app to handle room reservations at your office. To "convert" this app into a service you have to configure it such that most of the user-specific parts of the application are parametric (they can be "templatized" - for lack of better word). This is how the front end would be converted. You might create variables to hold the logo, headline, teaser, color scheme for the app; allowing each user to customize their instance. So far, your app is able to customize itself on the front end. It is still using the same database that was designed in phase one. Now comes the matter of showing only those fields that are relevant to a particular user. This would be parameterizing the database. So you might add a column that identifies each row as belonging to a particular user; then create views or stored procedures that filter records based on the logged in user. Now the application is able to be "rented" out; since you are able to customize the instance based on the user. It then just gets bigger from here - depending on the scale, type and intended customization of your application. You might decide that your application performs better when each user has their own dedicated database instead of the stored procedure + view combo. You may decide that for some user types (or "packages"), you need a dedicated instance of your application running. So for "premium" or "ultra" users you want to have their own dedicated system running. If your application requires lots of storage - you might decide to charge separately for storage. The bottom line is it has nothing to do with the language used. Its more an architecture and design problem.
2
31
0
Can you advice me with some articles/applications that allows you create SaaS(Software as a Service) application with Python and Django. For the moment the general topics I do not understand are: Do you have one working application for all clients or one app per client How do you manage database access, permissions or different DB for each client Are there any tools that allows you to convert one app to SaaS
How to create SaaS application with Python and Django
1
0
0
23,996
9,924,169
2012-03-29T11:09:00.000
8
0
0
0
python,django,saas
9,924,280
4
false
1
0
Software as a Service is just a marketing word, it's technically no different from a server that is accessible over the internet. So question 3 makes no sense. That leaves us with question 1 and 2: What do you mean with 'app' in this context? Your web application (built with Python and Django) can have multiple Django apps (components that make up the web application) but I think that's not what you mean. You can build your website in Python/Django and have various customization options depending on which user (client) is logged in. For example, a premium client can have several advanced options enabled but it's still part of the same codebase. It's just that some options (buttons/controls, etc) are not shown for certain clients Django has plenty of tools for user management, permissions and groups. You can give each user (each client) different permissions and these permissions determine what they can do. Database access should be managed by your web application. For example, the code determines what information needs to be displayed on the webpage (depending on which client is logged in) and that code retrieves the information from the database. Depending on the scale that you're aiming for, you can also specify which database should be used to retrieve the information from.
2
31
0
Can you advice me with some articles/applications that allows you create SaaS(Software as a Service) application with Python and Django. For the moment the general topics I do not understand are: Do you have one working application for all clients or one app per client How do you manage database access, permissions or different DB for each client Are there any tools that allows you to convert one app to SaaS
How to create SaaS application with Python and Django
1
0
0
23,996
9,926,088
2012-03-29T13:14:00.000
2
1
0
1
python,eclipse,pydev
9,926,632
1
true
0
0
Right click on the python file you care about and see what the default editor is. You can manually switch any file type here. If it's plain text, just switch it back to PyDev. To ensure that the setting is global, go to Window > Preferences > General > Editors > File associations and look for .py, .pyw, and .pyx. They should all be set to "Python Editor (default)". If not, just select it and select default. If it's not there at all, you can select the "add" button and add it from there.
1
1
0
I'm having a problem with eclipse+pydev. It suddenly refuses to parse a .py file as a python script, which means no syntax highlighting, code completion etc. It worked up until now, but I couldn't find a way to convince it to re parse it. re-opening the file, re-starting the IDE does not help. I suspect deleting some kind of meta-data file would do the trick. Has anyone here encountered this and has a quick solution? I would greatly appreciate that!
eclipse pydev refuses to parse a .py file
1.2
0
0
439
9,926,825
2012-03-29T13:54:00.000
0
0
0
0
python,amazon-web-services
9,928,772
4
false
1
0
Don't put it in applications you plan to distribute. It'll be visible and they can launch instances that are directly billable to you or worst..they can take down instances if you use it in production. I would look at your programs design and seriously question why I need to include that information in the app. If you post more details on the design I'm sure we can help you figure out a way in which you don't need to bundle this information.
1
11
0
I'm making an application in Python and using Amazon Web Services in some modules. I'm now hard coding my AWS access id and secret key in *.py file. Or might move them out to an configuration file in future. But there's a problem, how can I protect AWS information form other people? As I know python is a language that easy to de-compile. Is there a way to do this? Well what I'm making is an app to help user upload/download stuff from cloud. I'm using Amazon S3 as cloud storage. As I know Dropbox also using S3 so I'm wondering how they protects the key. After a day's research I found something. I'm now using boto (an AWS library for python). I can use a function of 'generate_url(X)' to get a url for the app to accessing the object in S3. The url will be expired in X seconds. So I can build a web service for my apps to provide them the urls. The AWS keys will not be set into the app but into the web service. It sounds great, but so far I only can download objects with this function, upload doesn't work. Any body knows how to use it for uploading? Does anyone here know how to use key.generate_url() of boto to get a temporary url for uploading stuff to S3?
How can I protect my AWS access id and secret key in my python application
0
0
1
6,307
9,927,372
2012-03-29T14:25:00.000
1
0
0
0
python,programming-languages,database-programming
9,927,520
4
true
0
0
The deveopment of a scalable database is language independent, i cannot say much about PHP, but i can tell you good things about Python, it's easy to read, easy to learn, etc. In my opinion it makes the code much cleaner than other languges.
3
0
0
I want to ask you what programming language I should use to develop a horizontally scalable database. I don't care too much about performance. Currently, I only know PHP and Python, but I wonder if Python is good for scalability. Or is this even possible in Python? The reasons I don't use an existing system is, I need deep insight into the system, and there is no database out there that can store indexes the way I want. (It's a mix of non relational, sparse free multidimensional, and graph design) EDIT: I already have most of the core code written in Python and investigated ways to improve adding data for that type of database design, what limits the use of other databases even more. EDIT 2: Forgot to note, the database tables are several hundred gigabytes.
Programming a scalable database
1.2
1
0
284
9,927,372
2012-03-29T14:25:00.000
0
0
0
0
python,programming-languages,database-programming
9,927,811
4
false
0
0
Since this is clearly a request for "opinion", I thought I'd offer my $.02 We looked at MongoDB 12-months ago, and started to really like it...but for one issue. MongoDB limits the largest database to amount of physical RAM installed on the MongoDB server. For our tests, this meant we were limited to 4 GB databases. This didn't fit our needs, so we walked away (too bad really, because Mongo looked great). We moved back to home turf, and went with PostgreSQL for our project. It is an exceptional system, with lots to like. But we've kept an eye on the NoSQL crowd ever since, and it looks like Riak is doing some really interesting work. (fyi -- it's also possible the MongoDB project has resolved the DB size issue -- we haven't kept up with that project).
3
0
0
I want to ask you what programming language I should use to develop a horizontally scalable database. I don't care too much about performance. Currently, I only know PHP and Python, but I wonder if Python is good for scalability. Or is this even possible in Python? The reasons I don't use an existing system is, I need deep insight into the system, and there is no database out there that can store indexes the way I want. (It's a mix of non relational, sparse free multidimensional, and graph design) EDIT: I already have most of the core code written in Python and investigated ways to improve adding data for that type of database design, what limits the use of other databases even more. EDIT 2: Forgot to note, the database tables are several hundred gigabytes.
Programming a scalable database
0
1
0
284
9,927,372
2012-03-29T14:25:00.000
0
0
0
0
python,programming-languages,database-programming
9,927,445
4
false
0
0
Betweent PHP & Python, definitely Python. Where I work, the entire system is written in Python and it scales quite well. p.s.: Do take a look at Mongo Db though.
3
0
0
I want to ask you what programming language I should use to develop a horizontally scalable database. I don't care too much about performance. Currently, I only know PHP and Python, but I wonder if Python is good for scalability. Or is this even possible in Python? The reasons I don't use an existing system is, I need deep insight into the system, and there is no database out there that can store indexes the way I want. (It's a mix of non relational, sparse free multidimensional, and graph design) EDIT: I already have most of the core code written in Python and investigated ways to improve adding data for that type of database design, what limits the use of other databases even more. EDIT 2: Forgot to note, the database tables are several hundred gigabytes.
Programming a scalable database
0
1
0
284
9,927,711
2012-03-29T14:42:00.000
3
0
0
0
python,numpy,pandas
9,927,957
3
false
0
0
You can pass a custom list of values to be treated as missing using pandas.read_csv . Alternately you can pass functions to the converters argument.
1
1
1
I am using pandas to read a csv file. The data are numbers but stored in the csv file as text. Some of the values are non-numeric when they are bad or missing. How do I filter out these values and convert the remaining data to integers. I assume there is a better/faster way than looping over all the values and using isdigit() to test for them being numeric. Does pandas or numpy have a way of just recognizing bad values in the reader? If not, what is the easiest way to do it? Do I have to specific the dtypes to make this work?
Reading csv in python pandas and handling bad values
0.197375
0
0
3,639
9,927,821
2012-03-29T14:48:00.000
0
1
0
0
python,user-interface,wxpython,pyqt,tkinter
9,928,114
4
false
0
0
Basically you just need to figure out what widgets will hold the data you want the best. I suspect you could use a couple combo boxes to hold different sets of extensions. Or you could just use the path name strings to figure that out. Hit a button and run the conversion process, probably in another thread so the GUI remains responsive. I'm biased for wxPython. However, you're better off taking a look at their demos and documentation and seeing which GUI toolkit fits your brain the easiest.
3
3
0
I have a command-line Python script that works well to convert one sort of file into another given a few parameters and would now like to deploy this to some of my colleagues who may not know what a command line is. I could work for hours trying to determine which Python GUI toolkit is "best", then learning how to do what I need, but it seems like this would have been done before. Is there a relatively cook-book method to GUIify my program? Direction to either some sort of lesson/tutorial or an existing, documented, concise program would be excellent.
Cookbook GUI interface for a command-line script
0
0
0
4,233
9,927,821
2012-03-29T14:48:00.000
1
1
0
0
python,user-interface,wxpython,pyqt,tkinter
9,934,956
4
false
0
0
There are a few answers advocating wxpython. However, any toolkit will work for this project. Tkinter has the added benefit tha you and your collegues already have it installed and it is very easy to use. That being said, the other toolkits are more-or-less equally easy to use but you might have to jump through a hoop or two to get them installed. If installation is not an issue it won't matter which one you pick. Unfortunately, telling you how to "GUIfy" your program is hard since we know nothing about your app. Probably all it will involve is putting up a few labels and input widgets, then creating a button that collects all the data and then runs your program with the subprocess module.
3
3
0
I have a command-line Python script that works well to convert one sort of file into another given a few parameters and would now like to deploy this to some of my colleagues who may not know what a command line is. I could work for hours trying to determine which Python GUI toolkit is "best", then learning how to do what I need, but it seems like this would have been done before. Is there a relatively cook-book method to GUIify my program? Direction to either some sort of lesson/tutorial or an existing, documented, concise program would be excellent.
Cookbook GUI interface for a command-line script
0.049958
0
0
4,233
9,927,821
2012-03-29T14:48:00.000
0
1
0
0
python,user-interface,wxpython,pyqt,tkinter
9,928,262
4
false
0
0
This depends mostly on your need. If your need is simple, you can just go with tkinter that is bundled with python itself. If you use this, you will not be relying on third party library to implement your GUI. Since you are wanting to make this available for your collegues, this might be easier to compile with py2exe or other similar stuffs to exe which might be tricky if you use third party library for GUI. However, if you want to add more functionality to your GUI, wxpython/pyqt/pyGTK are the GUI toolkit to look for. Personally, I favor wxpython due to its cross-platform nature but pyqt and pyGTK are also equally good as far as I have heard.
3
3
0
I have a command-line Python script that works well to convert one sort of file into another given a few parameters and would now like to deploy this to some of my colleagues who may not know what a command line is. I could work for hours trying to determine which Python GUI toolkit is "best", then learning how to do what I need, but it seems like this would have been done before. Is there a relatively cook-book method to GUIify my program? Direction to either some sort of lesson/tutorial or an existing, documented, concise program would be excellent.
Cookbook GUI interface for a command-line script
0
0
0
4,233
9,928,711
2012-03-29T15:36:00.000
1
0
0
0
python,wxpython
9,931,233
2
false
0
1
Let's say your command line executable is: % compute -flag1 -flag2 datafile outputfile In WxPython you could use check boxes to choose whether flag1 and/or flag2 are used, a file chooser widget for datafile, a text input field for outputfile and 'execute' button. When execute is clicked create a command line in a string and pass it to one of the methods in the subprocess module.
1
2
0
This might seem as silly question but I am thinking there might be the simple solution for this problem. I have a python script which does some mathematical calculation which is command-line-based. I don't want to make any major modification to the code which I have right now. What should be my approach now to create a GUI ( I use wxpython) which uses that script as its model while leaving model to function as stand-alone python script as it is right now. I know it is the question of inheritance and polymorphism but I am not clear about the approach I should take. Any guidelines will be greatly appreciated.
Converting existing command-line script to GUI in python
0.099668
0
0
2,037
9,929,170
2012-03-29T16:05:00.000
0
0
0
0
linux,unicode,numpy,python-2.7,ucs
9,993,744
1
true
0
0
I suggest that a quick solution to these sort of complications is that you use the Enthought Python Distribpotion (EPD) on Linux which includes a wide range of extensions. Cheers.
1
0
1
I have installed Numpy using ActivePython and when I try to import numpy module, it is throwing the following error: ImportError: /opt/ActivePython-2.7/lib/python2.7/site-packages/numpy/core/multiarray.so: undefined symbol: PyUnicodeUCS2_FromUnicode I am fairly new to python, and I am not sure what to do. I appreciate if you could point me to the right direction. Should I remove python and configure its compilation with the "--enable-unicode=ucs2" or "--with-wide-unicode" option? Cheers OS: Fedora 16, 64bit; Python version: Python 2.7.2 (default, Mar 26 2012, 10:29:24); The current compile Unicode version: ucs4
Numpy needs the ucs2
1.2
0
0
1,398
9,935,224
2012-03-29T23:47:00.000
3
0
0
0
python,user-interface,wxpython
9,935,305
2
true
0
1
Pyqt/pyside/Qt has the newer declarative QML which seems to have a application geared to a kiosk type interface. You can basically design something in Photoshop and use it as your custom UI
1
3
0
I've been toying with wxPython, but it seems mostly geared at 'standard' applications -- things with native looking file menu systems and toolbars and whatnot. My needs are pretty simple. I just need to be able play some mp3s, show some images, and be able to package it down to an .exe and .dmg. Also, being able to play an small mp4 would be grand. Unfortunately, I realize that there is no definitive answer to this question, and therefore doesn't exacltly fit the stack overflow format, but a nudge in the right direction would be greatly appreciated!
Is there a preferred framework for non-standard, non-native kiosk style GUI applications?
1.2
0
0
835
9,938,238
2012-03-30T06:50:00.000
0
1
0
0
python,signals
9,939,503
1
false
0
0
The Python callback code is not actually called right away in Python. The C code in Python just sets a flag when it gets a signal. It only runs the handler when it returns to the interpreter. If your code path is currently working in an extension module in compiled code the handler won't get run until it finishes. The only way to fix it is to ensure that the execution path doesn't spend a lot of time in a C function. What function are you running at that time? Another culprit is the standard time.sleep() method. Use signal.pause() instead.
1
2
0
I am registering a signal for remote debugging: signal.signal(signal.SIGUSR1, lambda x,y: remote_debug(x, y, emp_id)) While normally very fast, log statements show this command (register) sometimes takes 5 to 10 seconds to execute. What is causing this? How can I fix it?
What can make signal.signal block for a long time?
0
0
0
69
9,939,238
2012-03-30T08:13:00.000
2
0
0
0
python,zeromq
28,609,198
3
false
0
0
From the ØMQ guide: From ZeroMQ v3.x, filtering happens at the publisher side when using a connected protocol (tcp:// or ipc://). Using the epgm:// protocol, filtering happens at the subscriber side. In ZeroMQ v2.x, all filtering happened at the subscriber side.
1
2
1
I am trying to implement a broker using zeromq PUB/SUB(python eventlets). zeromq 2.1 does not seem to implement filtering at publisher and all messages are broadcasted to all subscribers which inturn apply filter. Is there some kind of workaround to achieve filtering at publisher. If not how bad is the performance if there are ~25 publishers and 25 subscribers exchanging msgs @ max rate of 200 msgs per second where msg_size ~= 5K through the broker. Are there any opensource well-tested zero-mq broker implementations.??
ZeroMQ PUB/SUB filtering and performance
0.132549
0
0
4,347
9,942,206
2012-03-30T11:39:00.000
0
0
0
0
java,python,django,postgresql,user-activity
9,942,327
5
false
1
0
In your log table you can have various columns, including: user_id (the user that did the action) activity_type (the type of activity, such as view or commented_on) object_id (the actual object that it concerns, such as the Article or Media) object_type (the type of object; this can be used later, in combination with object_id to lookup the object in the database) This way, you can keep track of all actions the users do. You'd need to update this table whenever something happens that you wish to track.
2
0
0
I have a web application build in Django + Python that interact with web services (written in JAVA). Now all the database management part is done by web-services i.e. all CRUD operations to actual database is done by web-services. Now i have to track all User Activities done on my website in some log table. Like If User posted a new article, then a new row is created into Articles table by web-services and side by side, i need to add a new row into log table , something like "User : Raman has posted a new article (with ID, title etc)" I have to do this for all Objects in my database like "Article", "Media", "Comments" etc Note : I am using PostgreSQL So what is the best way to achieve this..?? (Should I do it in PostgreSQL OR JAVA ..??..And How..??)
How to store all user activites in a website..?
0
1
0
2,693
9,942,206
2012-03-30T11:39:00.000
1
0
0
0
java,python,django,postgresql,user-activity
9,942,819
5
true
1
0
So, you have UI <-> Web Services <-> DB Since the web services talk to the DB, and the web services contain the business logic (i.e. I guess you validate stuff there, create your queries and execute them), then the best place to 'log' activities is in the services themselves. IMO, logging PostgreSQL transactions is a different thing. It's not the same as logging 'user activities' anymore. EDIT: This still means you create DB schema for 'logs' and write them to DB. Second EDIT: Catching log worthy events in the UI and then logging them from there might not be the best idea either. You will have to rewrite logging if you ever decide to replace the UI, or for example, write an alternate UI for, say mobile devices, or something else.
2
0
0
I have a web application build in Django + Python that interact with web services (written in JAVA). Now all the database management part is done by web-services i.e. all CRUD operations to actual database is done by web-services. Now i have to track all User Activities done on my website in some log table. Like If User posted a new article, then a new row is created into Articles table by web-services and side by side, i need to add a new row into log table , something like "User : Raman has posted a new article (with ID, title etc)" I have to do this for all Objects in my database like "Article", "Media", "Comments" etc Note : I am using PostgreSQL So what is the best way to achieve this..?? (Should I do it in PostgreSQL OR JAVA ..??..And How..??)
How to store all user activites in a website..?
1.2
1
0
2,693
9,942,423
2012-03-30T11:54:00.000
0
1
0
0
php,python,mysql,request,ip
9,942,581
3
false
0
0
This will not work, as you will always must have your client responding. I suggest using the client (eg. in html using javascript) to make a connection (ping) every minute from your script on the client to your server, and in your cronjobs letting a script run every x minutes to update the clients that didn't within x.
2
0
0
I'm making a server which is controlled by php scripts, i have clients (androidphones) who calls these script to control the server. I'm saving the ip's the php receives to the DB. now i'm looking for a way to check if these ip's are still reachable.. this is what i tried so far: Cron job -> i'm developing with usbwebserver so i cant use php from cmd make a ping request to the ip from the php script: if available it will return rather "fast" but if it fails i get the maximum excution error. this way of working get me the results i want but without the possibilty of threading this, this solution isnt going to perform in time as i wanted. is there a way this approach could work? something i'm considering: - make a request to de device through http, and do something with the result i get back, is this even possible (making a request from server to client)? making a python script that gets the ip from db and makes the ping calls and stores the results back into the db. making timestamps when a device connects and check timestamps from other devices, if max time was exceeded then update DB any suggestions?
PHP make a request check if client is available via ip
0
0
1
692
9,942,423
2012-03-30T11:54:00.000
0
1
0
0
php,python,mysql,request,ip
9,942,749
3
false
0
0
There is absolutely no point in such checking. You will always have these IPs UP. Just because an android client seldom have a real IP but using Net via some router/proxy. Web is one-way road. To implement a heart-beat feature you have to make your android clients to ping server.
2
0
0
I'm making a server which is controlled by php scripts, i have clients (androidphones) who calls these script to control the server. I'm saving the ip's the php receives to the DB. now i'm looking for a way to check if these ip's are still reachable.. this is what i tried so far: Cron job -> i'm developing with usbwebserver so i cant use php from cmd make a ping request to the ip from the php script: if available it will return rather "fast" but if it fails i get the maximum excution error. this way of working get me the results i want but without the possibilty of threading this, this solution isnt going to perform in time as i wanted. is there a way this approach could work? something i'm considering: - make a request to de device through http, and do something with the result i get back, is this even possible (making a request from server to client)? making a python script that gets the ip from db and makes the ping calls and stores the results back into the db. making timestamps when a device connects and check timestamps from other devices, if max time was exceeded then update DB any suggestions?
PHP make a request check if client is available via ip
0
0
1
692
9,945,206
2012-03-30T14:45:00.000
1
1
0
0
python,automation,notifications
9,945,337
7
false
1
0
If I understand well, the idea of your program is to do an automated browsing session. So yes, it's possible. It's not important in what the website is programmed (cgi, php etc). All you need is to send data through post/get (like a real browser) and process the return (regexp and so on). Good luck
2
4
0
I am a newborn programmer still programming from the book on my Alt+Tab. One of the first programs I want to create is to help my mom in her work. I need to know if I can use Python to create it. It needs to: Go on-line and log-in with account / pass. Do a search with specific criteria (use the site's search engine) View all the results and pick only the newest ones. Sort them out. Notify me so that the newest adds are noticed the moment they are posted on the website. From what I see the site says : .cgi in the end. I know python can connect, download the text from a page and sort the wanted info, but can it log in, use the search engine and pick the options I need? I don't want to skip my learning process, but I am so serious about this project I am ready to put Python on hold and start learning some language that can do it! I will very much appreciate your guidance! Thank you for your time! AJ
Can web automation be done in Python?
0.028564
0
1
10,966
9,945,206
2012-03-30T14:45:00.000
1
1
0
0
python,automation,notifications
9,945,530
7
false
1
0
I would point out that depending upon what site you are on, there may be a more efficient way (perhaps an exposed web service) than scraping data from the page and working with mechanize/selenium to do what you want. If you are on the web, browser driver tools are the hammers, and they will get the screws in the wood, but sometimes another tool will work better.
2
4
0
I am a newborn programmer still programming from the book on my Alt+Tab. One of the first programs I want to create is to help my mom in her work. I need to know if I can use Python to create it. It needs to: Go on-line and log-in with account / pass. Do a search with specific criteria (use the site's search engine) View all the results and pick only the newest ones. Sort them out. Notify me so that the newest adds are noticed the moment they are posted on the website. From what I see the site says : .cgi in the end. I know python can connect, download the text from a page and sort the wanted info, but can it log in, use the search engine and pick the options I need? I don't want to skip my learning process, but I am so serious about this project I am ready to put Python on hold and start learning some language that can do it! I will very much appreciate your guidance! Thank you for your time! AJ
Can web automation be done in Python?
0.028564
0
1
10,966
9,946,744
2012-03-30T16:18:00.000
1
1
0
0
python,ssh,paramiko
9,947,158
1
true
0
0
If you don't know where the public key file is located, Paramiko can't help you either - it also needs you to specify where it is. You can of course try the usual places (starting by parsing ~/.ssh/config if available), but you don't need Paramiko for that.
1
0
0
I'm writing a python program to get rsa public key. Is there a way to get it via paramiko or I just read it like plain text and with the assumption from id_rsa.pub?
Can we get public key using Paramiko? Or just read it like plain text?
1.2
0
1
215
9,947,703
2012-03-30T17:28:00.000
1
0
0
0
python,django,web-applications,frameworks,pyramid
9,947,834
2
false
1
0
I believe that at this point you might want to think more about the overall architecture of your application rather than frameworks. For Example Single Tier - Just a simple webapp, using simple file or object storage Two Tier - Webapp + Relational Database. The webapp contains the presentation logic + business logic using MVC principles Three Tier - Webapp + Middle Tier + Relation Database. In this setting, the Middle Tier will basically contain all the business & processing logic. The Webapp is then just a presentation layer Once you decide the architecture, you can then start thinking about which framework to use for each of the component of the architecture. I believe progressing this way will be less confusing and will give clarity of thought.
2
1
0
I'm slightly confused on what is meant by a "web application". I.e. Django positions itself as "a web framework" for the development of "web apps", quite similar to the description of Pyramid. What I'm looking for is a framework for an application that has a browser interface but is very database driven. In short: It's a system that should handle transaction and subscriptions. These transactions are registered through a web interface. The backend consists of XML/JSON feeds of these subscriptions/transactions and an administrative interface to generate statistics and reports. Quite similar to a ticketing/box office system. Now: Is it a good decision to start out with something like Django/Pyramid even though they seem more focussed on the creation of "websites" rather than (scalable) input/output "applications". Is there any python framework that I'm better of using or are they perfectly suited for the kind of software that I'm describing? Any help would be greatly appreciated!
Python frameworks: Website/CMS vs application?
0.099668
0
0
443
9,947,703
2012-03-30T17:28:00.000
3
0
0
0
python,django,web-applications,frameworks,pyramid
9,947,817
2
true
1
0
I don't know Pyramid at the time of writing so I'll answer the Django part, though I can imagine the answer to apply to Pyramid as well as the distinction between websites and web application is quite vague. Django is suitable for both websites and web applications: you can create an informative website for your local library as well as an all-in web application with lots of interactive features. Django simply facilitates the creation of the backend of a web system. Both websites and web applications use databases, have caching and can have interactive parts with forms. It's just that websites are usually just for informing the user (most sites out there) or interacting with others (such as forums). A web application is best described with some examples, such as webmail, administrative interfaces, Google Docs, etc; it serves as a replacement of a desktop application. From a technical perspective, there's no clear cut thing that separates the world of websites from web applications, it's just a matter of what you create with your web framework. To answer your question, Django is quite suitable for creating a database-driven web application as it supports multiple databases, caching, autmatic creation and handling of forms, etc. I can imagine Pyramid to be suitable as well but I can't answer that. It's good to explore your options.
2
1
0
I'm slightly confused on what is meant by a "web application". I.e. Django positions itself as "a web framework" for the development of "web apps", quite similar to the description of Pyramid. What I'm looking for is a framework for an application that has a browser interface but is very database driven. In short: It's a system that should handle transaction and subscriptions. These transactions are registered through a web interface. The backend consists of XML/JSON feeds of these subscriptions/transactions and an administrative interface to generate statistics and reports. Quite similar to a ticketing/box office system. Now: Is it a good decision to start out with something like Django/Pyramid even though they seem more focussed on the creation of "websites" rather than (scalable) input/output "applications". Is there any python framework that I'm better of using or are they perfectly suited for the kind of software that I'm describing? Any help would be greatly appreciated!
Python frameworks: Website/CMS vs application?
1.2
0
0
443
9,949,533
2012-03-30T19:47:00.000
2
0
1
0
python
26,517,982
4
false
0
0
Not an answer exactly, but it should be noted that eval and literal_eval are not the same thing. The ast.literal_eval won't run arbitrary code. That said, I agree with using JSON; I just wanted to point out that eval != literal_eval
3
16
0
I am converting 2 MB of data as a string into a dict. The input is serialized in JSON. Anyways I am currently using ast.literal_eval and I get the dictionary I want, but then when I tried just running eval it seems to run faster, and also returns the same result. Is there any reason to use the ast module or the json module when eval works just fine?
python eval vs ast.literal_eval vs JSON decode
0.099668
0
0
17,888
9,949,533
2012-03-30T19:47:00.000
25
0
1
0
python
9,949,553
4
false
0
0
Yes, there's definitely a reason: eval() is evil. Your code might read untrusted data one day, an this would allow an attacker to run arbitrary code on your machine. You shouldn't use ast.literal_eval() to decode JSON either. It cannot decode every valid JSON string and is not meant to be used for this purpose. Simply use json.loads(), it's reasonably fast.
3
16
0
I am converting 2 MB of data as a string into a dict. The input is serialized in JSON. Anyways I am currently using ast.literal_eval and I get the dictionary I want, but then when I tried just running eval it seems to run faster, and also returns the same result. Is there any reason to use the ast module or the json module when eval works just fine?
python eval vs ast.literal_eval vs JSON decode
1
0
0
17,888
9,949,533
2012-03-30T19:47:00.000
16
0
1
0
python
9,949,575
4
false
0
0
No. Unless you hit one of two scenarios: That's not JSON! Someone puts __import__('os').system('rm -rf /') in the file instead. You are boned. It's JSON, but not the Python-like part! Someone puts true, false, null, or a Unicode escape somewhere in it. Happy birthday.
3
16
0
I am converting 2 MB of data as a string into a dict. The input is serialized in JSON. Anyways I am currently using ast.literal_eval and I get the dictionary I want, but then when I tried just running eval it seems to run faster, and also returns the same result. Is there any reason to use the ast module or the json module when eval works just fine?
python eval vs ast.literal_eval vs JSON decode
1
0
0
17,888
9,950,362
2012-03-30T21:01:00.000
26
0
1
1
python,setuptools,distutils
9,960,426
2
true
0
0
setuptools monkey-patches some parts of distutils when it is imported. When you use easy_install to get a distutils-based project from PyPI, it will create an egg (pip may do that too). To do the same thing locally (i.e. in a directory that’s a code checkout or an unpacked tarball), use this trick: python -c "import setuptools; execfile('setup.py')" bdist_egg.
1
17
0
I vaguely remember some sort of setuptools wrapper that would generate .egg files from distutils source. Can someone jog my memory?
How do I create Python eggs from distutils source packages?
1.2
0
0
15,618
9,951,216
2012-03-30T22:35:00.000
2
0
0
0
python,django,post
9,951,986
1
true
1
0
urllib2 is the appropriate way to post data if you're looking for python standard library. Django doesn't provide a specific method to do this (as well as it shouldn't). Django goes out of it's way to not simply reinvent tools that already exist in the the standard library (except email...), so you should never really fear using something out of the python standard library. requests is also great, but not standard library. Nothing wrong with that though.
1
1
0
I would appreciate some help here. Google checkout has many ways to send it checkout data. I am using the XML server-to-server. I have everything ready and now I want to throw some xml at google. I have been doing some reading and I know of a couple of ways to do this, one with urllib, another with pyCurl, but I am using django over here and I searched the Django api for some way to POST data to another site and I havent fallen upon anything. I really would like to use the django way, if there is one because I feel it would be more fluid and right, but if you all don't know of any way I will probably use urllib.
Posting data to another Site with Django
1.2
0
1
471
9,952,327
2012-03-31T01:49:00.000
1
1
0
1
eclipse,python-3.x,pydev,generated-code
9,998,578
2
true
1
0
It should be possible to do what you want using an external builder inside Eclipse... Right click project > properties > builders > new > program, then configure the program as python having as a parameter the module to run and receiving as arguments also the ${build_files} variable (if it's a python script, you have to put your Python.exe as the executable, your main file as an argument and then the ${build_files} variable).
1
0
0
I'm developing a system, and I have build a code generator that emits a bunch of classes based on a configuration file. I would like to configure PyDev to invoke the generator for me whenever the configuration file (or the generator source) changes. I know that this is possible "in theory" because e.g., the ANTLR plugin for Eclipse does this in Java. Is there any kind of support in PyDev for doing this? If not, is there some other Eclipse hackery that I can use to get this working?
How do I generate code under Eclipse+PyDev?
1.2
0
0
339
9,952,873
2012-03-31T03:50:00.000
0
1
0
1
python,google-app-engine,google-apps,google-signin,gaeunit
9,953,084
2
false
1
0
Two situations: Local Dev server: login is mocked via a simple web form. You can do a http POST to log in. Production server: login goes through the Google auth infrastructure. No way to mock this. To make this work you'd need to code around it.
1
0
0
I am currently using gaeunit to perform automated test on my google app engine application. I am wondering whether it's possible to simulate the user login action using his/her google account using gaeunit? Thank you very much.
How to simulate Google login using gaeunit
0
0
0
401
9,954,745
2012-03-31T09:33:00.000
1
0
0
0
python,heroku,web2py
14,190,998
3
false
1
0
It may be a problem with the DB setup. By default web2py only supports sqlite or Google App Engine (GAE). It's probably trying to initialize sqlite databases on Heroku's read-only filesystem. Either disable the DB code temporarily to see if this is indeed the case, or configure a connection to a supported database (MySQL, S3, etc).
1
4
0
I'm having a lot of trouble with getting web2py to work on Heroku. I can't even get a basic app to work. Whenever I go to my herokuapp page, it says Application Error An error occurred in the application and your page could not be served. Please try again in a few moments. If you are the application owner, check your logs for details."
How do I use web2py on Heroku?
0.066568
0
0
1,549
9,955,517
2012-03-31T11:34:00.000
1
0
1
0
java,python,compiler-construction,antlr,semantics
9,955,649
3
false
0
0
ANTLR allows you to specify semantics in terms of actions associated with grammar rules. For simple tasks this may be convenient, but for larger grammars all you usually do is to generate an AST (Abstract Syntax Tree), i.e. a representation of what you parsed that's more convenient to handle from within a program than a very long string. Whether or how much of this is contained in the example you are using is rather hard to say without seeing the code ;-)
3
0
0
I am currently using a Python 2.5 sample from the ANTLR website. I'm actually wondering if the grammar already produces semantics as well.If there is none, what can I do or what can I use(tools) for generating semantics for python after parsing it with ANTLR?
Does ANTLR provide semantics
0.066568
0
0
121
9,955,517
2012-03-31T11:34:00.000
2
0
1
0
java,python,compiler-construction,antlr,semantics
9,955,577
3
true
0
0
There's no tool to generate a language's semantics, that's something you have to implement yourself. Now that you have parsed Python code, you can do some necessary processing first, output it as Python code again and use an existing implementation of the Python language for execution.
3
0
0
I am currently using a Python 2.5 sample from the ANTLR website. I'm actually wondering if the grammar already produces semantics as well.If there is none, what can I do or what can I use(tools) for generating semantics for python after parsing it with ANTLR?
Does ANTLR provide semantics
1.2
0
0
121
9,955,517
2012-03-31T11:34:00.000
1
0
1
0
java,python,compiler-construction,antlr,semantics
9,955,542
3
false
0
0
ANTLR handles the parsing, but not the semantics; it's a parser generation tool, after all. If you added semantics, you'd have a full python implementation (modulo fleshing out the libraries).
3
0
0
I am currently using a Python 2.5 sample from the ANTLR website. I'm actually wondering if the grammar already produces semantics as well.If there is none, what can I do or what can I use(tools) for generating semantics for python after parsing it with ANTLR?
Does ANTLR provide semantics
0.066568
0
0
121
9,956,847
2012-03-31T14:39:00.000
1
0
0
0
python,go,swig
9,957,173
1
false
0
0
One of the Go compilers produces C (cgo). I have never looked at it, but there may be a path to calling those functions from Python using SWIG. Also their is Cython, which converts a form-of-Python to C, so that may provide another more direct path by combining the two with C as the glue, and without SWIG. I was told by a Cython user at Python WM, that with care, Cython can produce C which needs no 'magic' run-time to work. Their technique is to use Cython mechanisms e.g.cdef, to make their Python closer to C. By changing the Cython source then iteratively looking at the Cython output, they said they can cause Python run-time to 'disappear', and reach 'pure' C. This is not ideal, but might be better than nothing. So you might be able to use that mechanisms to wrap around Go functions which have been compiled to C. BUT this approach would restrict you to using Cython, which might be too much of a constraint.
1
2
0
Can SWIG be used to call Go functions from Python? The Go examples I have seen in SWIG all seem to call C/C++ functions from Go.
SWIG: Calling Go from Python
0.197375
0
0
754
9,957,985
2012-03-31T17:14:00.000
1
0
1
0
python,multithreading,communication,pipe
9,960,643
2
false
0
0
I think you should take a look at the "candygram" message passing extension.
2
1
0
Thanks for your attention I am writing a simulation engine in python using "threading" module in python. One of the things that my simulator has to do is to be able to do all-to-all communication. Suppose there are 'n' threads (All n-threads are not instances of the same class). So for example I have 3 classes of threads m is an instance of class type 'Storage' s is an instance of class type 'Super' c1, c2... cn are instances of class type 'Child' m, s, c1, c2, ... cn might have to communicate with each other 1:1. Is it wise to maintain a one-to-one connection with each other ? My solution is to build an arbiter thread which will accept messages and route them to the target thread. That way, I will have fewer pipes going around. Do you think this is a good idea ? Is there a readymade python module/solution that can do this kind of arbitration ? RRS
All-to-All thread communication in Python
0.099668
0
0
350
9,957,985
2012-03-31T17:14:00.000
1
0
1
0
python,multithreading,communication,pipe
9,960,695
2
true
0
0
I think your solution of a broadcast Queue, and EventBus thread is the most common pattern. Queue is part of standard library, and a thread that consumes singleton queue and broadcasts to registered consumers is trivial to implement. Alternatively you could link those threads to form a cycle and pass message to the successor, ignoring messages originating from self.
2
1
0
Thanks for your attention I am writing a simulation engine in python using "threading" module in python. One of the things that my simulator has to do is to be able to do all-to-all communication. Suppose there are 'n' threads (All n-threads are not instances of the same class). So for example I have 3 classes of threads m is an instance of class type 'Storage' s is an instance of class type 'Super' c1, c2... cn are instances of class type 'Child' m, s, c1, c2, ... cn might have to communicate with each other 1:1. Is it wise to maintain a one-to-one connection with each other ? My solution is to build an arbiter thread which will accept messages and route them to the target thread. That way, I will have fewer pipes going around. Do you think this is a good idea ? Is there a readymade python module/solution that can do this kind of arbitration ? RRS
All-to-All thread communication in Python
1.2
0
0
350