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
3,184,089
2010-07-06T06:50:00.000
0
0
1
0
python,tuples,coupling
3,184,127
3
false
0
0
In those cases, I tend to use dictionaries. If only to have things easily understandable for myself when I come back a bit later to use the code. I don't know if it's a "huge overhead". I guess it depends on how often you do it and what it is used for. I start off with the easiest solution and optimize when I really need to. It surprisingly seldom I need to change something like that.
1
1
0
I have a small Python program consisting of very few modules (about 4 or so). The main module creates a list of tuples, thereby representing a number of records. These tuples are available to the other modules through a simple function that returns them (say, get_records()). I am not sure if this is good design however. The problem being that the other modules need to know the indexes of each element in the tuple. This increases coupling between the modules, and isn't very transparent to someone who wants to use the main module. I can think of a couple of alternatives: Make the index values of the tuple elements available as module constants (e.g., IDX_RECORD_TITLE, IDX_RECORD_STARTDATE, etc.). This avoids the need of magic numbers like title = record[3]. Don't use tuples, but create a record class, and return a list of these class objects. The advantage being that the class methods will have self-explaining names like record.get_title(). Don't use tuples, but dictionaries instead. So in this scenario, the function would return a list of dictionaries. The advantage being that the dictionary keys are also self-explanatory (though someone using the module would need to know them). But this seems like a huge overhead. I find tuples to be one of the great strengths of Python (very easy to pass compound data around without the coding overhead of classes/objects), so I currently use (1), but still wonder what would be the best approach.
Is it OK to exchange tuples between Python modules?
0
0
0
245
3,184,821
2010-07-06T08:57:00.000
1
0
1
0
python,png,palette,color-palette
3,184,867
2
false
0
0
If it's a palletted image then you can use the getcolors() method once you have loaded it into PIL. If it's a RGB or RGBA image then you'll need to do color reduction until you have 256 colors at most.
1
2
0
What would be the best python based library for generating 8-bit palette from the given .png file. As in photoshop generating under .pal format. PS: Input PNG is already in 8 bit format. (paletted) Regards
Generation of 8 bit palette from png file via Python
0.099668
0
0
1,898
3,184,974
2010-07-06T09:20:00.000
1
1
0
1
python,ssh,exit,signals
3,186,685
1
false
0
0
Well, the reason they're not shutting down when your ssh session terminates is because HUP is the signal used by a parent to inform its children that they should shut down. If you're overriding the behavior of this signal, then your processes will not automatically shut down when the SSH session is closed. As for why you cannot kill -9 them, however, I'm at a loss. The only thing I've seen that causes that behavior is processes blocked on misbehaving filesystems (nfs & unionfs being the two I've encountered the problem with).
1
0
0
I've written a python script which does some curses and pysqlite stuff, but I've noticed that in occasions where I've been running this script over ssh when that ssh session is killed for whatever reason the python script doesn't actually exit, instead it ends up as being a child of init and just stays there forever. I can't kill -9 them or anything. They also increase the reported system load by 1. Currently I have 8 of these mostly dead processes hanging around, and the server has a load average of 8.abit. I take it this is because there is some sort of resource that these scripts are waiting on, but lsof shows nothing actually open by them, all data files they were using are listed as deleted etc... and they are using no cpu time whatsoever. I'm doing some signal checking in the script, calling out to do some refresh routines on a HUP, but nothing else, not forking or anything and I'm at a loss as to why the scripts are not just shuffling off when I close my ssh session. Thanks Chris
Python scripts (curses + pysqlite) hanging after parent shell goes away
0.197375
0
0
281
3,185,263
2010-07-06T10:05:00.000
2
0
0
1
python,linux
3,185,279
3
true
0
0
Add a signal handler for SIGHUP. (x)inetd sends this upon the socket disconnecting.
2
0
0
This may or may not being a coding issue. It may also be an xinetd deamon issue, i do not know. I have a python script which is triggered from a linux server running xinetd. Xinetd has been setup to only allow one instance as I only want one machine to be able to connect to the service, which is therefore also limited by IP. Currently when the client connects to xinetd the service works correctly and the script begins sending its output to the client machine. However, when the client disconnects (i.e: due to reboot), the process is still alive on the server, and this blocks the ability for the client to connect once its finished rebooting or so on. Q: How can i detect in python that the client has disconnected. Perhaps i can test if stdout is no longer being read from by the client (and then exit the script), or is there a much eaiser way in xinetd to have the child process be killed when the client disconnects ? (I'm using python 2.4.3 on RHEL5 linux - solutions for 2.4 are needed, but 3.1 solutions would be useful to know also.)
python xinetd client disconnection handling
1.2
0
0
864
3,185,263
2010-07-06T10:05:00.000
0
0
0
1
python,linux
7,097,401
3
false
0
0
Monitor the signals sent to your proccess. Maybe your script isn't responding to the SIGHUP sent by xinet, monitor the signal and let it die.
2
0
0
This may or may not being a coding issue. It may also be an xinetd deamon issue, i do not know. I have a python script which is triggered from a linux server running xinetd. Xinetd has been setup to only allow one instance as I only want one machine to be able to connect to the service, which is therefore also limited by IP. Currently when the client connects to xinetd the service works correctly and the script begins sending its output to the client machine. However, when the client disconnects (i.e: due to reboot), the process is still alive on the server, and this blocks the ability for the client to connect once its finished rebooting or so on. Q: How can i detect in python that the client has disconnected. Perhaps i can test if stdout is no longer being read from by the client (and then exit the script), or is there a much eaiser way in xinetd to have the child process be killed when the client disconnects ? (I'm using python 2.4.3 on RHEL5 linux - solutions for 2.4 are needed, but 3.1 solutions would be useful to know also.)
python xinetd client disconnection handling
0
0
0
864
3,186,576
2010-07-06T13:28:00.000
1
0
0
0
python,pyqt4
3,187,108
1
true
0
1
i finally found out how. there's a signal call anchorClicked(QUrl) that should do the trick :)
1
0
0
is it possible to connect a href link in QTextBrowser to a slot? I want to make something that looks like a link in a QTextBrowser, but when user clicked on it, it will call one of the methods. Is that possible? if that is not, what is a good alternative? Thanks in advance.
is it possible to connect a href link in QTextBrowser to a slot?
1.2
0
0
198
3,187,301
2010-07-06T14:49:00.000
3
0
0
1
python,perl,bash
3,187,323
3
true
0
0
Just do python /path/to/my/python/script.py.
1
0
0
I previously used to copy Python/Perl scripts to access from my bash script. Duplication is not a good idea I know! Is there a way to call them from bin or libs folder that we have set up? For instance : My python script resides in /home/ThinkCode/libs/python/script.py My bash script resides in /home/ThinkCode/NewProcess/ProjectA/run.sh Now I want to use/call script.py from run.sh Thank you!
How do I call a Python/Perl script in bin folder from a Bash script?
1.2
0
0
1,145
3,188,024
2010-07-06T16:07:00.000
1
0
1
0
python,regex
3,188,036
3
false
0
0
I personally use your first approach where the expressions I'll reuse are compiled early on and available globally to the functions / methods that will need them. In my experience this is reliable, and reduces total compile time for them.
1
2
0
Is there a Pythonic 'standard' for how regular expressions should be used? What I typically do is perform a bunch of re.compile statements at the top of my module and store the objects in global variables... then later on use them within my functions and classes. I could define the regexs within the functions I would be using them, but then they would be recompiled every time. Or, I could forgo re.compile completely, but if I am using the same regex many times it seems like recompiling would incur unnecessary overhead.
Python regular expression style
0.066568
0
0
266
3,188,274
2010-07-06T16:38:00.000
1
0
0
1
python,django,google-app-engine
3,192,350
1
true
1
0
You probably are still going to hit the DB once to get the session record, which is where the user_id field is stored. Then you may need to side-step the lazy evaluation done in the django.contrib.auth.middleware code. It's not difficult, but you need to read the code and find exactly the info you want and then get at it without triggering any of the magic. Oh, and if you want to mumble your way through the Session objects directly you will have to call session.get_decoded() to get a dict. The field you want (if it exists) is _auth_user_id.
1
1
0
I'm using Django on GAE. When I say user = request.user, I believe it hits the datastore to fetch the User entity. I would like to just get the key for the currently logged in user, because that will allow me to get the user-related data I need from the memcache.
Get the key of logged-in user with no DB access in Django on Google App Engine?
1.2
0
0
64
3,188,289
2010-07-06T16:39:00.000
0
0
0
0
python,mysql,performance
3,188,555
1
false
0
0
Two ideas: MySQL may have query caching enabled, which makes it difficult to get accurate timing when you run the same query repeatedly. Try changing the ID in your query to make sure that it really does run in 3-4 seconds consistently. Try using strace on the python process to see what it is doing during this time.
1
0
0
I'm writing a script for exporting some data. Some details about the environment: The project is Django based I'm using raw/custom SQL for the export The database engine is MySQL. The database and code are on the same box.- Details about the SQL: A bunch of inner joins A bunch of columns selected, some with a basic multiplication calculation. The sql result has about 55K rows When I run the SQL statement in the mysql command line, it takes 3-4 seconds When I run the SQL in my python script the line cursor.execute(sql, [id]) takes over 60 seconds. Any ideas on what might be causing this?
Python MySQL Performance: Runs fast in mysql command line, but slow with cursor.execute
0
1
0
705
3,189,138
2010-07-06T18:34:00.000
3
1
0
0
python,firewall
3,189,187
6
false
0
0
I'm sure it's probably possible, but ill-advised. As mcandre mentions, most OSes couple the low level networking capabilities you need for a firewall tightly into the kernel and thus this task is usually done in C/C++ and integrates tightly with the kernel. The microkernel OSes (Mach et al) might be more amenable than linux. You may be able to mix some python and C, but I think the more interesting discussion here is going to be around "why should I"/"why shouldn't I" implement a firewall in python as opposed to just is it technically possible.
4
13
0
Is it possible to write a firewall in python? Say it would block all traffic?
Is it possible to write a firewall in python?
0.099668
0
1
31,230
3,189,138
2010-07-06T18:34:00.000
2
1
0
0
python,firewall
3,189,232
6
false
0
0
"Yes" - that's usually the answer to "is it possible...?" questions. How difficult and specific implementations are something else entirely. I suppose technically in a don't do this sort of way, if you were hell-bent on making a quick firewall in Python, you could use the socket libraries and open connections to and from yourself on every port. I have no clue how effective that would be, though it seems like it wouldn't be. Of course, if you're simply interested in rolling your own, and doing this as a learning experience, then cool, you have a long road ahead of you and plenty of education. OTOH, if you're actually worried about network security there are tons of other products out there that you can use, from iptables on *nix, to ZoneAlarm on windows. Plenty of them are both free and secure so there's really no reason to roll your own except on an "I want to learn" basis.
4
13
0
Is it possible to write a firewall in python? Say it would block all traffic?
Is it possible to write a firewall in python?
0.066568
0
1
31,230
3,189,138
2010-07-06T18:34:00.000
4
1
0
0
python,firewall
3,189,540
6
false
0
0
I'm sure in theory you could achieve what you want, but I believe in practice your idea is not doable (if you wonder why, it's because it's too hard to "interface" a high level language with the low level kernel). What you could do instead is some Python tool that controls the firewall of the operating system so you could add rules, delete , etc. (in a similar way to what iptables does in Linux).
4
13
0
Is it possible to write a firewall in python? Say it would block all traffic?
Is it possible to write a firewall in python?
0.132549
0
1
31,230
3,189,138
2010-07-06T18:34:00.000
3
1
0
0
python,firewall
15,045,900
6
false
0
0
Interesting thread. I stumbled on it looking for Python NFQUEUE examples. My take is you could create a great firewall in python and use the kernel. E.g. Add a linux fw rule through IP tables that forward sys packets (the first) to NFQUEUE for python FW to decide what to do. If you like it mark the tcp stream/flow with a FW mark using NFQUEUE and then have an iptables rule that just allows all traffic streams with the mark. This way you can have a powerful high-level python program deciding to allow or deny traffic, and the speed of the kernel to forward all other packets in the same flow.
4
13
0
Is it possible to write a firewall in python? Say it would block all traffic?
Is it possible to write a firewall in python?
0.099668
0
1
31,230
3,189,206
2010-07-06T18:42:00.000
4
0
1
0
python
3,189,234
6
true
0
0
It depends on your operating system. If you have python 2.6 installed, you need to change your environment path to point to the 2.6 executable rather than the 2.5 executable. Do a Google search for changing your PATH variable on your operating system.
2
7
0
New to Python and programming in general. I want to "install" a module from the command line for v 2.6, but it looks like my default Python is 2.5. (python --version returns 2.5.4) How can I run my python setup.py build/install on 2.6 instead? Many thanks in advance, Brock
Windows Command Line Python Change Version
1.2
0
0
28,100
3,189,206
2010-07-06T18:42:00.000
-3
0
1
0
python
3,189,210
6
false
0
0
Download Python v2.6.
2
7
0
New to Python and programming in general. I want to "install" a module from the command line for v 2.6, but it looks like my default Python is 2.5. (python --version returns 2.5.4) How can I run my python setup.py build/install on 2.6 instead? Many thanks in advance, Brock
Windows Command Line Python Change Version
-0.099668
0
0
28,100
3,190,013
2010-07-06T20:35:00.000
0
1
0
0
python
3,190,568
3
false
0
1
Portability is one thing. There are even differences between python 2.x and 3.x that can make things difficult with C extensions, if the writer didn't update them. Another thing is that pure python code gives you a bit more possibilities to read, understand and even modify (although it is usually a bad sign if you need to do that for other peoples modules)
3
1
0
Are there any downsides in Python to using a library that is just a binding to a C library? Does that hurt the portability of your application? Anything else I should look out for?
What are the pros and cons in Python of using a c library vs a native python one
0
0
0
146
3,190,013
2010-07-06T20:35:00.000
4
1
0
0
python
3,190,053
3
false
0
1
C library is likely to have better performance, but needs to be recompiled for each platform. You can't use C libraries on Google App Engine
3
1
0
Are there any downsides in Python to using a library that is just a binding to a C library? Does that hurt the portability of your application? Anything else I should look out for?
What are the pros and cons in Python of using a c library vs a native python one
0.26052
0
0
146
3,190,013
2010-07-06T20:35:00.000
4
1
0
0
python
3,190,035
3
true
0
1
Of course using a C library hurts portability. It also prohibites you (in general) to use Jython or IronPython. I would only use a C library if I had no other option. This could happen if direct access to hardware is necessary or if special efficiency requirements apply.
3
1
0
Are there any downsides in Python to using a library that is just a binding to a C library? Does that hurt the portability of your application? Anything else I should look out for?
What are the pros and cons in Python of using a c library vs a native python one
1.2
0
0
146
3,190,122
2010-07-06T20:51:00.000
1
0
1
0
python,string,list,range,ascii
3,190,229
18
false
0
0
This is your 2nd question: string.lowercase[ord('a')-97:ord('n')-97:2] because 97==ord('a') -- if you want to learn a bit you should figure out the rest yourself ;-)
1
142
0
1. Print a-n: a b c d e f g h i j k l m n 2. Every second in a-n: a c e g i k m 3. Append a-n to index of urls{hello.com/, hej.com/, ..., hallo.com/}: hello.com/a hej.com/b ... hallo.com/n
Python: how to print range a-z?
0.011111
0
0
323,159
3,190,226
2010-07-06T21:04:00.000
1
0
1
1
python,windows
3,551,199
1
false
0
0
This is a very complex task. I woudl look at open-source forensic tools. You also should analyze the recylcing bin ( not completly deleted file ) For FAT you will not be able to get the first character of a deleted file. For some deleted files the metadata will be gone. NTFS is much more complex and time consuming due to the more complex nature of this file system.
1
0
0
I am wondering if it is possible to compile a list of deleted files on a windows file system, FAT or NTFS. I do not need to actually recover the files, only have access to their name and any other accessible time (time deleted, created etc). Even if I can run a cmd line tool to achieve this it would be acceptable. The application is being developed in Python, however if another language has the capability I could always create a small component implemented in that language. Thanks.
How to show list of deleted files in windows file system
0.197375
0
0
1,086
3,192,001
2010-07-07T04:51:00.000
0
0
1
0
python,zip,tar,lzma
44,927,799
2
false
0
0
if you can use python 3.3 and later, you could use the built-in lzma module
1
1
0
i need to create a lzma file with the existing .tar file and another metadata file to further create a zip file.
create a lzma file in python
0
0
0
1,411
3,192,747
2010-07-07T07:36:00.000
0
0
0
0
python,validation,formencode,wtforms,toscawidgets
3,219,559
5
false
1
0
it depends on what underlying framework you use. for django , built in form framework is best, while kay uses extended version of zine's form system and tipfy uses WTForms. django's built in system is best so far . what framework do you use under the hood ?
1
38
0
I would like a form validation library that 1.separate html generation from form validation; 2.validation errors can be easily serialized, eg. dumped as a json object What form validation library would you choose in a python web project?
Recommendation for python form validation library
0
0
0
21,514
3,193,012
2010-07-07T08:18:00.000
13
1
1
1
python,programming-languages,scripting,lua,dynamic-languages
3,193,910
7
false
0
0
Both Lua and Python can provide the features you mention, so choosing one of them will depend on other criteria. Lua is a lighter weight solution, it will have a much smaller disk footprint and likely a smaller memory overhead than Python too. For some uses it may be faster. Python has a much richer standard library, more mature third party libraries and a more expressive language. Both have been embedded into major applications. Python can be found in Blender, OpenOffice and Civilization 4. Lua can be found in World of Warcraft and Adobe Lightroom. I'd recommend looking at a few tutorials for each and the facilities available to embed them in your application and just choose the one that fits your brain best.
3
7
0
I am looking for a good scripting language to link to my program. I am looking for 2 important attributes: Scripting language should be hard linked into the executable (not requiring 3rd party installations). This is important to me to simplify distribution. Scripting should allow some run-time debugging option (When running a script inside my program I would like to easily run it inside a debugger while it is running in the context of my program) Can python,lua or some other language supply me with this?
Scripting Languages
1
0
0
932
3,193,012
2010-07-07T08:18:00.000
0
1
1
1
python,programming-languages,scripting,lua,dynamic-languages
3,217,793
7
false
0
0
I'll add Tcl to the mix. It's designed to be easily embedded into other programs.
3
7
0
I am looking for a good scripting language to link to my program. I am looking for 2 important attributes: Scripting language should be hard linked into the executable (not requiring 3rd party installations). This is important to me to simplify distribution. Scripting should allow some run-time debugging option (When running a script inside my program I would like to easily run it inside a debugger while it is running in the context of my program) Can python,lua or some other language supply me with this?
Scripting Languages
0
0
0
932
3,193,012
2010-07-07T08:18:00.000
1
1
1
1
python,programming-languages,scripting,lua,dynamic-languages
3,195,618
7
false
0
0
I really like Lua for embedding, but just as another alternative, JavaScript is easily embeddable in C, C++ (SpiderMonkey and V8) and Java (Rhino) programs.
3
7
0
I am looking for a good scripting language to link to my program. I am looking for 2 important attributes: Scripting language should be hard linked into the executable (not requiring 3rd party installations). This is important to me to simplify distribution. Scripting should allow some run-time debugging option (When running a script inside my program I would like to easily run it inside a debugger while it is running in the context of my program) Can python,lua or some other language supply me with this?
Scripting Languages
0.028564
0
0
932
3,193,346
2010-07-07T09:08:00.000
0
0
0
1
python,django,nginx,wsgi,uwsgi
28,769,075
3
false
1
0
I will go with supervisord for managing the starting, stoping process.
1
6
0
I am leaning towards uwsgi+nginx for my Django app, can anyone share the best method for starting up my uwsgi processes? Does anyone have experience tuning uwsgi?
uwsgi + django via Nginx - uwsgi settings/spawn?
0
0
0
3,116
3,193,756
2010-07-07T10:07:00.000
2
0
0
0
python,machine-learning,adaboost
3,207,845
2
true
0
0
Thanks a million Steve! In fact, your suggestion had some compatibility issues with MacOSX (a particular library was incompatible with the system) BUT it helped me find out a more interesting package : icsi.boost.macosx. I am just denoting that in case any Mac-eter finds it interesting! Thank you again! Tim
1
5
1
Is there anyone that has some ideas on how to implement the AdaBoost (Boostexter) algorithm in python? Cheers!
AdaBoost ML algorithm python implementation
1.2
0
0
4,289
3,195,437
2010-07-07T13:55:00.000
0
0
0
0
python,soap
3,195,467
3
false
1
0
If library is not under active development, then there are two options: it was abandoned, it has no errors anymore. Why are you looking something else? Did you test these two?
1
0
0
I need an advice. What python framework I can use to develop a SOAP web service? I know about SOAPpy and ZSI but that libraries aren't under active development. Is there something better? Thanks.
Python framework for SOAP web services
0
0
1
1,428
3,197,236
2010-07-07T17:19:00.000
1
0
1
0
c++,python,boost-thread,boost-python
3,223,165
1
false
0
1
Python can be called from multiple threads serially, I don't think that's a problem. It sounds to me like your errors are just coming from bad C++ code, as you said the errors happened after PY_BEGIN_ALLOW_THREADS and before PY_END_ALLOW_THREADS. If you know that's not true, can you post a little more of your actual code and show exactly where its erroring and exactly what errors its giving?
1
7
0
Me and a friend are developing an application which uses Boost::Python. I have defined an interface in C++ (well a pure virtual class), exposed through Boost::Python to the users, who have to inherit from it and create a class, which the application takes and uses for some callback mechanism. Everything that far goes pretty well. Now, the function callback may take some time (the user may have programmed some heavy stuff)... but we need to repaint the window, so it doesn't look "stuck".We wanted to use Boost::Thread for this. Only one callback will be running at a time (no other threads will call python at the same time), so we thought it wouldn't be such a great deal... since we don't use threads inside python, nor in the C++ code wrapped for python. What we do is calling PyEval_InitThreads() just after Py_Initialize(), then, before calling the function callback inside it's own boost thread, we use the macro PY_BEGIN_ALLOW_THREADS and, and the macro PY_END_ALLOW_THREADS when the thread has ended. I think I don't need to say the execution never reaches the second macro. It shows several errors everytime it runs... but t's always while calling the actual callback. I have googled a lot, even read some of the PEP docs regarding threads, but they all talk about threading inside the python module (which I don't sice it's just a pure virtual class exposed) or threading inside python, not about the main application calling Python from several threads. Please help, this has been frustrating me for several hours. Ps. help!
Problems regarding Boost::Python and Boost::Threads
0.197375
0
0
511
3,197,299
2010-07-07T17:30:00.000
1
0
0
0
python,urllib2
3,410,537
2
false
0
0
As a general strategy, open wireshark and watch the traffic generated by urllib2.urlopen(url). You may be able to see where the error is coming from.
1
3
0
I am trying to open a page using urllib2 but i keep getting connection timed out errors. The line which i am using is: f = urllib2.urlopen(url) exact error is: URLError: <urlopen error [Errno 110] Connection timed out>
urllib2 connection timed out error
0.099668
0
1
17,707
3,197,509
2010-07-07T17:59:00.000
0
0
1
1
python,stdout,stdio,os.system
3,197,579
4
false
0
0
If you want to completely eliminate the console that launches with the python program, you can save it with the .pyw extension. I may be misunderstanding the question, though.
2
9
0
Usually I can change stdout in Python by changing the value of sys.stdout. However, this only seems to affect print statements. So, is there any way I can suppress the output (to the console), of a program that is run via the os.system() command in Python?
Redirecting stdio from a command in os.system() in Python
0
0
0
42,816
3,197,509
2010-07-07T17:59:00.000
0
0
1
1
python,stdout,stdio,os.system
3,197,521
4
false
0
0
Redirect stderr as well as stdout.
2
9
0
Usually I can change stdout in Python by changing the value of sys.stdout. However, this only seems to affect print statements. So, is there any way I can suppress the output (to the console), of a program that is run via the os.system() command in Python?
Redirecting stdio from a command in os.system() in Python
0
0
0
42,816
3,198,104
2010-07-07T19:23:00.000
-1
0
0
0
python,authentication,saml,single-sign-on
3,255,786
1
false
0
0
I know you are looking for a Python based solution but there are quite a few "server" based solutions that would potentially solve your problem as well and require few ongoing code maintenance issues. For example, using the Apache or IIS Integration kits in conjunction with the PingFederate server from www.pingidentity.com would allow you to pretty quickly and easily support SAML 1.0, 1.1, 2.0, WS-Fed and OpenID for your SP Application. Hope this helps
1
7
0
I'd like to integrate a web site written in Python (using Pylons) with an existing SAML based authentication service. From reading about SAML, I believe that the IdP (which already exists in this scenario) will send an XML document (via browser post) to the Service Provider (which I am implementing). The Service Provider will need to parse this XML and verify the identity of the user. Are there any existing Python libraries that implement this functionality? Thank you,
Implementing a SAML client in Python
-0.197375
0
1
3,557
3,198,646
2010-07-07T20:45:00.000
2
1
0
0
java,python,user-interface,mobile
3,198,745
3
true
1
0
Java is certainly available on more platforms. I would pick a target platform (or set of targets) and see what language(s) would require the least number of redundant implementations. Also, when you get to a certain level of complexity, the language often doesn't factor into speed. For initial prototypes, sure some languages are lightning fast to develop in, but by the time you've taken care of all the exception cases and tripled the entire schedule due to QA, you'll find that the prototype development speed wasn't all that big a deal. Of course, depending on the complexity of your app, this may prove to be untrue--a small simple app can be delivered in near "prototype time".
2
0
0
I know Python apps are faster to write, but it seems Java is the 800 lb gorilla for mobile and GUI development. Are there any mobile platforms that run Python, or should I go the Java route?
Python or Java? Whats better for mobile development, and GUI applications
1.2
0
0
5,062
3,198,646
2010-07-07T20:45:00.000
0
1
0
0
java,python,user-interface,mobile
3,199,234
3
false
1
0
The first question is whether you really need to develop an app, which requires per-platform work, vs a webapp. If you really need an app, then you might likely need a separate language for each platform! For Android you'd want to use Java, and for iPhone/iPad you'd want to use Objective-C. A good argument for really trying to go the webapp route.
2
0
0
I know Python apps are faster to write, but it seems Java is the 800 lb gorilla for mobile and GUI development. Are there any mobile platforms that run Python, or should I go the Java route?
Python or Java? Whats better for mobile development, and GUI applications
0
0
0
5,062
3,198,874
2010-07-07T21:13:00.000
-2
0
0
1
python,beautifulsoup
3,198,945
5
false
1
0
Look at column 3 of line 100 in the "data" that is mentioned in File "/usr/bin/Sipie/Sipie/Factory.py", line 298
1
9
0
I just installed python, mplayer, beautifulsoup and sipie to run Sirius on my Ubuntu 10.04 machine. I followed some docs that seem straightforward, but am encountering some issues. I'm not that familiar with Python, so this may be out of my league. I was able to get everything installed, but then running sipie gives this: /usr/bin/Sipie/Sipie/Config.py:12: DeprecationWarning: the md5 module is deprecated; use hashlib instead import md5 Traceback (most recent call last): File "/usr/bin/Sipie/sipie.py", line 22, in <module> Sipie.cliPlayer() File "/usr/bin/Sipie/Sipie/cliPlayer.py", line 74, in cliPlayer completer = Completer(sipie.getStreams()) File "/usr/bin/Sipie/Sipie/Factory.py", line 374, in getStreams streams = self.tryGetStreams() File "/usr/bin/Sipie/Sipie/Factory.py", line 298, in tryGetStreams soup = BeautifulSoup(data) File "/usr/local/lib/python2.6/dist-packages/BeautifulSoup-3.1.0.1-py2.6.egg/BeautifulSoup.py", line 1499, in __init__ BeautifulStoneSoup.__init__(self, *args, **kwargs) File "/usr/local/lib/python2.6/dist-packages/BeautifulSoup-3.1.0.1-py2.6.egg/BeautifulSoup.py", line 1230, in __init__ self._feed(isHTML=isHTML) File "/usr/local/lib/python2.6/dist-packages/BeautifulSoup-3.1.0.1-py2.6.egg/BeautifulSoup.py", line 1263, in _feed self.builder.feed(markup) File "/usr/lib/python2.6/HTMLParser.py", line 108, in feed self.goahead(0) File "/usr/lib/python2.6/HTMLParser.py", line 148, in goahead k = self.parse_starttag(i) File "/usr/lib/python2.6/HTMLParser.py", line 226, in parse_starttag endpos = self.check_for_whole_start_tag(i) File "/usr/lib/python2.6/HTMLParser.py", line 301, in check_for_whole_start_tag self.error("malformed start tag") File "/usr/lib/python2.6/HTMLParser.py", line 115, in error raise HTMLParseError(message, self.getpos()) HTMLParser.HTMLParseError: malformed start tag, at line 100, column 3 I looked through these files and the line numbers, but since I am unfamiliar with Python, it doesn't make much sense. Any advice on what to do next?
malformed start tag error - Python, BeautifulSoup, and Sipie - Ubuntu 10.04
-0.07983
0
0
7,977
3,199,363
2010-07-07T22:21:00.000
0
0
1
0
python,list,file
3,199,376
3
false
0
0
It simply returns a list containing each line -- there's no "EOF" item in the list.
2
1
0
When you use the fileName.readlines() function in Python, is there a symbol for the end of the file that is included in the list? For example, if the file is read into a list of strings and the last line is 'End', will there be another place in the list with a symbol indicating the end of the file? Thanks.
Reading files to list of strings in Python
0
0
0
3,258
3,199,363
2010-07-07T22:21:00.000
1
0
1
0
python,list,file
3,200,822
3
false
0
0
The list returned by .readlines(), like any other Python list, has no "end" marker -- assumin e.g. you start with L = myfile.readlines(), you can see how many items L has with len(L), get the last one with L[-1], loop over all items one after the other with for item in L:, and so forth ... again -- just like any other list. If for some peculiar reason you want, after the last line, some special "sentinel" value, you could for example do L.append('') to add just such a sentinel, or marker -- the empty string is never going to be the value of any other line (since each item is a complete line including the trailing '\n', so it will never be an empty string!). You could use other arbitrary markers, such as None, but often it's simpler, when feasible [[and it's obviously feasible in this case, as I've just shown]], if the sentinel is of exactly the same type as any other item. That depends on what processing you're doing that needs a past-the-end "sentinel" (I'm not going to guess because you give us no indication, and only relatively rare problems are best solved that way in Python, anyway;-), but in almost every conceivable case of sentinel use a '' sentinel will be just fine.
2
1
0
When you use the fileName.readlines() function in Python, is there a symbol for the end of the file that is included in the list? For example, if the file is read into a list of strings and the last line is 'End', will there be another place in the list with a symbol indicating the end of the file? Thanks.
Reading files to list of strings in Python
0.066568
0
0
3,258
3,199,611
2010-07-07T23:12:00.000
1
0
1
0
python,eclipse,variables,debugging
11,030,623
4
false
0
0
As this was the top hit on Google I should add that if you right-click on the variables pane in debug mode and select 'copy variables' the string value that Eclipse is truncating (along with all other variables) is added in full to the system clipboard. you can then paste it into your favourite text editor to extract the targeted value
1
21
0
I'm debugging Python code and when I try to show the contents of an string variable its showed truncated... How can show the full contents of a variable debugging Python code with PyDev on Eclipse?
Variables viewer on Eclipse debugging truncates the string values
0.049958
0
0
18,404
3,199,702
2010-07-07T23:40:00.000
12
0
0
1
python,eclipse,twisted,pydev
3,199,728
1
true
1
0
go to preferences->Pydev->Interpreter - Python and hit the apply button. That will rescan your modules directory and add any missing modules. That should fix any normal import errors. Some modules do some runtime magic that PyDev cant follow.
1
5
0
It seems like my Eclipse PyDev does not recognize that Twisted is installed on my system. I can't make auto suggest working. Does anyone know how to solve it?
pydev and twisted framework
1.2
0
0
1,684
3,200,004
2010-07-08T00:59:00.000
1
0
0
0
python,django,soap,multithreading,asynchronous
3,200,013
2
true
1
0
That sounds great! You almost always want to do long running stuff in a background thread, and many soap requests spend a lot of time waiting on network IO... The only question is how do you get the data back to the user. Is this a GUI app, or a web app, or what?
2
1
0
I'm working with an application that needs to be make some time consuming SOAP requests (using suds, as it were). There are several instances where a user will change the state of an object and in doing so trigger one or more SOAP requests that fetch some data. This could be done in the background, and right now the user has to wait while these finish. Is this a reasonable use case for Python threads? Or is that just asking for trouble? Better suggestions?
Threaded SOAP requests in Python (Django) application?
1.2
0
0
619
3,200,004
2010-07-08T00:59:00.000
0
0
0
0
python,django,soap,multithreading,asynchronous
3,200,022
2
false
1
0
I use the producer consumer model with a RPCXML server for just this sort of thing. I start a pool of 3 threads, when someone requests something done (add file, etc) I add the work to the queue and return a key. an ajax request can check on the status of the key to set a progress bar, etc.
2
1
0
I'm working with an application that needs to be make some time consuming SOAP requests (using suds, as it were). There are several instances where a user will change the state of an object and in doing so trigger one or more SOAP requests that fetch some data. This could be done in the background, and right now the user has to wait while these finish. Is this a reasonable use case for Python threads? Or is that just asking for trouble? Better suggestions?
Threaded SOAP requests in Python (Django) application?
0
0
0
619
3,201,446
2010-07-08T07:26:00.000
0
0
0
1
python,web-services
3,201,519
4
false
0
0
Don't re-invent the bicycle! Run jobs via cron script, and create a separate web interface using, for example, Django or Tornado. Connect them via a database. Even sqlite will do the job if you don't want to scale on more machines.
2
0
0
To give a little background, I'm writing (or am going to write) a daemon in Python for scheduling tasks to run at user-specified dates. The scheduler daemon also needs to have a JSON-based HTTP web service interface (buzzword mania, I know) for adding tasks to the queue and monitoring the scheduler's status. The interface needs to receive requests while the daemon is running, so they either need to run in a separate thread or cooperatively multitask somehow. Ideally the web service interface should run in the same process as the daemon, too. I could think of a few ways to do it, but I'm wondering if there's some obvious module out there that's specifically tailored for this kind of thing. Any suggestions about what to use, or about the project in general are quite welcome. Thanks! :)
what's a good module for writing an http web service interface for a daemon?
0
0
1
400
3,201,446
2010-07-08T07:26:00.000
0
0
0
1
python,web-services
3,201,631
4
false
0
0
I believed all kinds of python web framework is useful. You can pick up one like CherryPy, which is small enough to integrate into your system. Also CherryPy includes a pure python WSGI server for production. Also the performance may not be as good as apache, but it's already very stable.
2
0
0
To give a little background, I'm writing (or am going to write) a daemon in Python for scheduling tasks to run at user-specified dates. The scheduler daemon also needs to have a JSON-based HTTP web service interface (buzzword mania, I know) for adding tasks to the queue and monitoring the scheduler's status. The interface needs to receive requests while the daemon is running, so they either need to run in a separate thread or cooperatively multitask somehow. Ideally the web service interface should run in the same process as the daemon, too. I could think of a few ways to do it, but I'm wondering if there's some obvious module out there that's specifically tailored for this kind of thing. Any suggestions about what to use, or about the project in general are quite welcome. Thanks! :)
what's a good module for writing an http web service interface for a daemon?
0
0
1
400
3,201,642
2010-07-08T08:00:00.000
1
0
0
1
python,distribution,cx-freeze
3,219,422
2
false
0
0
Try py2app for Mac OS X. (And py2exe for Windows.)
2
1
0
I created independent python app using cxfreeze under linux and can run it other machines without python and other dependencies. But while doing it for mac OS X, in other machines the app searches for the following python installed location which actually present in the machine where it is frozen. "/Library/Frameworks/Python.framework/Versions/3.1/Python" How to execute this app without this dependency?
distributing independent python app to other machines
0.099668
0
0
149
3,201,642
2010-07-08T08:00:00.000
0
0
0
1
python,distribution,cx-freeze
3,226,239
2
false
0
0
Is py2app supports python 3 version?
2
1
0
I created independent python app using cxfreeze under linux and can run it other machines without python and other dependencies. But while doing it for mac OS X, in other machines the app searches for the following python installed location which actually present in the machine where it is frozen. "/Library/Frameworks/Python.framework/Versions/3.1/Python" How to execute this app without this dependency?
distributing independent python app to other machines
0
0
0
149
3,201,685
2010-07-08T08:07:00.000
0
0
0
0
python,pygame,flip
3,201,723
1
false
0
1
Just poll for the time immediately after the flip call, if that one syncs to the vertical retrace.
1
0
0
I am using Pygame to pageflip different stimuli on the screen. The problem is that pygame's flip function, although syncing the flip to the vertical retrace, does not tell me when the retrace was. Does anyone know of a way to get this information (preferably platform independent) in Python? Regards, fladd
How to get the point in time of (last) vertical retrace under Python?
0
0
0
153
3,204,037
2010-07-08T13:25:00.000
1
0
1
0
python,multiprocessing
3,204,794
1
true
0
0
multiprocessing.Process objects take an optional name argument on initialization. You can use that name as a key in a dictionary: child_procs = {'name1' : Process(target=myprocfunc, name='name1'), ...} As for IPC between the parent process and the children, you should be fine with just maintaining a separate multiprocessing.Queue for each child process. You'll need a task distribution object/function to assign work. This function would probably be responsible for popping the task from the main/central queue and then assigning it to the correct child process queue (based on the architecture I am gleaming from your question).
1
1
0
I am using multiprocessing module. This module is works on Queue that is its pick random process and assign the entery from Queue. I want to decide which process will work on which entry of Queue Here is my requirements, I will pass 2 parameters to queue Initiator Process name Action/method ( What process is going to do) Its should pass queue Entry to given Process only.
How to call process by name or tags in python
1.2
0
0
304
3,204,614
2010-07-08T14:26:00.000
13
0
1
0
python
3,204,625
10
false
0
0
str(object) will do the trick. If you want to alter the way object is stringified, define __str__(self) method for object's class. Such method has to return str or unicode object.
3
159
0
How can I change any data type into a string in Python?
How to change any data type into a string?
1
0
0
557,158
3,204,614
2010-07-08T14:26:00.000
6
0
1
0
python
3,204,624
10
false
0
0
With str(x). However, every data type can define its own string conversion, so this might not be what you want.
3
159
0
How can I change any data type into a string in Python?
How to change any data type into a string?
1
0
0
557,158
3,204,614
2010-07-08T14:26:00.000
20
0
1
0
python
36,364,940
10
false
0
0
I see all answers recommend using str(object). It might fail if your object have more than ascii characters and you will see error like ordinal not in range(128). This was the case for me while I was converting list of string in language other than English I resolved it by using unicode(object)
3
159
0
How can I change any data type into a string in Python?
How to change any data type into a string?
1
0
0
557,158
3,205,349
2010-07-08T15:38:00.000
1
0
0
0
python,security,authentication,encryption,cryptography
3,205,573
3
false
1
0
I don't think RegistrationKey adds any real security. It needs more nonces (against replay attacks). It needs more padding (or else the messages are small and thus easy to decrypt). An algorithm can be proven to be secure, you may want to do this. Most flaws in crypto are in the implementation, not in the algorithm (timing attacks, for example).
1
1
0
We have a custom built program that needs authenticated/encrypted communication between a client and a server[both in Python]. We are doing an overhaul from custom written Diffie-Hellman+AES to RSA+AES in a non-orthodox way. So I would be very interested in comments about my idea. Prequisites: Klient has a 128bit RegistrationKey which needs to remain a secret during the authentication - this key is also the only shared secret between the server and client. Client contacts the server over an insecure channel and asks the servers RSA PubKey Client then queries the server: [pseudocode follows] RegistrationKey = "1dbe665ac7a944beb67f106f779e890b" clientname = "foobar" randomkey = random(bits=128) rsa_cp = RSA(key=pubkey, data=randomkey+clientname) aes_cp = AES(key=RegistrationKey, data=RegistrationKey+rsa_cp) send(aes_cp) 3. Server then responds: [pseudocode follows] # Server decrypts the data and sees if it has a valid RegistrationKey, if it does... clientuuid = random(bits=128) sharedkey = random(bits=128) rsa_cp = RSA(key=privkey, data=clientuuid+sharedkey) aes_cp = AES(key=randomkey[got from client], data= rsa_cp) send(aes_cp) Now both sides know the "clientuuid", "sharedkey" which the client can use later to authenticate itself. The method above should be secure even when the attacker learns the regkey later since he would have to crack the RSA key AND man-in-the-middle attacks(on RSA) should stop the auth. from completing correctly. The only possible attack method I see would be the case where the attacker knows the regkey AND can alter the traffic during the authentication. Am i correct? I really want to hear your ides on what to add/remove from this method and If you know a much better way to do this kind of exchange. PS! We are currently using Diffie-Hellman(my own lib, so it probably has flaws) and we have tried TLSv1.2 with PreSharedKeys(didn't work for some reason) and we are CONSTRICTED to http protocols since we need to do this in django. And because we are doing this in http we try to keep the request/answer count as low as possible(no sessions would be the best) - 1 would be the best :) If you have any questions about the specifics, please ask. So, you crypto/security geeks, please give me a helping hand :)
HTTP based authentication/encryption protocol in a custom system
0.066568
0
0
1,123
3,207,219
2010-07-08T19:31:00.000
3
0
1
0
python,directory
47,758,562
21
false
0
0
I will provide a sample one liner where sourcepath and file type can be provided as input. The code returns a list of filenames with csv extension. Use . in case all files needs to be returned. This will also recursively scans the subdirectories. [y for x in os.walk(sourcePath) for y in glob(os.path.join(x[0], '*.csv'))] Modify file extensions and source path as needed.
1
3,467
0
How can I list all files of a directory in Python and add them to a list?
How do I list all files of a directory?
0.028564
0
0
6,808,733
3,207,572
2010-07-08T20:12:00.000
1
0
1
0
python
3,207,610
11
false
0
0
if you want globally set parameters for a callable 'thing' you could always create a class and implement the __call__ method?
3
8
0
I've got a bunch of functions (outside of any class) where I've set attributes on them, like funcname.fields = 'xxx'. I was hoping I could then access these variables from inside the function with self.fields, but of course it tells me: global name 'self' is not defined So... what can I do? Is there some magic variable I can access? Like __this__.fields? A few people have asked "why?". You will probably disagree with my reasoning, but I have a set of functions that all must share the same signature (accept only one argument). For the most part, this one argument is enough to do the required computation. However, in a few limited cases, some additional information is needed. Rather than forcing every function to accept a long list of mostly unused variables, I've decided to just set them on the function so that they can easily be ignored. Although, it occurs to me now that you could just use **kwargs as the last argument if you don't care about the additional args. Oh well... Edit: Actually, some of the functions I didn't write, and would rather not modify to accept the extra args. By "passing in" the additional args as attributes, my code can work both with my custom functions that take advantage of the extra args, and with third party code that don't require the extra args. Thanks for the speedy answers :)
"self" inside plain function?
0.01818
0
0
2,968
3,207,572
2010-07-08T20:12:00.000
0
0
1
0
python
3,207,623
11
false
0
0
What exactly are you hoping "self" would point to, if the function is defined outside of any class? If your function needs some global information to execute properly, you need to send this information to the function in the form of an argument. If you want your function to be context aware, you need to declare it within the scope of an object.
3
8
0
I've got a bunch of functions (outside of any class) where I've set attributes on them, like funcname.fields = 'xxx'. I was hoping I could then access these variables from inside the function with self.fields, but of course it tells me: global name 'self' is not defined So... what can I do? Is there some magic variable I can access? Like __this__.fields? A few people have asked "why?". You will probably disagree with my reasoning, but I have a set of functions that all must share the same signature (accept only one argument). For the most part, this one argument is enough to do the required computation. However, in a few limited cases, some additional information is needed. Rather than forcing every function to accept a long list of mostly unused variables, I've decided to just set them on the function so that they can easily be ignored. Although, it occurs to me now that you could just use **kwargs as the last argument if you don't care about the additional args. Oh well... Edit: Actually, some of the functions I didn't write, and would rather not modify to accept the extra args. By "passing in" the additional args as attributes, my code can work both with my custom functions that take advantage of the extra args, and with third party code that don't require the extra args. Thanks for the speedy answers :)
"self" inside plain function?
0
0
0
2,968
3,207,572
2010-07-08T20:12:00.000
1
0
1
0
python
3,207,667
11
false
0
0
There is no special way, within a function's body, to refer to the function object whose code is executing. Simplest is just to use funcname.field (with funcname being the function's name within the namespace it's in, which you indicate is the case -- it would be harder otherwise).
3
8
0
I've got a bunch of functions (outside of any class) where I've set attributes on them, like funcname.fields = 'xxx'. I was hoping I could then access these variables from inside the function with self.fields, but of course it tells me: global name 'self' is not defined So... what can I do? Is there some magic variable I can access? Like __this__.fields? A few people have asked "why?". You will probably disagree with my reasoning, but I have a set of functions that all must share the same signature (accept only one argument). For the most part, this one argument is enough to do the required computation. However, in a few limited cases, some additional information is needed. Rather than forcing every function to accept a long list of mostly unused variables, I've decided to just set them on the function so that they can easily be ignored. Although, it occurs to me now that you could just use **kwargs as the last argument if you don't care about the additional args. Oh well... Edit: Actually, some of the functions I didn't write, and would rather not modify to accept the extra args. By "passing in" the additional args as attributes, my code can work both with my custom functions that take advantage of the extra args, and with third party code that don't require the extra args. Thanks for the speedy answers :)
"self" inside plain function?
0.01818
0
0
2,968
3,207,671
2010-07-08T20:24:00.000
3
0
0
1
python,google-app-engine,google-cloud-datastore
3,207,714
2
true
1
0
I can reference it through record.key().id(). I just found this RIGHT AFTER I posted this question (as luck would have it). Sorry for wasting anybody's time.
2
2
0
I have a feeling the answer is simple and documented, but I'm absolutely missing it: Is there a way, using Python and webapp through Google App Engine, to pass the id field of a record to the template? I'm fairly new to the app engine, and yes, I have searched all around the Google Documentation to find this.
Reference ID in GAE
1.2
0
0
105
3,207,671
2010-07-08T20:24:00.000
1
0
0
1
python,google-app-engine,google-cloud-datastore
3,209,539
2
false
1
0
Assuming you're using the built-in Django 0.96 templates, you can access the ID (assuming the entity has one; it might have a key name instead if you saved it with one) with {{entity.key.id}}.
2
2
0
I have a feeling the answer is simple and documented, but I'm absolutely missing it: Is there a way, using Python and webapp through Google App Engine, to pass the id field of a record to the template? I'm fairly new to the app engine, and yes, I have searched all around the Google Documentation to find this.
Reference ID in GAE
0.099668
0
0
105
3,207,719
2010-07-08T20:29:00.000
0
0
1
0
python
3,207,765
4
false
0
0
How big and does it need to be done in python? If this is on unix, would split/csplit/grep suffice?
1
0
0
Hey I need to split a large file in python into smaller files that contain only specific lines. How do I do this?
question about splitting a large file
0
0
0
538
3,208,450
2010-07-08T22:24:00.000
0
0
0
1
python,c,macos,python-idle
3,208,731
4
false
0
0
Is your application GUI-driven? If so, you could start a timer when the GUI comes up and then have keyboard and mouse callbacks at the top level. Every time the keyboard or mouse callback is triggered, reset the timer. Otherwise when the timer goes off, it's handler code should suspend your counter. If not, ignore this... ;-)
2
2
0
How can i get system idle time (no keys pressed - mouse moved) in C or Python? EDIT: My program suspend a counter when idle time > 10 sec
Get Mac idle time C or Python
0
0
0
1,227
3,208,450
2010-07-08T22:24:00.000
0
0
0
1
python,c,macos,python-idle
3,208,501
4
false
0
0
what about that in python ( win ) ? like time module in standard lib of python ... ?
2
2
0
How can i get system idle time (no keys pressed - mouse moved) in C or Python? EDIT: My program suspend a counter when idle time > 10 sec
Get Mac idle time C or Python
0
0
0
1,227
3,210,577
2010-07-09T07:21:00.000
1
0
0
1
python,google-app-engine
3,211,471
1
true
1
0
The best way is to populate the summaries (aggregates) at the time of write. This way your reads will be faster, since they just read - at the cost of writes which will have to update the summaries if its likely to be effected by the write. Hopefully you will be reading more often than writing/updating summaries.
1
0
0
As is mentioned in the doc for google app engine, it does not support group by and other aggregation functions. Is there any alternatives to implement the same functionality? I am working on a project where I need it on urgent basis, being a large database its not efficient to iterate the result set and then perform the logic. Please suggest. Thanks in advance.
Google application engine Datastore - any alternatives to aggregate functions and group by?
1.2
1
0
322
3,210,902
2010-07-09T08:10:00.000
9
0
0
1
python
3,210,928
5
false
0
0
You might get that error if the current working directory has been deleted. Programs that are working in a particular directory don't automatically notice if the directory gets deleted; as far as the program is concerned, the CWD is just a string, at least until you do something like os.getcwd() that actually accesses that path on the filesystem. So it's possible to have a current directory that doesn't exist. Without knowing more about your program and its execution environment, I couldn't tell you if that is what's actually happening, though.
5
30
0
I have this program that at one point accesses os.getcwd(), but some times, depending on where the program has gone before getting to that line, it crashes with the message "OSError: [Errno 2] No such file or directory". I cannot figure out what i can do wrong then calling os.getcwd(). There's no arguments, and there should always be a current working directory, right?
Python: Why does os.getcwd() sometimes crash with OSError?
1
0
0
15,175
3,210,902
2010-07-09T08:10:00.000
48
0
0
1
python
3,210,929
5
true
0
0
The current directory may have been deleted by another process.
5
30
0
I have this program that at one point accesses os.getcwd(), but some times, depending on where the program has gone before getting to that line, it crashes with the message "OSError: [Errno 2] No such file or directory". I cannot figure out what i can do wrong then calling os.getcwd(). There's no arguments, and there should always be a current working directory, right?
Python: Why does os.getcwd() sometimes crash with OSError?
1.2
0
0
15,175
3,210,902
2010-07-09T08:10:00.000
1
0
0
1
python
59,532,717
5
false
0
0
It is also possible to get this error when working with an encrypted filesystem and if the partition containing the working directory went back to a "locked" state. In my case, a README file was available at the mounting point of the partition explaining how to unlock the partition again. It could depend of the encryption system and settings. Once the partition unlocked again, to get rid of the error, a change directory is needed to reset the working directory. Even if the target directory is the directory where you already are.
5
30
0
I have this program that at one point accesses os.getcwd(), but some times, depending on where the program has gone before getting to that line, it crashes with the message "OSError: [Errno 2] No such file or directory". I cannot figure out what i can do wrong then calling os.getcwd(). There's no arguments, and there should always be a current working directory, right?
Python: Why does os.getcwd() sometimes crash with OSError?
0.039979
0
0
15,175
3,210,902
2010-07-09T08:10:00.000
0
0
0
1
python
65,927,209
5
false
0
0
Sommeone probably erased your filesystem while you had the Python open. That is why Python is stating that it could not be found. This had happened to me.
5
30
0
I have this program that at one point accesses os.getcwd(), but some times, depending on where the program has gone before getting to that line, it crashes with the message "OSError: [Errno 2] No such file or directory". I cannot figure out what i can do wrong then calling os.getcwd(). There's no arguments, and there should always be a current working directory, right?
Python: Why does os.getcwd() sometimes crash with OSError?
0
0
0
15,175
3,210,902
2010-07-09T08:10:00.000
3
0
0
1
python
3,210,937
5
false
0
0
You would get that error if your current directory no longer exists (it is deleted).
5
30
0
I have this program that at one point accesses os.getcwd(), but some times, depending on where the program has gone before getting to that line, it crashes with the message "OSError: [Errno 2] No such file or directory". I cannot figure out what i can do wrong then calling os.getcwd(). There's no arguments, and there should always be a current working directory, right?
Python: Why does os.getcwd() sometimes crash with OSError?
0.119427
0
0
15,175
3,210,994
2010-07-09T08:21:00.000
0
0
0
1
python,google-app-engine,performance,many-to-many
3,213,988
1
true
1
0
I don't think there's a hard and fast answer to questions like this. "Is this optimization worth it" always depends on many variables such as, is the lack of optimization actually a problem to start with? How much of a problem is it? What's the cost in terms of extra time and effort and risk of bugs of a more complex optimized implementation, relative to the benefits? What might be the extra costs of implementing the optimization later, such as data migration to a new schema?
1
1
0
I'm using Google Appengine to store a list of favorites, linking a Facebook UserID to one or more IDs from Bing. I need function calls returning the number of users who have favorited an item, and the number of times an item has been favorited (and by whom). My question is, should I resolve this relationship into two tables for efficiency? If I have a table with columns for Facebook ID and Bing ID, I can easily use select queries for both of the functions above, however this will require that each row is searched in each query. The alternative is having two tables, one for each Facebook user's favorites and the other for each Bing item's favorited users, and using transactions to keep them in sync. The two tables option has the advantage of being able to use JSON or CSV in the database so that only one row needs to be fetched, and little manipulation needs to be done for an API. Which option is better, in terms of efficiency and minimising cost? Thanks, Matt
Many-to-many relationships in Google AppEngine - efficient?
1.2
1
0
280
3,211,379
2010-07-09T09:27:00.000
0
0
1
1
python,multithreading,concurrency,datastore
3,211,387
1
true
1
0
What you're seeking isn't too Python specific, because AFAIU you want to communicate between two different processes, which are only incidentally written in Python. If this indeed is your problem, you should look for a general solution, not a Python-specific one. I think that a simple No-SQL key-value datastore such as Redis, for example, could be a very nice solution for your situation. Contrary to "complicated" using a tool designed specifically for such a purpose will actually make your code simpler. If you insist on a Python-only solution, then consider using the Python bindings for SQLite which come pre-installed with Python. An SQLite DB can be concurrently used by two processes in a safe manner, as long as your semantics of data access are well defined (i.e. problems you have to solve anyway, the tool nonwithstanding).
1
1
0
I'm writing a small multithreaded client-side python application that contains a small webserver (only serves page to the localhost) and a daemon. The webserver loads and puts data into a persistent "datastore", and the daemon processes this data, modifies it and adds some more. It should also takes care of the synchronization with the disk. I'd like to avoid complicated external things like SQL or other databases as much as possible. What are good and simple ways to design the datastore? Bonus points if your solution uses only standard python.
How should I share and store data in a small multithreaded python application?
1.2
0
0
178
3,211,690
2010-07-09T10:21:00.000
1
0
1
1
python,eclipse,relative-path,pydev
3,212,495
3
false
0
0
Take a look in the project settings, I've never used Pydev with Eclipse, but you should be able to set where the project is executed at, or paths for references. Of course there may be a better solution, but hopefully that's some help!
3
6
0
I installed eclipse with pydev plugin. I need to run my existing project on eclipse. But there are relative paths to the files inside my code. I expect from eclipse to append relative paths to the project's default directory. Instead, it appends the relative path to the directory where Eclipse is installed. I could not find a way to solve the problem. Thanks in advance.
Pydev relative project path
0.066568
0
0
3,341
3,211,690
2010-07-09T10:21:00.000
0
0
1
1
python,eclipse,relative-path,pydev
4,901,532
3
false
0
0
Another way to do it is to go to the 'Environment' tab from the "Run Configuration". Add a new variable with name, "PATH", specifying your desired directory in the "Value" box.
3
6
0
I installed eclipse with pydev plugin. I need to run my existing project on eclipse. But there are relative paths to the files inside my code. I expect from eclipse to append relative paths to the project's default directory. Instead, it appends the relative path to the directory where Eclipse is installed. I could not find a way to solve the problem. Thanks in advance.
Pydev relative project path
0
0
0
3,341
3,211,690
2010-07-09T10:21:00.000
7
0
1
1
python,eclipse,relative-path,pydev
3,213,187
3
true
0
0
I finally found out how to do it and I am writing the answer for other people with the same problem. You can find it in Run Configurations or Debug Configurations. Choose "Python Run" and your run configuration from the left and then in the "Arguments" tab in the right side, set your "working directory" as "other" with giving "the path" on which you want to run your code. Thanks for your interest, Wayne btw.
3
6
0
I installed eclipse with pydev plugin. I need to run my existing project on eclipse. But there are relative paths to the files inside my code. I expect from eclipse to append relative paths to the project's default directory. Instead, it appends the relative path to the directory where Eclipse is installed. I could not find a way to solve the problem. Thanks in advance.
Pydev relative project path
1.2
0
0
3,341
3,211,723
2010-07-09T10:25:00.000
1
0
0
1
python,google-app-engine
5,072,453
1
false
1
0
Note that even if you could get access to the ast modules on GAE, RestrictedPython might still not be the right solution for your use-case. It's only aimed at securing input from less trusted users, where you don't trust their ability to code. You still need to trust and know them. There's various ways in which a malicious user can cause large resource usage or infinite recursions - so don't use it to protect against anonymous users.
1
2
0
I'm looking for a way to execute user submitted python code in GAE in a secure fashion (much stricter then the GAE sandbox). RestrictedPython would certainly fit the shoe, being used in Zope for the exakt same purpose. But RestrictedPython relies on modifying the AST (abstract syntax tree) which means loading modules from the compiler (I get as far as loading the parser module before the SDK complains). Has anyone else done any work with this for Google App Engine?
RestrictedPython on Google AppEngine (GAE)
0.197375
0
0
336
3,212,396
2010-07-09T12:08:00.000
1
0
0
0
python,django,importerror,uwsgi
3,213,320
1
false
1
0
Seems like you have missed a comma in the settings.INSTALLED_APPS, after the app name. Go, check!
1
0
0
Hi I am trying to deploy a django app with uwsgi. I keep getting Import Errors that look like this: ImportError: No module named ?z? -or- ImportError: No module named ?j? -or- ImportError: No module named `?6 So basically the output of the module seems like gibberish and I am unable to figure out the problem. Does anybody have an idea what the problem could be?
Django: ImportError: No module named ?z?
0.197375
0
0
1,341
3,215,062
2010-07-09T17:26:00.000
0
1
0
0
python,flash,forms,mechanize,code-injection
3,849,851
2
false
1
0
Nice question but seems unfortunately mechanize can't be used for flash objects
1
2
0
I am trying to create an automated program in Python that deals with Flash. Right now I am using Python Mechanize, which is great for filling forms, but when it comes to flash I don't know what to do. Does anyone know how I can interact with flash forms (set and get variables, click buttons, etc.) via Python mechanize or some other python library?
Interact with Flash using Python Mechanize
0
0
0
1,702
3,215,168
2010-07-09T17:39:00.000
11
0
1
0
python,string
34,101,344
7
false
0
0
just use \xb0 (in a string); python will convert it automatically
1
86
0
How can I get a ° (degree) character into a string?
How to get ° character in a string in python?
1
0
0
176,258
3,215,455
2010-07-09T18:21:00.000
2
0
0
0
python,ruby-on-rails,ruby
3,218,192
4
false
1
0
Depending on your exact needs, you can either call out to an external process (using popen, system, etc) or you can setup another mini-web-server or something along those lines and have the rails server communicate with it over HTTP with a REST-style API (or whatever best suits your needs). In your example, you have a ruby frontend website and then a number-crunching python backend service that builds up recommendation data for the ruby site. A fairly nice solution is to have the ruby site send a HTTP request to the python service when it needs data updating (with a payload of information to identify what it needs doing to what or some such) and then the python backend service can crunch away and update the table which presumably your ruby frontend will automatically pick up the changes of during the next request and display.
3
2
0
Is it possible to use multiple languages along side with ruby. For example, I have my application code in Ruby on Rails. I would like to calculate the recommendations and I would like to use python for that. So essentially, python code would get the data and calculate all the stuff and probably get the data from DB, calculate and update the tables.Is it possible and what do you guys think about its adv/disadv Thanks
Using other languages with ruby
0.099668
0
0
1,299
3,215,455
2010-07-09T18:21:00.000
0
0
0
0
python,ruby-on-rails,ruby
3,218,487
4
false
1
0
An easy, quick 'n' dirty solution in case you have python scripts and you want to execute them from inside rails, is this: %x[shell commands or python path/of/pythonscript.py #{ruby variables to pass on the script}] or ``shell commands or python path/of/pythonscript.py #{ruby variables to pass on the script}\ (with ` symbol in the beginning and the end). Put the above inside a controller and it will execute. For some reason, inside ruby on rails, system and exec commands didn't work for me (exec crashed my application and system doesn't do anything).
3
2
0
Is it possible to use multiple languages along side with ruby. For example, I have my application code in Ruby on Rails. I would like to calculate the recommendations and I would like to use python for that. So essentially, python code would get the data and calculate all the stuff and probably get the data from DB, calculate and update the tables.Is it possible and what do you guys think about its adv/disadv Thanks
Using other languages with ruby
0
0
0
1,299
3,215,455
2010-07-09T18:21:00.000
4
0
0
0
python,ruby-on-rails,ruby
3,215,496
4
false
1
0
If you are offloading work to an exterior process, you may want to make this a webservice (ajax, perhaps) of some sort so that you have some sort of consistent interface. Otherwise, you could always execute the python script in a subshell through ruby, using stdin/stdout/argv, but this can get ugly quick.
3
2
0
Is it possible to use multiple languages along side with ruby. For example, I have my application code in Ruby on Rails. I would like to calculate the recommendations and I would like to use python for that. So essentially, python code would get the data and calculate all the stuff and probably get the data from DB, calculate and update the tables.Is it possible and what do you guys think about its adv/disadv Thanks
Using other languages with ruby
0.197375
0
0
1,299
3,216,027
2010-07-09T19:47:00.000
1
0
0
0
python,mysql
3,216,500
1
true
0
0
Depending on your user privileges, you can execute SHOW PROCESSLIST or SELECT from information_schema.processlist while the UPDATE hangs to see if there is a contention issue with another query. Also do an EXPLAIN on a SELECT of the WHERE clause used in the UPDATE to see if you need to change the statement. If it's a lock contention, then you should eventually encounter a Lock Wait Timeout (default = 50 sec, I believe). Otherwise, if you have timing constraints, you can make use of KILL QUERY and KILL CONNECTION to unblock the cursor execution.
1
0
0
I'm using MySQLdb and when I perform an UPDATE to a table row I sometimes get an infinite process hang. At first I thought, maybe its COMMIT since the table is Innodb, but even with autocommit(True) and db.commit() after each update I still get the hang. Is it possible there is a row lock and the query just fails to carry out? Is there a way to handle potential row locks or maybe even handle slow queries?
MySQLdb Handle Row Lock
1.2
1
0
544
3,216,654
2010-07-09T21:22:00.000
1
0
1
0
python
3,216,689
2
false
0
0
Python uses radians, as a float. There is no specific "angle" type, although you can write one yourself as needed.
1
0
0
What is the standard way to enter degrees into python? My total station gives degrees in degree-minute-second format. I could write a function to convert this to a decimal degree but I would like to know if there is a common way to do this that I am unaware of. -Chris
Entering precise degrees into python
0.099668
0
0
535
3,216,681
2010-07-09T21:28:00.000
0
1
1
0
python,coding-style,conditional
3,232,563
7
false
0
0
Might I suggest that the amount of bickering over this question is enough to answer it? Some argue that it "if x" should only be used for Z, others for Y, others for X. If such a simple statement is able to create such a fuss, to me it is clear that the statement is not clear enough. Write what you mean. If you want to check that x is equal to 0, then write "if x == 0". If you want to check if x exists, write "if x is not None". Then there is no confusion, no arguing, no debate.
4
5
0
Assuming that x is an integer, the construct if x: is functionally the same as if x != 0: in Python. Some languages' style guides explicitly forbid against the former -- for example, ActionScript/Flex's style guide states that you should never implicitly cast an int to bool for this sort of thing. Does Python have a preference? A link to a PEP or other authoritative source would be best.
Which of `if x:` or `if x != 0:` is preferred in Python?
0
0
0
6,685
3,216,681
2010-07-09T21:28:00.000
3
1
1
0
python,coding-style,conditional
3,216,964
7
false
0
0
There's no hard and fast rule here. Here are some examples where I would use each: Suppose that I'm interfacing to some function that returns -1 on error and 0 on success. Such functions are pretty common in C, and they crop up in Python frequently when using a library that wraps C functions. In that case, I'd use if x:. On the other hand, if I'm about to divide by x and I want to make sure that x isn't 0, then I'm going to be explicit and write if x != 0. As a rough rule of thumb, if I treat x as a bool throughout a function, then I'm likely to use if x: -- even if I can prove that x will be an int. If in the future I decide I want to pass a bool (or some other type!) to the function, I wouldn't need to modify it. On the other hand, if I'm genuinely using x like an int, then I'm likely to spell out the 0.
4
5
0
Assuming that x is an integer, the construct if x: is functionally the same as if x != 0: in Python. Some languages' style guides explicitly forbid against the former -- for example, ActionScript/Flex's style guide states that you should never implicitly cast an int to bool for this sort of thing. Does Python have a preference? A link to a PEP or other authoritative source would be best.
Which of `if x:` or `if x != 0:` is preferred in Python?
0.085505
0
0
6,685
3,216,681
2010-07-09T21:28:00.000
-2
1
1
0
python,coding-style,conditional
3,216,911
7
false
0
0
Wouldn't if x is not 0: be the preferred method in Python, compared to if x != 0:? Yes, the former is a bit longer to write, but I was under the impression that is and is not are preferred over == and !=. This makes Python easier to read as a natural language than as a programming language.
4
5
0
Assuming that x is an integer, the construct if x: is functionally the same as if x != 0: in Python. Some languages' style guides explicitly forbid against the former -- for example, ActionScript/Flex's style guide states that you should never implicitly cast an int to bool for this sort of thing. Does Python have a preference? A link to a PEP or other authoritative source would be best.
Which of `if x:` or `if x != 0:` is preferred in Python?
-0.057081
0
0
6,685
3,216,681
2010-07-09T21:28:00.000
2
1
1
0
python,coding-style,conditional
3,216,691
7
false
0
0
Typically, I read: if(x) to be a question about existence. if( x != 0) to be a question about a number.
4
5
0
Assuming that x is an integer, the construct if x: is functionally the same as if x != 0: in Python. Some languages' style guides explicitly forbid against the former -- for example, ActionScript/Flex's style guide states that you should never implicitly cast an int to bool for this sort of thing. Does Python have a preference? A link to a PEP or other authoritative source would be best.
Which of `if x:` or `if x != 0:` is preferred in Python?
0.057081
0
0
6,685
3,217,222
2010-07-10T00:00:00.000
2
1
1
0
python
3,217,317
8
false
0
0
I found python in 1988 and fell in love with it. Our group at work had been dissolved and we were looking for other jobs on site, so I had a couple of months to play around doing whatever I wanted to. I spent the time profitably learning and using python. I suggest you spend time thinking up and writing utilities and various useful tools. I've got 200-300 in my python tools library now (can't even remember them all). I learned python from Guido's tutorial, which is a good place to start (a C programmer will feel right at home). python is also a great tool for making models -- physical, math, stochastic, etc. Use numpy and scipy. It also wouldn't hurt to learn some GUI stuff -- I picked up wxPython and learned it, as I had some experience using wxWidgets in C++. wxPython has some impressive demo stuff!
1
43
0
Well just getting into the flow of thing with Python. Reading a few books, finding it fairly easy as I already have some experience with C++/Java from school and Python is definetly my favorite thus far. Anyway, I am getting a whole bunch of information on python, but haven't been putting it to much use. Thus, what I was wondering was if there are any sort of practice problems online that I can use? If anyone could point me in any sort of direction, I'd greatly appreciate it.
Beginner Python Practice?
0.049958
0
0
142,555
3,217,673
2010-07-10T03:16:00.000
67
0
1
0
python,command-line,optparse,getopt,argparse
3,217,926
5
false
0
0
Why should I use it instead of optparse? Are their new features I should know about? @Nicholas's answer covers this well, I think, but not the more "meta" question you start with: Why has yet another command-line parsing module been created? That's the dilemma number one when any useful module is added to the standard library: what do you do when a substantially better, but backwards-incompatible, way to provide the same kind of functionality emerges? Either you stick with the old and admittedly surpassed way (typically when we're talking about complicated packages: asyncore vs twisted, tkinter vs wx or Qt, ...) or you end up with multiple incompatible ways to do the same thing (XML parsers, IMHO, are an even better example of this than command-line parsers -- but the email package vs the myriad old ways to deal with similar issues isn't too far away either;-). You may make threatening grumbles in the docs about the old ways being "deprecated", but (as long as you need to keep backwards compatibility) you can't really take them away without stopping large, important applications from moving to newer Python releases. (Dilemma number two, not directly related to your question, is summarized in the old saying "the standard library is where good packages go to die"... with releases every year and a half or so, packages that aren't very, very stable, not needing releases any more often than that, can actually suffer substantially by being "frozen" in the standard library... but, that's really a different issue).
1
316
0
I noticed that the Python 2.7 documentation includes yet another command-line parsing module. In addition to getopt and optparse we now have argparse. Why has yet another command-line parsing module been created? Why should I use it instead of optparse? Are there new features that I should know about?
Why use argparse rather than optparse?
1
0
0
147,808
3,218,599
2010-07-10T09:10:00.000
1
1
1
1
python,bash
3,218,680
1
true
0
0
My interpretation of your context, is that you have a Python script that performs various make- or autoconf-like operations, and you want to allow clients to write their own Makefiles for Foobuzzle. The problem with directories I don't understand. import will always search the local directory? And you can os.chdir() when you hop around to change current working directory, like make does. Having it as a bash script has the pro that nobody needs to learn Python or, specifically, the Python-like Foobuzzle DSL. But it is a lot less powerful: you're basically limited to sending and receiving text only. You can't write support functions that the bash code can call (unless you generate that into bash as well), proper error handling might be tough, etc. Depending on how powerful the configuration needs to be, I would use Python. I'd probably load the file itself and use eval() on it, giving me full control over its namespace. I could pass various utility and helper functions, for example, or provide objects they can manipulate directly. If it's really simple though, specifying flags and names, that sort of thing, then you could just have it as .ini files and use ConfigParser() in the standard library.
1
0
0
Lets say I am designing a tool foobuzzle (foobuzzle's exact job is to set up SRPM files for cross-compiling a variety of codes into their own compartmentalized prefix directories, but this is not important). I would like foobuzzle to take in an input file (buzzle_input) specified by an (intelligent, code-savvy) client, who will tell foobuzzle how they would like it to perform these operations. I am writing foobuzzle in Python, and it seems to make sense for the user to provide buzzle_input configuration information in either Python or bash. Which would you choose? How would you implement it? I am expecting that Python will need some global environment variables that may need to be set up by executing some other scripts, probably from within the buzzle_input script. This is not production code, just an internal tool a small team of developers will be using to help manage a fairly large cross-compiled environment of C/C++/FORTRAN codes. My best guess is to use something to wrap the foobuzzle script so that the $PYTHONPATH variable picks up the current working directory, and to have the foobuzzle_input script imported and executed as set up. Is there a cleaner way to do this without wrapping foobuzzle? Any special considerations for executing the bash scripts (assume safety is not really a concern and that these scripts will not be run with system administrator privileges).
How do I execute Python/bash code in the current directory as part of a code?
1.2
0
0
276
3,219,765
2010-07-10T15:23:00.000
2
0
0
0
python,tkinter,grid,tkinter-entry
3,222,439
2
true
0
1
Don't place them in the same row and column; place the upper in a row, and the lower in row+1, both in the same column. That does the trick. Note that the grid manager does not need to have all rows and columns filled with widgets; it ignores empty rows and columns.
1
1
0
I am having a bit of trouble with the Tkinter grid() manager. It is spacing the rows too far apart. I have two entry widgets to place, and I need one almost directly under the other. When I place them both on the same row and column, but change the pady option, it places them directly on top of each other. I know there has to be a way to fix this, never had this problem before. I am using Python 2.6 on Windows XP.
Tkinter grid() Manager
1.2
0
0
1,716
3,219,772
2010-07-10T15:25:00.000
1
0
1
1
python,diff,patch
3,219,785
2
false
0
0
Your update manager can know which version the current app is, and which version is the most recent one and apply only the relevant patches. Suppose the user runs 0.38, and currently there is 0.42 available. The update for 0.42 contains patches for 0.39, 0.40, 0.41 and 0.42 (and probably farther down the history). The update manager downloads the 0.42 update, knows it's at 0.38 and applies all the relevant patches. If it currently runs 0.41, it only applies the latest patch, and so on.
1
3
0
Currently my program updates itself by downloading the latest .tar.gz file containing the source code, and extracting it over the current directory where the program lives. There are 2 "modes" of update - one for users running the Python source, and one if the user is running the program as a Windows exe. Over time my program's filesize is becoming larger with each release, due to new images, libraries, documentation and code. However, sometimes only code changes occur from one release to another, so the user ends up re-downloading all the images, documentation etc over and over, when only there are only small code changes. I was thinking that a more efficient approach would be to use a patch/diff based system where the program incrementally updates itself from one version to another by only downloading small change sets. However, how should I do this? If the user is running version 0.38, and there is a 0.42 available, do they download 0.38->39; 0.39->40; 0.40->41, 0.41->42? How would I handle differences in binary files? (images, in my case). I'd also have to maintain some repository containing all the patches, which isn't too bad. I'd just generate the diffs with each new release. But I guess it would be harder to do this to executables than to pure python code? Any input is appreciated. Many thanks.
Updating my program, using a diff-based patch approach
0.099668
0
0
535
3,220,280
2010-07-10T17:55:00.000
2
0
1
0
python,django,setuptools,virtualenv
66,091,958
5
false
1
0
pip install "django>=2.2,<3" To install djnago 2.2
1
96
0
I want to install some specific version of a package (in this case Django) inside the virtual environment. I can't figure it out. I'm on Windows XP, and I created the virtual environment successfully, and I'm able to run it, but how am I supposed to install the Django version I want into it? I mean, I know to use the newly-created easy_install script, but how do I make it install Django 1.0.7? If I do easy_install django, it will install the latest version. I tried putting the version number 1.0.7 into this command in various ways, but nothing worked. How do I do this?
How do I install an old version of Django on virtualenv?
0.07983
0
0
80,239
3,220,433
2010-07-10T18:50:00.000
0
0
1
0
python,optimization,recursion,diff
3,220,449
2
false
0
0
If you have any expensive method that you are likely to call multiple times with the same parameters then you can just cache the result of the method, using the parameters as a key.
1
2
0
After finding the difflib.SequenceMatcher class in Python's standard library to be unsuitable for my needs, a generic "diff"-ing module was written to solve a problem space. After having several months to think more about what it is doing, the recursive algorithm appears to be searching more than in needs to by re-searching the same areas in a sequence that a separate "search thread" may have also examined. The purpose of the diff module is to compute the difference and similarities between a pair of sequences (list, tuple, string, bytes, bytearray, et cetera). The initial version was much slower than the code's current form, having seen a speed increase by a factor of ten. Does anyone have a suggestion for implementing a method of pruning search spaces in recursive algorithms to improve performance?
How to optimize a recursive algorithm to not repeat itself?
0
0
0
508
3,221,366
2010-07-11T00:21:00.000
2
0
1
0
python,timezone
3,221,517
2
false
0
0
I don't think that's a good idea. In Australia, Melbourne and Sydney usually share the same timezone, however the choice of when DST starts and ends is controlled by two different bodies. When Melbourne hosted the Commonwealth Games a few years back, they changed the DST (just for the one year) for convenience. I think Sydney may have changed also to avoid confusion, but they did have to decide that separately from Melbourne.
1
9
0
There are way too many overlapping timezones in pytz's common list. Has anyone pared this down? For example there are 5 or 6 duplicate Canadian timezones and 15 or so duplicate US time zones. China is 1 timezone no DST, but has 5 entries.. By duplicate I mean GMT offset and DST are exactly the same. Getting rid of the timezones in pytz.country_timezones['us'] gets rid of the duplicate US timezones as it only contains the America/* zones and not the base US/* zones. This doesn't work for other countries.
Python timezones - pytz.common_timezones has too many
0.197375
0
0
1,191
3,221,739
2010-07-11T03:22:00.000
4
0
1
0
python,variables
3,221,742
2
false
0
0
There's no reason you can't hold 100 MB of data in Python, system memory permitting. But you should try to use an iterator, rather than reading the whole result set into a list.
1
2
0
I get an response in Python program from SQL server. How big can this response be? What is the maximum? Coult it be as much as about 100 mb?
How big can variable be, in python?
0.379949
0
0
4,638
3,222,654
2010-07-11T10:15:00.000
3
0
0
0
python,database,dom
3,222,720
3
true
1
0
Is there anything missing to my general approach for developing a web app? (Server-side scripting interacts with database to produce dynamic HTML which is then manipulated client-side via. the DOM/client-side scripting). No - that's the usual setup. Actually, client-side scripting is quite often missing, and web-page is completely refreshed on any interaction. Your description is perfectly fine. I chose PHP because it is commonly associated with web development. What are the alternatives? As a beginner I would like to know the "best" server-side language to learn (and I am up for a challenge), or at least be aware of the alternatives. This is a debatable topic, subject to different tastes, thus usually more suited to community wiki; besides, there's bunch of such questions already. Very quickly, PHP is most common because it is the easiest to configure, but it has bunch of cruft. Perl is old-school, and rather unreadable. Python and Ruby are currently the hottest, owing to amazing dynamic frameworks (CherryPy and Django vs. Sinatra and Rails), but the rivalry is strong, and everyone has picked a side. I'll tell you Ruby is nicer to work with, but someone else will say the same for Python. However, configuring them is a bit more difficult (i.e. not usually standard option on majority of hosting providers). As far as client-side goes it seems that JavaScript is IT. Is it? That's it, if you're talking about HTML. The alternatives died off. I've heard alot about AJAX but know little to nothing at all about it. Is it an alternative to generating HTML server-side via. a database? What is it/advantages/disadvantages. AJAX is a fancy name for making a HTTP request from JavaScript without reloading the page. The requested content can be executable JS, or parsable XML, or ready-to-insert HTML... and it is the only method to get some data client-side without refreshing the whole page. I've read that frames are being deprecated. Should I move away from frames and more towards DOM manipulation? An emphatic yes. However, iframes have their (limited) uses. You most likely do not need them. If this application is to be available over the internet I will need to setup a login system of some sort. What are common ways of setting up authentication using hosted or private services? Username + encrypted password in database, when user enters username + password, encrypt password and check both against the database. If successful, record username in session. Another way is OpenID, but it requires a third-party OpenID provider. (Getting a little off topic) Any free hosting suggestions? I'm a student, and hosting the server myself would be unreliable for my friend. Not too knowledgeable. I know about comyr (general purpose) and heroku (Ruby), both free for non-commercial use, AFAICR, but a bit of research can get you more. I would really love to implement as much of this project via. Python as possible. What can Python do in terms of programming for the browser and what would it require? It can do everything in terms of server-side programming, just like any other Turing-complete language. It can do it pretty easily, being a dynamic language with lots of nice libraries targeted for web development. It will not do anything at all for the browser, though. Check out CherryPy for lightweight, and Django for heavyweight web app framework. But I thought you chose PHP?...
2
3
0
As a programmer used to developing native applications, I'm expanding my horizons and developing my first web app. I'm intermediate to expert with Linux and C, intermediate with Python and HTML and beginner to intermediate with MySQL and Java. I'm developing a web app that is more or less a resource allocator for a friend of mine. To put it simply, I want this program to help him manage jobs, assigning technicians and equipment. The main screen will be an embedded Google Calendar frame that can be updated dynamically via. their API. Now, certain jobs require technicians to hold certain certificates, and equipment must be calibrated on a specific schedule. I would also like to track extra data, such as phone numbers, e-mail addresses, job information, etc. To top it all off, I want it to look nice! I've spent quite some time familiarizing myself with PHP, JavaScript and the DOM and I've developed some functionality and a neat UI. So far I've been coding server-side w/ PHP to deliver dynamic HTML via. MySQL and then JavaScript to manipulate the DOM. I have tables for technicians, certificates, jobs, phone numbers, etc. My questions are: Is there anything missing to my general approach for developing a web app? (Server-side scripting interacts with database to produce dynamic HTML which is then manipulated client-side via. the DOM/client-side scripting). I chose PHP because it is commonly associated with web development. What are the alternatives? As a beginner I would like to know the "best" server-side language to learn (and I am up for a challenge), or at least be aware of the alternatives. As far as client-side goes it seems that JavaScript is IT. Is it? I've heard alot about AJAX but know little to nothing at all about it. Is it an alternative to generating HTML server-side via. a database? What is it/advantages/disadvantages. I've read that frames are being deprecated. Should I move away from frames and more towards DOM manipulation? If this application is to be available over the internet I will need to setup a login system of some sort. What are common ways of setting up authentication using hosted or private services? (Getting a little off topic) Any free hosting suggestions? I'm a student, and hosting the server myself would be unreliable for my friend. I would really love to implement as much of this project via. Python as possible. What can Python do in terms of programming for the browser and what would it require?
General guidelines for developing a web application
1.2
0
0
404
3,222,654
2010-07-11T10:15:00.000
1
0
0
0
python,database,dom
3,222,758
3
false
1
0
I'd like to suggest ditching PHP as soon as possible. Searching 'php wtf' here should be illuminating. While it is possible to write secure, safe, reliable applications in PHP, I think it is despite the best efforts of the PHP team to make The Most Exciting And Surprisin Language EVAR. With lots of funny side-effects. And pretend-security-options. If most of what PHP looks like is appealing to you, I think I'd suggest using Perl instead. It should be much less surprising. So, with my rant against PHP out of the way, you have a LOT of much better options. Python has Django, Zope, and Twisted Matrix. They each solve different problems, allowing you to write applications at different levels: Django imposes some Model-View-Controller structure on your code, Zope is a much larger CMS framework, and Twisted Matrix provides a lot of super-keen programming primitives if you want to write things pretty close to the wire. (You're something like five lines of code away from a very-simple-yet-neat web server with Twisted that runs your application code..) If you really want to learn another language in the process, Ruby on Rails is getting a lot of the hype, and for mostly good reasons. I've really enjoyed coding Ruby on Rails, the imposed structure is fantastic for anything beyond trivial applications, and it mostly gets out of your way with reasonable assumptions. Perl is 'the old standby'. I'd take it over PHP any day, but I can't stand Perl's OO or modules system. So it's hard for me to really endorse it. I'd like to suggest against Flash and Silverlight on the client-side: First, Flash is a giant resource hog and security disaster, and Silverlight, while probably better than Flash on both fronts, is even less portable than Flash. (I strongly recommend trying your site on a handful of mobile browsers; it doesn't have to look pretty, but everything ought to work. :)
2
3
0
As a programmer used to developing native applications, I'm expanding my horizons and developing my first web app. I'm intermediate to expert with Linux and C, intermediate with Python and HTML and beginner to intermediate with MySQL and Java. I'm developing a web app that is more or less a resource allocator for a friend of mine. To put it simply, I want this program to help him manage jobs, assigning technicians and equipment. The main screen will be an embedded Google Calendar frame that can be updated dynamically via. their API. Now, certain jobs require technicians to hold certain certificates, and equipment must be calibrated on a specific schedule. I would also like to track extra data, such as phone numbers, e-mail addresses, job information, etc. To top it all off, I want it to look nice! I've spent quite some time familiarizing myself with PHP, JavaScript and the DOM and I've developed some functionality and a neat UI. So far I've been coding server-side w/ PHP to deliver dynamic HTML via. MySQL and then JavaScript to manipulate the DOM. I have tables for technicians, certificates, jobs, phone numbers, etc. My questions are: Is there anything missing to my general approach for developing a web app? (Server-side scripting interacts with database to produce dynamic HTML which is then manipulated client-side via. the DOM/client-side scripting). I chose PHP because it is commonly associated with web development. What are the alternatives? As a beginner I would like to know the "best" server-side language to learn (and I am up for a challenge), or at least be aware of the alternatives. As far as client-side goes it seems that JavaScript is IT. Is it? I've heard alot about AJAX but know little to nothing at all about it. Is it an alternative to generating HTML server-side via. a database? What is it/advantages/disadvantages. I've read that frames are being deprecated. Should I move away from frames and more towards DOM manipulation? If this application is to be available over the internet I will need to setup a login system of some sort. What are common ways of setting up authentication using hosted or private services? (Getting a little off topic) Any free hosting suggestions? I'm a student, and hosting the server myself would be unreliable for my friend. I would really love to implement as much of this project via. Python as possible. What can Python do in terms of programming for the browser and what would it require?
General guidelines for developing a web application
0.066568
0
0
404
3,223,557
2010-07-11T15:28:00.000
0
1
0
0
php,python,jsp
3,223,599
7
false
1
0
I expect this question to be closed as being subjective. But, I'll put in my 2 cents. JSP would likely dovetail well with J2EE. (I've heard that it can be a bit rigid, but I have no experience to provide any insight on the matter.) PHP is a good candidate, because it's popular. You can find a lot of info on the web. Python isn't as popular for webdev, so finding examples won't be as easy. I also second Dave Markle's opinion. If you want to learn webdev, HTML, CSS and JavaScript will be crucial as well. You may never want to be a front-end developer, but you can't get away from dealing with those technologies at some point.
6
5
0
Friends, I've got some exp in c++ and now kind of starting my way to J2EE (to survive:))). Meanwhile, I've got a plan to venture in to a web portal my own. But with very little experience in web technology, I'd need to start from scratch. I'm little confused on which way to go and I'm here. PHP, Python or JSP, considering the fact that, anyway I've got to learn J2EE at my work. Would that be worth to learn PHP or Python to develop a portal which I expect to get 80-100K hits per day "IF" everything goes well OR jsp would be sufficient? Many thanks
Which web technology to learn for an experienced C++ developer?
0
0
0
1,073
3,223,557
2010-07-11T15:28:00.000
1
1
0
0
php,python,jsp
3,225,166
7
false
1
0
Hit's per day isn't a really useful metric for estimating performance. You really need to be concerned with the peak load and the acceptable response time. 80-100k hits per day is an average of about 1 hit per second. The hits are not going to be evenly spread out, so for normal traffic you might expect a peak load of 10 hits per second. If you are going to promote the site with newsletters or commercials, expect to peack at 100's of hits per second. If you selling $1 air tickets, expect to peak at 1000's of hits per second. Now the language you choose for the site isn't nearly as important as your choice of database (not necessarily relational) and the way you store the data in the database. Scaling up frontends is relatively easy, so having really fast efficient HTML generation shouldn't be a primary concern. Pick a platform that is going to be efficient for development time.
6
5
0
Friends, I've got some exp in c++ and now kind of starting my way to J2EE (to survive:))). Meanwhile, I've got a plan to venture in to a web portal my own. But with very little experience in web technology, I'd need to start from scratch. I'm little confused on which way to go and I'm here. PHP, Python or JSP, considering the fact that, anyway I've got to learn J2EE at my work. Would that be worth to learn PHP or Python to develop a portal which I expect to get 80-100K hits per day "IF" everything goes well OR jsp would be sufficient? Many thanks
Which web technology to learn for an experienced C++ developer?
0.028564
0
0
1,073
3,223,557
2010-07-11T15:28:00.000
1
1
0
0
php,python,jsp
3,223,588
7
false
1
0
Considering you're used to c++, should look at aspx and c# - probably closer to your current experience. That said, PHP is a doddle, so it shouldn't present any challenges. Bear in mind that if you want to get the most from the language, you absolutely have to learn a little bit about configuring apache, and frameworks (cake, codeigniter, zend etc).
6
5
0
Friends, I've got some exp in c++ and now kind of starting my way to J2EE (to survive:))). Meanwhile, I've got a plan to venture in to a web portal my own. But with very little experience in web technology, I'd need to start from scratch. I'm little confused on which way to go and I'm here. PHP, Python or JSP, considering the fact that, anyway I've got to learn J2EE at my work. Would that be worth to learn PHP or Python to develop a portal which I expect to get 80-100K hits per day "IF" everything goes well OR jsp would be sufficient? Many thanks
Which web technology to learn for an experienced C++ developer?
0.028564
0
0
1,073