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
832,693
2009-05-07T02:57:00.000
1
0
0
0
python,pdf,xhtml,latex
837,011
3
true
1
0
The stand alone program : wkhtmltopdf is exactly what I needed. The PDF rendering of XHTML is the best of seen from a free tool.
1
2
0
I know PDF generation has been discussed a lot here; however, I've yet to find what I need. I'm trying to generate PDF reports (mainly tables) from python. Yes I've tried ReportLab and Pisa. Both had column content "break out" in circumstances I didn't think were unreasonable and unrealistic to encounter in productio...
PDF Tables of Arbitrary (within reason) Width
1.2
0
0
600
833,062
2009-05-07T05:52:00.000
0
0
0
1
python,windows-services,tcp
834,878
3
false
0
0
Check to see that the service is running under the Nertwork Service account and not the Local System account. The later doesn't have network access and is the default user to run services under. You can check this by going to the services app under administrative tool in the start menu and looking for your service. ...
2
2
0
I have written a Python TCP/IP server for internal use, using win32serviceutil/py2exe to create a Windows service. I installed it on a computer running Windows XP Pro SP3. However, I can't connect to it when it's running as a service. I can confirm that it's binding to the address/port, because I get a conflict when I ...
Cannot access Python server running as Windows service
0
0
0
1,004
833,062
2009-05-07T05:52:00.000
1
0
0
1
python,windows-services,tcp
904,114
3
true
0
0
First of all, whenever you implement a Windows service, be sure to add proper logging. My worker threads were terminating because of the exception, "The socket operation could not complete without blocking." The solution was to simply call sock.setblocking(1) after accepting the connection.
2
2
0
I have written a Python TCP/IP server for internal use, using win32serviceutil/py2exe to create a Windows service. I installed it on a computer running Windows XP Pro SP3. However, I can't connect to it when it's running as a service. I can confirm that it's binding to the address/port, because I get a conflict when I ...
Cannot access Python server running as Windows service
1.2
0
0
1,004
833,063
2009-05-07T05:52:00.000
0
0
1
0
python,c,iterator,jit,algol68
833,074
3
false
0
0
No. Nice and short!
1
6
0
The "yield" statement in python allows simple iteration from a procedure, and it also means that sequences don't need to be pre-calculated AND stored in a array of "arbitrary" size. Is there a there a similar way of iterating (with yield) from a C procedure?
Python style iterators in C
0
0
0
875
833,356
2009-05-07T07:45:00.000
0
0
0
1
python
833,364
2
false
0
0
Set the scheduled task to start the script as minimized.
2
1
0
I have a scheduled task which runs a python script every 10 min so it turns out that a script pops up on my desktop every 10 min how can i make it invincible so my script will work in the background ? I've been told that pythonw will do the work, but I cant figure out how to use it any help ? thanks
How to run a script without being in the tasktray?
0
0
0
109
833,356
2009-05-07T07:45:00.000
3
0
0
1
python
833,391
2
false
0
0
I've been told that pythonw will do the work, but I cant figure out how to use it Normally you just have to rename the file extension to .pyw. Then it will be executed by pythonw.
2
1
0
I have a scheduled task which runs a python script every 10 min so it turns out that a script pops up on my desktop every 10 min how can i make it invincible so my script will work in the background ? I've been told that pythonw will do the work, but I cant figure out how to use it any help ? thanks
How to run a script without being in the tasktray?
0.291313
0
0
109
834,840
2009-05-07T14:05:00.000
3
1
0
0
python,ftp,performance,dos
834,923
7
false
0
0
FTPlib may not be the cleanest Python API, I don't think it so bad that it run ten times slower than a DOS shell script. Unless you do not provide any code to compare, e.g you shell and you python snippet to batch dl 5000 files, I can't see how we can help you.
2
4
0
I have been playing around with Python's FTP library and am starting to think that it is too slow as compared to using a script file in DOS? I run sessions where I download thousands of data files (I think I have over 8 million right now). My observation is that the download process seems to take five to ten times a...
Python's FTPLib too slow?
0.085505
0
0
8,009
834,840
2009-05-07T14:05:00.000
4
1
0
0
python,ftp,performance,dos
835,474
7
false
0
0
The speed problem is probably in your code. FTPlib is not 10 times slower.
2
4
0
I have been playing around with Python's FTP library and am starting to think that it is too slow as compared to using a script file in DOS? I run sessions where I download thousands of data files (I think I have over 8 million right now). My observation is that the download process seems to take five to ten times a...
Python's FTPLib too slow?
0.113791
0
0
8,009
834,932
2009-05-07T14:22:00.000
1
1
0
0
java,python,authentication,encryption,hash
840,803
4
false
1
0
Let me just add a few random thoughts/comments to your proposals. RSA: Since you are mainly interested in authentication, I assume you'd want to use RSA signatures. This would imply that each user needs his own privat key. To me that sounds a little bit like overkill, especially when user and server already share comm...
3
0
0
I am writing a server-client application to receive user message and publish it. Thinking about authentication method. Asymmetric encryption, probably RSA. Hash (salt+password+'msg'+'userid'), SHA256 HMAC, SHA256. seems to be more secured than the method 2. Also involve hashing the password and msg data. Symmetric En...
authentication method
0.049958
0
0
1,626
834,932
2009-05-07T14:22:00.000
2
1
0
0
java,python,authentication,encryption,hash
836,074
4
false
1
0
Can't you just use standard SSL sockets to secure the connection, validate the user with a password, and then send the message to be published? If there won't be many clients, you can even use a self-signed certificate and put it in a KeyStore in the client app, that way you won't need to buy a certificate from Verisig...
3
0
0
I am writing a server-client application to receive user message and publish it. Thinking about authentication method. Asymmetric encryption, probably RSA. Hash (salt+password+'msg'+'userid'), SHA256 HMAC, SHA256. seems to be more secured than the method 2. Also involve hashing the password and msg data. Symmetric En...
authentication method
0.099668
0
0
1,626
834,932
2009-05-07T14:22:00.000
0
1
0
0
java,python,authentication,encryption,hash
837,532
4
false
1
0
RSA protocol is generally used to setup a key exchange for a faster encryption means. That's how SSL works. If the security requirements for your applications are so sensitive that you require PKI, then it should be said (without any intent to be harsh) that if you need to ask about it on SO, then its probably somet...
3
0
0
I am writing a server-client application to receive user message and publish it. Thinking about authentication method. Asymmetric encryption, probably RSA. Hash (salt+password+'msg'+'userid'), SHA256 HMAC, SHA256. seems to be more secured than the method 2. Also involve hashing the password and msg data. Symmetric En...
authentication method
0
0
0
1,626
836,992
2009-05-07T20:55:00.000
0
0
0
1
python,google-app-engine,transactions,google-cloud-datastore
838,960
3
true
1
0
After a through research, I have found that a distributed transaction layer that provides a solution to the single entity group restriction has been developed in userland with the help of some google people. But so far, it is not released and is only available in java.
1
3
0
in my google app application, whenever a user purchases a number of contracts, these events are executed (simplified for clarity): user.cash is decreased user.contracts is increased by the number contracts.current_price is updated. market.no_of_transactions is increased by 1. in a rdms, these would be placed within t...
datastore transaction restrictions
1.2
1
0
384
837,256
2009-05-07T21:59:00.000
-1
1
0
1
python,ruby
837,862
5
false
1
0
For python code to run the interpreter needs to be launched as a process. So system() is your best option. For calling the python code you could use RPC or network sockets, got for the simplest thing which could possibly work.
2
5
0
Does a easy to use Ruby to Python bridge exist? Or am I better off using system()?
How do I invoke Python code from Ruby?
-0.039979
0
0
6,499
837,256
2009-05-07T21:59:00.000
2
1
0
1
python,ruby
837,296
5
false
1
0
I don't think there's any way to invoke Python from Ruby without forking a process, via system() or something. The language run times are utterly diferent, they'd need to be in separate processes anyway.
2
5
0
Does a easy to use Ruby to Python bridge exist? Or am I better off using system()?
How do I invoke Python code from Ruby?
0.07983
0
0
6,499
839,384
2009-05-08T11:20:00.000
1
0
0
1
python,twisted,protocols,p2p
839,411
4
false
0
0
Yes, twisted was used to create the initial version of Bittorrent. There are some opensource libraries to start from.
1
14
0
Can you tell me: could I use twisted for p2p-applications creating? And what protocols should I choose for this?
Twisted and p2p applications
0.049958
0
0
5,823
839,755
2009-05-08T13:19:00.000
4
0
1
0
python,time,python-2.5,time-t,year2038
1,865,730
3
true
0
0
The best solution I've found is to get a source copy of Python 2.5, and re-compile the time module with compilers which defaults time_t to 64 bit, for example VS2005 or VS2008 (may also configure the C runtime to prevent side-by-side issue).
3
5
0
The official Python 2.5 on Windows was build with Visual Studio.Net 2003, which uses 32 bit time_t. So when the year is > 2038, it just gives exceptions. Although this is fixed in Python 2.6 (which changed time_t to 64 bit with VS2008), I'd like to use 2.5 because many modules are already compiled for it. So here's my ...
How to use time > year 2038 on official Windows Python 2.5
1.2
0
0
2,919
839,755
2009-05-08T13:19:00.000
7
0
1
0
python,time,python-2.5,time-t,year2038
839,830
3
false
0
0
I don't mean to sound trite, but why not: forget about the Y2038 bug with Python 2.5 upgrade to Python 2.6 at some point in the future before 2038 edit: To clarify: (and I'm serious — I didn't mean to poke fun) Presumably you can upgrade Python to 2.6 (or later) at some indefinite time between now and 2038. Maybe in ...
3
5
0
The official Python 2.5 on Windows was build with Visual Studio.Net 2003, which uses 32 bit time_t. So when the year is > 2038, it just gives exceptions. Although this is fixed in Python 2.6 (which changed time_t to 64 bit with VS2008), I'd like to use 2.5 because many modules are already compiled for it. So here's my ...
How to use time > year 2038 on official Windows Python 2.5
1
0
0
2,919
839,755
2009-05-08T13:19:00.000
7
0
1
0
python,time,python-2.5,time-t,year2038
839,826
3
false
0
0
The datetime module in the standard library should work fine for you. What do you need from module time that datetime doesn't offer?
3
5
0
The official Python 2.5 on Windows was build with Visual Studio.Net 2003, which uses 32 bit time_t. So when the year is > 2038, it just gives exceptions. Although this is fixed in Python 2.6 (which changed time_t to 64 bit with VS2008), I'd like to use 2.5 because many modules are already compiled for it. So here's my ...
How to use time > year 2038 on official Windows Python 2.5
1
0
0
2,919
841,159
2009-05-08T18:23:00.000
0
0
1
0
python,yacc,lex,ply
842,331
4
false
0
0
I typically use a separate 'command reader' to obtain a complete command - probably a line in your case - into a host variable string, and then arrange for the lexical analyzer to analyze the string, including telling me when it didn't reach the end. This is hard to set up, but make some classes of error reporting eas...
2
3
0
Forgive me, I'm completely new to parsing and lex/yacc, and I'm probably in way over my head, but nonetheless: I'm writing a pretty basic calculator with PLY, but it's input might not always be an equation, and I need to determine if it is or not when parsing. The extremes of the input would be something that evaluates...
Tokenizing left over data with lex/yacc
0
0
0
674
841,159
2009-05-08T18:23:00.000
1
0
1
0
python,yacc,lex,ply
842,248
4
true
0
0
There is a built-in error token in yacc. You would normally do something like: line: goodline | badline ; badline : error '\n' /* Error-handling action, if needed */ goodline : equation '\n' ; Any line that doesn't match equation will be handled by badline. You might want to use yyerrok in the error handling action t...
2
3
0
Forgive me, I'm completely new to parsing and lex/yacc, and I'm probably in way over my head, but nonetheless: I'm writing a pretty basic calculator with PLY, but it's input might not always be an equation, and I need to determine if it is or not when parsing. The extremes of the input would be something that evaluates...
Tokenizing left over data with lex/yacc
1.2
0
0
674
841,669
2009-05-08T20:35:00.000
8
1
0
1
.net,ruby,powershell,scripting,ironpython
841,689
7
false
0
0
Except for the seventh item on your list this should be fairly trivial using Powershell and WMI, as this is perhaps the natural domain for Powershell. Since you won't need another language for the first six list items it shouldn't really matter what you use for the last one. You probably can use PS (I've never done IO ...
3
0
0
I just got a project where I have to do the following on a Windows OS: detect how many drives (C: D: E: ..etc) are connected to current system what the system labels are for each volume how much storage (both used and free) for each of the drives what format each drive is (NTFS/FAT32) how many files are in a given ...
Advice for Windows system scripting+programming
1
0
0
501
841,669
2009-05-08T20:35:00.000
0
1
0
1
.net,ruby,powershell,scripting,ironpython
844,915
7
false
0
0
As for Perl, Ruby too has access to all Win32 API and WMI functions.
3
0
0
I just got a project where I have to do the following on a Windows OS: detect how many drives (C: D: E: ..etc) are connected to current system what the system labels are for each volume how much storage (both used and free) for each of the drives what format each drive is (NTFS/FAT32) how many files are in a given ...
Advice for Windows system scripting+programming
0
0
0
501
841,669
2009-05-08T20:35:00.000
0
1
0
1
.net,ruby,powershell,scripting,ironpython
842,535
7
false
0
0
I'll give you the unpopular answer then since no one else has added it: Perl. If you're comfortable with the Win32 API as a C/C++ programmer, Perl may be the easier way to go. It has modules for accessing the Win32 API and Perl is quite easy for C/C++ programmers to get up to speed in. Perl has always done the job f...
3
0
0
I just got a project where I have to do the following on a Windows OS: detect how many drives (C: D: E: ..etc) are connected to current system what the system labels are for each volume how much storage (both used and free) for each of the drives what format each drive is (NTFS/FAT32) how many files are in a given ...
Advice for Windows system scripting+programming
0
0
0
501
842,120
2009-05-08T22:41:00.000
1
0
0
1
python,windows,scripting,batch-file,io
842,139
3
false
0
0
Try subprocess.Popen(). It allows you to redirect stdout and stderr to files.
1
3
0
I'm trying to write a python script (in windows) that runs a batch file and will take the command line output of that batch file as input. The batch file runs processes that I don't have access to and gives output based on whether those processes are successful. I'd like to take those messages from the batch file and u...
Piping Batch File output to a Python script
0.066568
0
0
9,251
842,208
2009-05-08T23:10:00.000
20
0
0
0
wxpython,wxwidgets
843,023
1
false
0
1
wx.Window is the base class for all widgets (not necessarily all windows - the name is misleading). wx.Panel is a subclass of wx.Window, which is more tailored towards containing widgets inside it. For example, it by default allows moving between widgets using "tab", and handles a focus event in a way that is more usef...
1
4
0
I got the impression that Panel is better. Is that true? What advantage does one have over the other? What reason is there to use one over the other?
wxPython: What is the difference between a wx.Panel and a wx.Window?
1
0
0
3,627
842,831
2009-05-09T06:45:00.000
4
0
0
0
python,sql-server,django,pyodbc
843,500
7
false
1
0
We are using django-mssql in production at our company. We too had an existing system using mssql. For me personally it was the best design decision I have ever made because my productivity increased dramatically now that I can use django . I submitted a patch but when I started using django-mssql and did a week or t...
2
52
0
Has anybody got recent experience with deploying a Django application with an SQL Server database back end? Our workplace is heavily invested in SQL Server and will not support Django if there isn't a sufficiently developed back end for it. I'm aware of mssql.django-pyodbc and django-mssql as unofficially supported bac...
Using Sql Server with Django in production
0.113791
1
0
48,333
842,831
2009-05-09T06:45:00.000
1
0
0
0
python,sql-server,django,pyodbc
843,476
7
false
1
0
Haven't used it in production yet, but my initial experiences with django-mssql have been pretty solid. All you need are the Python Win32 extensions and to get the sqlserver_ado module onto your Python path. From there, you just use sql_server.pyodbc as your DATABASE_ENGINE. So far I haven't noticed anything missing, b...
2
52
0
Has anybody got recent experience with deploying a Django application with an SQL Server database back end? Our workplace is heavily invested in SQL Server and will not support Django if there isn't a sufficiently developed back end for it. I'm aware of mssql.django-pyodbc and django-mssql as unofficially supported bac...
Using Sql Server with Django in production
0.028564
1
0
48,333
842,856
2009-05-09T07:20:00.000
0
0
1
0
python,regex,string,substring
842,904
6
false
0
0
First of all, I would suggest you to sort the initial list in ascending order. Because scanning for a shorter substring is faster that scanning for a longer substring.
1
30
0
I have a list of possible substrings, e.g. ['cat', 'fish', 'dog']. In practice, the list contains hundreds of entries. I'm processing a string, and what I'm looking for is to find the index of the first appearance of any of these substrings. To clarify, for '012cat' the result is 3, and for '0123dog789cat' the result ...
What's the most efficient way to find one of several substrings in Python?
0
0
0
14,288
843,268
2009-05-09T13:05:00.000
0
0
1
0
python,windows
843,294
4
false
0
0
I think you must use windows API, and run by python. use os.system('logoff'); (or logout, I forget) it is not tested, because I am using ubuntu now...
1
1
0
I want to write a small program that given a time (in minutes) as input, sleeps in the background for that time, and then forces a return to the "switch user screen" (equivalent to the Winkey+L combination) or logs off a user (may be another user logged in on the same machine). What functions or libraries in Python cou...
Logout or switch user in Windows using Python
0
0
0
3,173
843,698
2009-05-09T17:22:00.000
3
0
1
0
python,objective-c,macos,pyobjc
845,560
3
true
0
0
Finally figured this one out myself. The key to this is to make the final executable link with /System/Library/Frameworks/Python.framework instead of /Library/Frameworks/Python.framework.
1
1
0
I use Python 2.6 more than I use Leopard's default python installation, so I have it set as my main Python installation. But I'd rather use the default Python for a PyObjC program I'm working on. Is there any way to specify to only use it instead of Python 2.6?
How do I choose which Python installation to run in a PyObjC program?
1.2
0
0
454
844,746
2009-05-10T05:15:00.000
2
0
0
0
python,django,django-templates
844,828
6
false
1
0
I ended up adding a method to the model in question, and that method can be accessed like an attribute in the template. Still, i think it would be great if a built in tag allowed you to dynamically lookup an attribute, since this is a problem a lot of us constantly have in our templates.
1
50
0
Python's getattr() method is useful when you don't know the name of a certain attribute in advance. This functionality would also come in handy in templates, but I've never figured out a way to do it. Is there a built-in tag or non-built-in tag that can perform dynamic attribute lookups?
Performing a getattr() style lookup in a django template
0.066568
0
0
25,291
845,502
2009-05-10T15:11:00.000
8
1
1
0
c#,python,ironpython
845,506
3
false
0
0
Yes, by hosting IronPython.
1
6
0
Is there an easy way to call Python objects from C#, that is without any COM mess?
using Python objects in C#
1
0
0
10,077
846,139
2009-05-10T21:25:00.000
3
1
1
0
python,ruby
846,168
4
false
0
0
After running through some tutorials on-line (the ones posted so far look pretty good), find a current Ruby project you've done (or are working on) and re-write it in Python. I've used this technique to transition from various languages, and it's helped enormously.
1
17
0
I've been programming Ruby pretty extensively for the past four years or so, and I'm extremely comfortable with the language. For no particular reason, I've decided to learn some Python this week. Is there a specific book, tutorial, or reference that would be well-suited to someone coming from a nearly-identical langua...
What's the quickest way for a Ruby programmer to pick up Python?
0.148885
0
0
4,331
846,383
2009-05-11T00:41:00.000
11
0
0
0
python,database,django,macos
846,403
3
true
0
0
This is an error that crops up when the build tools cannot find your Postgresql libraries. It means one of three things: You don't have postgresql installed on your system. If so, download and build postgres, or download a pre-built psycopg2 binary for OS X. You have postgresql installed on your system, but you instal...
1
3
0
I have downloaded the latest build of pyscopg2 and have tried to build and install it using the directions provided. However i always get an error saying that 'w' is undeclared. Does anybody have any experience with this?
Problem installing pyscopg2 on Mac OS X
1.2
0
0
6,020
846,950
2009-05-11T06:30:00.000
0
0
0
1
python,networking,sockets,twisted,httplib2
847,014
2
true
0
0
Should new networking code (with the exception of small command line tools) be written with Twisted? Maybe. It really depends. Sometimes its just easy enough to wrap the blocking calls in their own thread. Twisted is good for large scale network code. Would you mix Twisted, http2lib or socket code in the same projec...
1
6
0
Many python libraries, even recently written ones, use httplib2 or the socket interface to perform networking tasks. Those are obviously easier to code on than Twisted due to their blocking nature, but I think this is a drawback when integrating them with other code, especially GUI one. If you want scalability, concurr...
Is Twisted an httplib2/socket replacement?
1.2
0
1
1,969
847,860
2009-05-11T12:24:00.000
1
0
0
0
c#,c++,python,c,vb.net
847,883
2
false
0
1
Compiling can be done by calling cl.exe which comes with Visual Studio. Of course you could also use GCC instead.
1
1
0
I'm trying to make a vb.net application that has got 2 textboxes, 7 radio buttons and 2 buttons(one named compile and the other 'run'). How can I load the content of a C/C++(or any programming language) file into the 1st textbox and on clicking the compile button, i should be able to show the errors or the C/C++ progra...
How to write a vb.net code to compile C/C++ programs?
0.099668
0
0
1,053
848,508
2009-05-11T14:55:00.000
0
1
0
1
python,m2crypto
848,795
3
false
0
0
Possibly its looking up shared libs libssl.so and libcrypto.so and finding the old ones in /usr/lib if you add the new_path to the top of /etc/ld.so.conf so it gets searched first it would work. But this might break other OpenSSL applications expecting old OpenSSL.
1
2
0
M2Crypto provides EC support for ECDSA/ECDH. I have installed OpenSSL 0.9.8i which contains support for EC. However when I run "from M2Crypto import EC,BIO" I get error saying EC_init() failed. So I added debug to print m2.OPENSSL_VERSION_TEXT value. It gets printed as "OpenSSL 0.9.7 19 Feb 2003". This version of OpenS...
Python M2Crypto EC Support
0
0
0
880
849,334
2009-05-11T18:13:00.000
2
0
1
0
python,resources,location,package,shared
849,803
3
false
0
0
We put non .py files in /opt/foo/foo-1.2/... Except, of course, for static media that is served by Apache, that goes to /var/www/html/foo/foo-1.1/media/... Except, of course, for customer-specific configuration files. They go to /var/opt/customer/foo/... Those follow the Linux standards as I understand them. We try ...
2
4
0
This should be a common scenario, but could not find any relevant post yet.. I plan to deploy a Python library (I guess the same applies to regular applications) which makes use of some images and other resource files. What is the standard location for such items? I imagine, for project Foo, the choices would be Have ...
Standard non-code resource location for python packages
0.132549
0
0
453
849,334
2009-05-11T18:13:00.000
2
0
1
0
python,resources,location,package,shared
849,446
3
true
0
0
This question is somewhat incomplete, because a proper answer would depend on the underlying operating system, as each has its own modus operandi. In linux (and most unix based OSs) for example /usr/share/foo or /usr/local/share/foo would be the standard. In OS X you can do the same, but I would think "/Library/Applica...
2
4
0
This should be a common scenario, but could not find any relevant post yet.. I plan to deploy a Python library (I guess the same applies to regular applications) which makes use of some images and other resource files. What is the standard location for such items? I imagine, for project Foo, the choices would be Have ...
Standard non-code resource location for python packages
1.2
0
0
453
850,630
2009-05-12T00:18:00.000
3
1
1
0
python,embedded
850,642
5
false
0
0
Number 3 should and will work. You do not need the .pyo or .py files in order to use the compiled python code.
2
12
0
To squeeze into the limited amount of filesystem storage available in an embedded system I'm currently playing with, I would like to eliminate any files that could reasonably be removed without significantly impacting functionality or performance. The *.py, *.pyo, and *.pyc files in the Python library account for a si...
Python *.py, *.pyo, *.pyc: Which can be eliminated for an Embedded System?
0.119427
0
0
7,405
850,630
2009-05-12T00:18:00.000
2
1
1
0
python,embedded
851,194
5
false
0
0
I would recommend keeping only .py files. The difference in startup time isn't that great, and having the source around is a plus, as it will run under different python versions without any issues. As of python 2.6, setting sys.dont_write_bytecode to True will suppress compilation of .pyc and .pyo files altogether, so ...
2
12
0
To squeeze into the limited amount of filesystem storage available in an embedded system I'm currently playing with, I would like to eliminate any files that could reasonably be removed without significantly impacting functionality or performance. The *.py, *.pyo, and *.pyc files in the Python library account for a si...
Python *.py, *.pyo, *.pyc: Which can be eliminated for an Embedded System?
0.07983
0
0
7,405
850,877
2009-05-12T02:20:00.000
-1
0
1
0
python,algorithm,for-loop
850,910
5
false
0
0
For a general list, you have to at least go over every member at least once to get the sum, which is exactly what a for loop does. Using library APIs (like sum) is more convenient, but I doubt it would actually be faster.
2
13
0
Is there a way to sum up a list of numbers faster than with a for-loop, perhaps in the Python library? Or is that something really only multi-threading / vector processing can do efficiently? Edit: Just to clarify, it could be a list of any numbers, unsorted, just input from the user.
Faster way to sum a list of numbers than with a for-loop?
-0.039979
0
0
27,803
850,877
2009-05-12T02:20:00.000
1
0
1
0
python,algorithm,for-loop
850,898
5
false
0
0
Well, I don't know if it is faster but you could try a little calculus to make it one operation. (N*(N+1))/2 gives you the sum of every number from 1 to N, and there are other formulas for solving more complex sums.
2
13
0
Is there a way to sum up a list of numbers faster than with a for-loop, perhaps in the Python library? Or is that something really only multi-threading / vector processing can do efficiently? Edit: Just to clarify, it could be a list of any numbers, unsorted, just input from the user.
Faster way to sum a list of numbers than with a for-loop?
0.039979
0
0
27,803
851,010
2009-05-12T03:20:00.000
4
0
1
0
python,windows
851,039
6
false
0
0
You can compare len(os.listdir("path")) to zero to see if there are any files in the directory.
1
4
0
Say I want to manipulate some files on a floppy drive or a USB card reader. How do I check to see if the drive in question is ready? (That is, has a disk physically inserted.) The drive letter exists, so os.exists() will always return True in this case. Also, at this point in the process I don't yet know any file nam...
How do I check if a disk is in a drive using python?
0.132549
0
0
3,839
851,636
2009-05-12T07:52:00.000
3
0
0
0
python,django,django-admin
920,320
17
false
1
0
Note that if instead of pre-selecting a filter value you want to always pre-filter the data before showing it in the admin, you should override the ModelAdmin.queryset() method instead.
2
105
0
How can I change the default filter choice from 'ALL'? I have a field named as status which has three values: activate, pending and rejected. When I use list_filter in Django admin, the filter is by default set to 'All' but I want to set it to pending by default.
Default filter in Django admin
0.035279
0
0
42,742
851,636
2009-05-12T07:52:00.000
2
0
0
0
python,django,django-admin
1,560,919
17
false
1
0
I know that is not the best solution, but i changed the index.html in the admin template, line 25 and 37 like this: 25: <th scope="row"><a href="{{ model.admin_url }}{% ifequal model.name "yourmodelname" %}?yourflag_flag__exact=1{% endifequal %}">{{ model.name }}</a></th> 37: <td><a href="{{ model.admin_url }}{% ifequa...
2
105
0
How can I change the default filter choice from 'ALL'? I have a field named as status which has three values: activate, pending and rejected. When I use list_filter in Django admin, the filter is by default set to 'All' but I want to set it to pending by default.
Default filter in Django admin
0.023525
0
0
42,742
854,353
2009-05-12T19:11:00.000
0
0
0
1
python,apache-flex,google-app-engine
854,403
2
false
1
0
Do a HTTP post from Flex to your AppEngine app using the URLRequest class.
1
0
0
I want to communicate using flex client with GAE, I am able to communicate using XMl from GAE to FLex but how should I post from flex3 to python code present on App Engine. Can anyone give me a hint about how to send login information from Flex to python Any ideas suggest me some examples.....please provide me some he...
How to establish communication between flex and python code build on Google App Engine
0
0
1
1,782
855,191
2009-05-12T22:27:00.000
-18
0
1
0
python,list,size
22,240,449
10
false
0
0
There is no limitation of list number. The main reason which causes your error is the RAM. Please upgrade your memory size.
3
141
0
In Python, how big can a list get? I need a list of about 12000 elements. Will I still be able to run list methods such as sorting, etc?
How Big can a Python List Get?
-1
0
0
205,647
855,191
2009-05-12T22:27:00.000
5
0
1
0
python,list,size
855,195
10
false
0
0
12000 elements is nothing in Python... and actually the number of elements can go as far as the Python interpreter has memory on your system.
3
141
0
In Python, how big can a list get? I need a list of about 12000 elements. Will I still be able to run list methods such as sorting, etc?
How Big can a Python List Get?
0.099668
0
0
205,647
855,191
2009-05-12T22:27:00.000
1
0
1
0
python,list,size
855,200
10
false
0
0
I'd say you're only limited by the total amount of RAM available. Obviously the larger the array the longer operations on it will take.
3
141
0
In Python, how big can a list get? I need a list of about 12000 elements. Will I still be able to run list methods such as sorting, etc?
How Big can a Python List Get?
0.019997
0
0
205,647
855,408
2009-05-12T23:29:00.000
5
0
0
1
python,django,macos
856,033
4
false
1
0
Unless you are planning on going to production with OS X you might not want to bother. If you must do it, go straight to mod_wsgi. Don't bother with mod_python or older solutions. I did mod_python on Apache and while it runs great now, it took countless hours to set up. Also, just to clarify something based on what you...
2
1
0
I've just completed the very very nice django tutorial and it all went swimmingly. One of the first parts of the tutorial is that it says not to use their example server thingie in production, my first act after the tutorial was thus to try to run my app on apache. I'm running OSX 10.5 and have the standard apache (whi...
Running django on OSX
0.244919
0
0
1,602
855,408
2009-05-12T23:29:00.000
2
0
0
1
python,django,macos
856,986
4
false
1
0
Yet another option is to consider using a virtual machine for your development. You can install a full version of whatever OS your production server will be running - say, Debian - and run your Apache and DB in the VM. You can connect to the virtual disk in the Finder, so you can still use TextMate (or whatever) on OSX...
2
1
0
I've just completed the very very nice django tutorial and it all went swimmingly. One of the first parts of the tutorial is that it says not to use their example server thingie in production, my first act after the tutorial was thus to try to run my app on apache. I'm running OSX 10.5 and have the standard apache (whi...
Running django on OSX
0.099668
0
0
1,602
856,173
2009-05-13T05:15:00.000
4
0
0
0
python,mysql,linux,perl
856,208
2
false
0
0
Write an insert trigger which duplicates inserted rows to a secondary table. Periodically poll the secondary table for rows with an external application/cronjob; if any rows are in the table, delete them and do your processing (or set a 'processing started' flag and only delete from the secondary table upon successful ...
2
3
0
I need to launch a server side process off a mysql row insert. I'd appreciate some feedback/suggestions. So far I can think of three options: 1st (least attractive): My preliminary understanding is that I can write a kind of "custom trigger" in C that could fire off a row insert. In addition to having to renew my C s...
launch a process off a mysql row insert
0.379949
1
0
227
856,173
2009-05-13T05:15:00.000
0
0
0
0
python,mysql,linux,perl
856,210
2
false
0
0
I had this issue about 2 years ago in .NET and I went with the 3rd approach. However, looking back at it, I'm wondering if looking into Triggers with PhpMyAdmin & MySQL isn't the approach to look into.
2
3
0
I need to launch a server side process off a mysql row insert. I'd appreciate some feedback/suggestions. So far I can think of three options: 1st (least attractive): My preliminary understanding is that I can write a kind of "custom trigger" in C that could fire off a row insert. In addition to having to renew my C s...
launch a process off a mysql row insert
0
1
0
227
858,213
2009-05-13T14:16:00.000
5
0
0
0
python,django,django-models,upload
2,424,900
3
false
1
0
If you added a user field to the model, and have that attribute set before you performed an upload, then you could get the user in to your upload_location function via the instance attribute.
1
3
0
I've got a model like this def upload_location(instance, filename): return 'validate/%s/builds/%s' % (get_current_user(), filename) class MidletPair(models.Model): jad_file = models.FileField(upload_to = upload_location) jar_file = models.FileField(upload_to = upload_location) upload_to=tempfile.ge...
How to save django FileField to user folder?
0.321513
0
0
5,337
859,319
2009-05-13T17:34:00.000
2
0
0
0
python,django
859,951
3
false
1
0
Templates are just strings not file names. Probably your best option is to monkey patch render_to_response and/or direct_to_template and copy the filename arg into the context.
1
8
0
For debugging purposes, I would like to have a variable in all my templates holding the path of the template being rendered. For example, if a view renders templates/account/logout.html I would like {{ template_name }} to contain the string templates/account/logout.html. I don't want to go and change any views (specia...
Getting the template name in django template
0.132549
0
0
4,840
859,594
2009-05-13T18:28:00.000
0
1
1
0
python,windows,path
859,615
9
false
0
0
What's it set to? Have you tried creating a PYTHONPATH environment variable?
4
12
0
I'm trying to change my PYTHONPATH. I've tried to change it in "My Computer" etc, but it doesn't exist there. I searched in the registry in some places, and even ran a whole search for the word 'PYTHONPATH', but to no avail. However, it Python I can easily see it exists. So where is it?
Can't find my PYTHONPATH
0
0
0
45,286
859,594
2009-05-13T18:28:00.000
0
1
1
0
python,windows,path
859,618
9
false
0
0
You need modify your environment variables. How to do this depends on which version of Windows you have. If the PYTHONPATH variable doesn't exist, you have to create it. It might not exist if you haven't already created it.
4
12
0
I'm trying to change my PYTHONPATH. I've tried to change it in "My Computer" etc, but it doesn't exist there. I searched in the registry in some places, and even ran a whole search for the word 'PYTHONPATH', but to no avail. However, it Python I can easily see it exists. So where is it?
Can't find my PYTHONPATH
0
0
0
45,286
859,594
2009-05-13T18:28:00.000
1
1
1
0
python,windows,path
3,079,003
9
false
0
0
MacOS 10.5.8, Python 2.6, Eclipse+Pydev 1.5.7 Python installation's site-package is, for example: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages create symlinks YOUR LIBRARY inside into site-package, for example: cd /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-pac...
4
12
0
I'm trying to change my PYTHONPATH. I've tried to change it in "My Computer" etc, but it doesn't exist there. I searched in the registry in some places, and even ran a whole search for the word 'PYTHONPATH', but to no avail. However, it Python I can easily see it exists. So where is it?
Can't find my PYTHONPATH
0.022219
0
0
45,286
859,594
2009-05-13T18:28:00.000
0
1
1
0
python,windows,path
67,562,437
9
false
0
0
I had same problem and oliver-zehentleitner's answer in github solved my problem. He said: Maybe You install package with pip for python2 and run with python3, just try to install with pip3 or python3 -m pip install python-binance and then run your script again. I hope this can solve yours too.
4
12
0
I'm trying to change my PYTHONPATH. I've tried to change it in "My Computer" etc, but it doesn't exist there. I searched in the registry in some places, and even ran a whole search for the word 'PYTHONPATH', but to no avail. However, it Python I can easily see it exists. So where is it?
Can't find my PYTHONPATH
0
0
0
45,286
861,864
2009-05-14T06:37:00.000
1
0
1
0
python,security,scripting,scripting-language,embedded-language
861,969
13
false
0
0
I'd be wary about releasing such applications into the wild for fear of someone either accidentally, or maliciously, adding destructive code to the file. Your native code that's "in the wild" is equally vulnerable to this attack; that it is in machine code is just a speed bump, and no security. If you are extr...
3
13
0
In the many Python applications I've created, I often create simple modules containing nothing but constants to be used as config files. Additionally, because the config file is actually a Python code file, I can add simple logic for changing variables depending on a debug level, etc. While this works great for intern...
Is there a "safe" subset of Python for use as an embedded scripting language?
0.015383
0
0
4,570
861,864
2009-05-14T06:37:00.000
1
0
1
0
python,security,scripting,scripting-language,embedded-language
1,000,418
13
false
0
0
It's a little hard to understand what you're trying to do -- not enough details. Are you hosting the native app and allowing the users to write plugins? Consider using an OS-level solution by running the Python application as a separate runtime process inside a jail/chroot/similar, and communicating over sockets. Are y...
3
13
0
In the many Python applications I've created, I often create simple modules containing nothing but constants to be used as config files. Additionally, because the config file is actually a Python code file, I can add simple logic for changing variables depending on a debug level, etc. While this works great for intern...
Is there a "safe" subset of Python for use as an embedded scripting language?
0.015383
0
0
4,570
861,864
2009-05-14T06:37:00.000
4
0
1
0
python,security,scripting,scripting-language,embedded-language
861,875
13
false
0
0
No there is no production ready subset of Python that is "safe". Python has had a few sand box modules which were deprecated due to deficiencies. Your best bet is to either create your own parser, or isolate the python process with syscall hooks and a jailed account. Some people might point you to PyPy, but it is unfin...
3
13
0
In the many Python applications I've created, I often create simple modules containing nothing but constants to be used as config files. Additionally, because the config file is actually a Python code file, I can add simple logic for changing variables depending on a debug level, etc. While this works great for intern...
Is there a "safe" subset of Python for use as an embedded scripting language?
0.061461
0
0
4,570
863,253
2009-05-14T13:11:00.000
2
1
1
0
python,collective-intelligence
986,107
6
false
0
0
I suggest translating them to C#. I have been porting chapter 2 "Recommendations" to VB.Net. Along the way I'm learning Python as a side-effect. Toby does some amazing things with Python lists. Dealing with the the extra Python libraries is another story. Ndelicious is a close match to pyDelicious, but it is missing a ...
3
3
0
I'm currently reading a great book called 'Programming Collective Intelligence' by Toby Segaran (which i highly recommend) The code examples are all written in Python, and as I have already learnt one new language this year (graduating from VB.net to C#) i'm not keen to jump on another learning curve. This leaves my wi...
Python and Collective Intelligence
0.066568
0
0
2,273
863,253
2009-05-14T13:11:00.000
1
1
1
0
python,collective-intelligence
863,568
6
false
0
0
The book is about algorithms, not the details of programming, and the language of choice is just to make the examples concrete. As the author says, "The code examples in this book are written in Python... but I provide explanations of all the algorithms so that programmers of other languages can follow." (p. xv) Pytho...
3
3
0
I'm currently reading a great book called 'Programming Collective Intelligence' by Toby Segaran (which i highly recommend) The code examples are all written in Python, and as I have already learnt one new language this year (graduating from VB.net to C#) i'm not keen to jump on another learning curve. This leaves my wi...
Python and Collective Intelligence
0.033321
0
0
2,273
863,253
2009-05-14T13:11:00.000
20
1
1
0
python,collective-intelligence
863,292
6
true
0
0
One challenge you'll find is that not only are the algorithms implemented in Python, but the book makes extensive use of Python libraries like BeautifulSoup, Numpy, PIL, and others (see appendix A). I doubt there are any specifics of the algorithms that you couldn't port to another language, but you'll have trouble wor...
3
3
0
I'm currently reading a great book called 'Programming Collective Intelligence' by Toby Segaran (which i highly recommend) The code examples are all written in Python, and as I have already learnt one new language this year (graduating from VB.net to C#) i'm not keen to jump on another learning curve. This leaves my wi...
Python and Collective Intelligence
1.2
0
0
2,273
864,883
2009-05-14T18:16:00.000
1
0
1
0
python,file-io
4,588,481
5
false
0
0
for row in matrix: file.write(" ".join(map(str,row))+"\n") This works for me... and writes the output in matrix format
1
10
0
I need to write a series of matrices out to a plain text file from python. All my matricies are in float format so the simple file.write() and file.writelines() do not work. Is there a conversion method I can employ that doesn't have me looping through all the lists (matrix = list of lists in my case) converting the...
How do I write a float list of lists to file in Python
0.039979
0
0
70,119
864,887
2009-05-14T18:17:00.000
1
0
0
0
python,windows-mobile,mobile-phones
864,988
1
false
1
1
Can't help you much with Python\CE but if you want a great db for mobile devices SQLLite will do the job for you. If you do a quick google you'll find there are libraries for connecting to SQLLite with Python too.
1
0
0
I've wanted to get into Python development for awhile and most of my programming experience has been in .NET and no mobile development. I recently thought of a useful app to make for my windows mobile phone and thought this could be a great first Python project. I did a little research online and found PyCe which I ...
Beginning Windows Mobile 6.1 Development With Python
0.197375
0
0
1,216
865,082
2009-05-14T18:56:00.000
1
0
1
1
python,shell,wxpython,multiprocessing
892,646
2
true
0
0
First create the shell Decouple the shell from your app by making its locals empty Create your code string Compile the code string and get a code object Execute the code object in the shell from wx.py.shell import Shell frm = wx.Frame(None) sh = Shell(frm) frm.Show() sh.interp.locals = {} ...
1
1
0
I would like to create a shell which will control a separate process that I created with the multiprocessing module. Possible? How? EDIT: I have already achieved a way to send commands to the secondary process: I created a code.InteractiveConsole in that process, and attached it to an input queue and an output queue, s...
Python: Plugging wx.py.shell.Shell into a separate process
1.2
0
0
1,527
865,382
2009-05-14T19:58:00.000
2
1
1
0
python,grep,plone,zope
5,189,472
12
false
0
0
And simply because there are not enough answers... If you're developing routinely, it's well worth the effort to install Eclipse with Pydev (or even easier, Aptana Studio - which is a modified Eclipse), in which case the find tools are right there.
3
23
0
I'm working on a Python program that makes heavy use of eggs (Plone). That means there are 198 directories full of Python code I might want to search through while debugging. Is there a good way to search only the .py files in only those directories, avoiding unrelated code and large binary files?
How do you grep through code that lives in many different directories?
0.033321
0
0
12,967
865,382
2009-05-14T19:58:00.000
4
1
1
0
python,grep,plone,zope
5,131,554
12
false
0
0
This problem was the motivation for the creation of collective.recipe.omelette. It is a buildout recipe which can symlink all the eggs from your working set into one directory structure, which you can point your favorite search utility at.
3
23
0
I'm working on a Python program that makes heavy use of eggs (Plone). That means there are 198 directories full of Python code I might want to search through while debugging. Is there a good way to search only the .py files in only those directories, avoiding unrelated code and large binary files?
How do you grep through code that lives in many different directories?
0.066568
0
0
12,967
865,382
2009-05-14T19:58:00.000
2
1
1
0
python,grep,plone,zope
5,131,426
12
false
0
0
Just in case you want a non-commandline OSS solution... I use pycharm. It has built in support for buildout. You point it at a buildout generated bin/instance and it sets the projects external dependencies to all the eggs used by the instance. Then all the IDE's introspection and code navigation work nicely. Goto defin...
3
23
0
I'm working on a Python program that makes heavy use of eggs (Plone). That means there are 198 directories full of Python code I might want to search through while debugging. Is there a good way to search only the .py files in only those directories, avoiding unrelated code and large binary files?
How do you grep through code that lives in many different directories?
0.033321
0
0
12,967
865,973
2009-05-14T21:42:00.000
21
0
1
0
python,algorithm
865,997
8
false
0
0
To delete half the N images you cannot be faster than O(N)! You do know that the O() notation means (among other things) that constant multiplicative factors are irrelevant, yes?
4
1
0
I have a folder with thousands of images. I want to delete every other image. What is the most effective way to do this? Going through each one with i%2==0 is still O(n). Is there a fast way to do this (preferably in Python)? Thx
Algorithm: How to Delete every other file
1
0
0
3,527
865,973
2009-05-14T21:42:00.000
3
0
1
0
python,algorithm
866,018
8
false
0
0
Going through each one with i%2==0 is still O(n). Is there a fast way to do this (preferably in Python)? The only way to be faster than O(n) is if your files are already sorted, and you only want to delete 1 file. You said i%2==0, this means you are deleting every "even" file. O(n/2) is still O(n)
4
1
0
I have a folder with thousands of images. I want to delete every other image. What is the most effective way to do this? Going through each one with i%2==0 is still O(n). Is there a fast way to do this (preferably in Python)? Thx
Algorithm: How to Delete every other file
0.07486
0
0
3,527
865,973
2009-05-14T21:42:00.000
1
0
1
0
python,algorithm
866,009
8
false
0
0
If you wanted to delete Log(n) files, there would be... You can store images in a database, though ( MySQL has a "blob" type, among several others, that will store your images). Then you could do it in O(1) if you named them smartly. /edit i hate how i have to use shorthand and bad grammar to get my answers in quickly!...
4
1
0
I have a folder with thousands of images. I want to delete every other image. What is the most effective way to do this? Going through each one with i%2==0 is still O(n). Is there a fast way to do this (preferably in Python)? Thx
Algorithm: How to Delete every other file
0.024995
0
0
3,527
865,973
2009-05-14T21:42:00.000
2
0
1
0
python,algorithm
866,005
8
false
0
0
I fail to see any conceivable way in which deleting n/2 files could be faster than O(n), unless the filesystem has some special feature for deleting large numbers of files (but I don't think that actually exists in practice, if it's even possible)
4
1
0
I have a folder with thousands of images. I want to delete every other image. What is the most effective way to do this? Going through each one with i%2==0 is still O(n). Is there a fast way to do this (preferably in Python)? Thx
Algorithm: How to Delete every other file
0.049958
0
0
3,527
866,737
2009-05-15T02:16:00.000
0
0
0
1
python,shell
866,750
3
false
0
0
You say "pipe" so I assume you're dealing with text output from the subprocesses. A simple solution may be to just write output to files? e.g. in the subprocess: Redirect output %TEMP%\output.txt On exit, copy output.txt to a directory your main process is watching. In the main process: Every second, examine direct...
1
1
0
I want to pipe [edit: real-time text] the output of several subprocesses (sometimes chained, sometimes parallel) to a single terminal/tty window that is not the active python shell (be it an IDE, command-line, or a running script using tkinter). IPython is not an option. I need something that comes with the standard in...
Creating a new terminal/shell window to simply display text
0
0
0
1,202
867,175
2009-05-15T06:03:00.000
1
0
0
0
python,tcp,database-connection
867,433
3
false
0
0
If you want to implement timeouts that work no matter how the client library is connecting to the server, it's best to attempt the DB operations in a separate thread, or, better, a separate process, which a "monitor" thread/process can kill if needed; see the multiprocessing module in Python 2.6 standard library (there...
2
0
0
I am writing a code in python in which I established a connection with database. I have queries in a loop. While queries being executed in the loop , If i unplug the network cable it should stop with an exception. But this not happens, When i again plug yhe network cabe after 2 minutes it starts again from where it end...
db connection in python
0.066568
1
0
442
867,175
2009-05-15T06:03:00.000
2
0
0
0
python,tcp,database-connection
867,202
3
false
0
0
Your database connection will almost certainly be based on a TCP socket. TCP sockets will hang around for a long time retrying before failing and (in python) raising an exception. Not to mention and retries/automatic reconnection attempts in the database layer.
2
0
0
I am writing a code in python in which I established a connection with database. I have queries in a loop. While queries being executed in the loop , If i unplug the network cable it should stop with an exception. But this not happens, When i again plug yhe network cabe after 2 minutes it starts again from where it end...
db connection in python
0.132549
1
0
442
869,885
2009-05-15T17:17:00.000
1
0
1
0
python,loops
24,374,584
17
false
0
0
for var in range(10,-1,-1) works
1
357
0
I am trying to loop from 100 to 0. How do I do this in Python? for i in range (100,0) doesn't work.
Loop backwards using indices in Python?
0.011764
0
0
449,182
870,520
2009-05-15T19:48:00.000
0
0
1
0
python,filter,whitelist
870,565
10
false
0
0
I'd use a regex. For lowercase match [a-z].
1
22
0
Imagine a string, like 'Agh#$%#%2341- -!zdrkfd' and I only wish to perform some operating on it such that only the lowercase letters are returned (as an example), which in this case would bring 'ghzdrkfd'. How do you do this in Python? The obvious way would be to create a list, of characters, 'a' through 'z', then i...
How do you filter a string such that only characters in your list are returned?
0
0
0
31,214
871,447
2009-05-16T01:36:00.000
6
0
0
1
python,pipe,fork
871,515
4
false
0
0
Using fcntl.fcntl(readPipe, fcntl.F_SETFL, os.O_NONBLOCK) Before invoking the read() solved both problems. The read() call is no longer blocking and the data is appearing after just a flush() on the writing end.
1
13
0
I've recently needed to write a script that performs an os.fork() to split into two processes. The child process becomes a server process and passes data back to the parent process using a pipe created with os.pipe(). The child closes the 'r' end of the pipe and the parent closes the 'w' end of the pipe, as usual. I co...
Python program using os.pipe and os.fork() issue
1
0
0
16,065
872,065
2009-05-16T09:34:00.000
1
0
0
0
python,django,django-templates
875,985
6
false
1
0
Kind of an oblique answer, but if being able to use tools like Dreamweaver on your templates is important to you, you may find you like Genshi better than Django Templates, and it's easy enough to switch your template engine. Genshi is an XML templating language that is one of the inheritors of the Zope TAL family. Yo...
2
20
0
Is there a tool out there for visually building Django templates? Thanks
Visual Editor for Django Templates?
0.033321
0
0
10,614
872,065
2009-05-16T09:34:00.000
2
0
0
0
python,django,django-templates
874,222
6
false
1
0
There's no WYSIWYG tool like Dreamweaver. But highligting is possible. I am using Kate to edit my templates. For instance when you comment in Django template it inserts {% comment %}.
2
20
0
Is there a tool out there for visually building Django templates? Thanks
Visual Editor for Django Templates?
0.066568
0
0
10,614
872,290
2009-05-16T12:01:00.000
2
0
1
0
python,string
872,295
9
false
0
0
You're basically testing whether a member is in a set or not, right? If so, and because you said you have lots of memory, why not just load all the words as keys in memcache, and then for every word, just check if it is present in memcache or not. Or use that data structure that is used by bash to autocomplete command ...
2
11
0
I have a file containing roughly all the words in English (~60k words, ~500k characters). I want to test whether a certain word I receive as input is "in English" (i.e. if this exact word is in the list). What would be the most efficient way to do this in Python? The trivial solution is to load the file into a list and...
Most Efficient Way to Find Whether a Large List Contains a Specific String (Python)
0.044415
0
0
15,715
872,290
2009-05-16T12:01:00.000
2
0
1
0
python,string
872,353
9
false
0
0
Two things: The Python 'mutable set' type has an 'add' method ( s.add(item) ), so you could go right from reading (a line) from your big file straight into a set without using a list as an intermediate data structure. Python lets you 'pickle' a data structure, so you could save your big set to a file and save the ti...
2
11
0
I have a file containing roughly all the words in English (~60k words, ~500k characters). I want to test whether a certain word I receive as input is "in English" (i.e. if this exact word is in the list). What would be the most efficient way to do this in Python? The trivial solution is to load the file into a list and...
Most Efficient Way to Find Whether a Large List Contains a Specific String (Python)
0.044415
0
0
15,715
872,695
2009-05-16T16:01:00.000
4
1
0
0
php,python,mod-python
872,913
6
false
0
0
I think you have some misconceptions about how HTTP works. Nothing in the http standard requires you to have a certain file as a resource. It is just the way how mod_php works, that for a given path, this path is translated to a php file on the disk of the server, which in turn is interpreted by the compiler. The mod_p...
5
4
0
Why mod_python is oop but mod_php is not ? Example :We go to www.example.com/dir1/dir2 if you use mod_python apache opens www/dir1.py and calls dir2 method but if you use php module apache opens www/dir1/dir2/index.php
mod_php vs mod_python
0.132549
0
0
2,975
872,695
2009-05-16T16:01:00.000
-1
1
0
0
php,python,mod-python
872,710
6
false
0
0
Perhaps I misunderstand your question, but both Python and PHP support both procedural and object-oriented programming. (Though one could argue that Python's support for OO is the stronger of the two.)
5
4
0
Why mod_python is oop but mod_php is not ? Example :We go to www.example.com/dir1/dir2 if you use mod_python apache opens www/dir1.py and calls dir2 method but if you use php module apache opens www/dir1/dir2/index.php
mod_php vs mod_python
-0.033321
0
0
2,975
872,695
2009-05-16T16:01:00.000
0
1
0
0
php,python,mod-python
873,885
6
false
0
0
in PHP you can program your web pages the top-to-bottom scripts, procedural programming and function calls, OOP. this is the main reason why PHP was first created, and how it evolved. mod_php is just a module for web servers to utilize PHP as a preprocessor. so it just passes HTTP information and the PHP script to PHP ...
5
4
0
Why mod_python is oop but mod_php is not ? Example :We go to www.example.com/dir1/dir2 if you use mod_python apache opens www/dir1.py and calls dir2 method but if you use php module apache opens www/dir1/dir2/index.php
mod_php vs mod_python
0
0
0
2,975
872,695
2009-05-16T16:01:00.000
8
1
0
0
php,python,mod-python
873,822
6
true
0
0
Let's talk about mod_python vs. mod_php. Since the Python language is NOT specifically designed for serving web pages, mod_python must do some additional work. Since the PHP language IS specifically designed to serve web pages, mod_php simply starts a named PHP module. In the case of mod_python (different from mod_fa...
5
4
0
Why mod_python is oop but mod_php is not ? Example :We go to www.example.com/dir1/dir2 if you use mod_python apache opens www/dir1.py and calls dir2 method but if you use php module apache opens www/dir1/dir2/index.php
mod_php vs mod_python
1.2
0
0
2,975
872,695
2009-05-16T16:01:00.000
4
1
0
0
php,python,mod-python
872,824
6
false
0
0
Because mod_python is abstracting the URL into a "RPC-like" mechanism. You can achieve the same in PHP. I always did it by hand, but I am pretty sure there are prepackaged pear modules for this. Note the mod_python behavior is not forcibly "the best". It all amounts to the type of design you want to give to your applic...
5
4
0
Why mod_python is oop but mod_php is not ? Example :We go to www.example.com/dir1/dir2 if you use mod_python apache opens www/dir1.py and calls dir2 method but if you use php module apache opens www/dir1/dir2/index.php
mod_php vs mod_python
0.132549
0
0
2,975
872,737
2009-05-16T16:19:00.000
1
0
0
0
python,ruby,user-interface
873,925
3
false
0
1
I would recommend PyGame.
2
1
0
using Ruby or Python, does someone know how to draw on the screen, covering up any other window? Kind of like, press a key, and the program will show current weather or stock quote on the screen (using the whole screen as the canvas), and then press the key again, and everything restores to the same as before? (like ...
does someone know how to show content on screen (covering up any window) using Ruby or Python?
0.066568
0
0
179
872,737
2009-05-16T16:19:00.000
4
0
0
0
python,ruby,user-interface
872,757
3
true
0
1
You could use the systems dashboard (desktop widgets, or whatever it's called) API. In order to do that you need bindings to it for Python or Ruby. Alternatively you could use some generic gui toolkit or application framework and just create a frameless window with transparent background. Then you need to be sure that ...
2
1
0
using Ruby or Python, does someone know how to draw on the screen, covering up any other window? Kind of like, press a key, and the program will show current weather or stock quote on the screen (using the whole screen as the canvas), and then press the key again, and everything restores to the same as before? (like ...
does someone know how to show content on screen (covering up any window) using Ruby or Python?
1.2
0
0
179
873,089
2009-05-16T19:17:00.000
1
0
1
1
python,debugging,arguments,pdb
67,887,744
4
false
0
0
python3 -m pdb myscript.py -a val if using argparse with flag "a" and value "val"
1
22
0
I've got python script (ala #! /usr/bin/python) and I want to debug it with pdb. How can I pass arguments to the script? I have a python script and would like to debug it with pdb. Is there a way that I can pass arguments to the scripts?
How do you pass script arguments to pdb (Python)?
0.049958
0
0
12,717
873,564
2009-05-16T23:45:00.000
0
0
1
0
python
873,572
3
false
0
0
I would probably create a timesheet object for each week, or pay period. Each timesheet object might have a collection of days, with hours worked or times clocked in and out. For persistent storage for a web site, I'd use a database like mysql. For an application running on a single machine I'd maybe use pickle, or a ...
1
1
0
Say I make a program that keeps track of the days I worked and the hours I worked, would I use a dictionary? And how would I differentiate from a Monday on week 1 from a Monday on week 2? How do I get it to store this information after I close the program? (Python Language)
Timesheet Program to Track Days/Hours worked?
0
0
0
3,319
874,461
2009-05-17T12:02:00.000
12
0
0
0
python,matlab,file-io,scipy,mat-file
66,453,257
12
false
0
0
There is a great library for this task called: pymatreader. Just do as follows: Install the package: pip install pymatreader Import the relevant function of this package: from pymatreader import read_mat Use the function to read the matlab struct: data = read_mat('matlab_struct.mat') use data.keys() to locate where...
1
508
1
Is it possible to read binary MATLAB .mat files in Python? I've seen that SciPy has alleged support for reading .mat files, but I'm unsuccessful with it. I installed SciPy version 0.7.0, and I can't find the loadmat() method.
Read .mat files in Python
1
0
0
566,507
874,476
2009-05-17T12:09:00.000
7
1
0
1
python,unix,root,sudo
874,519
3
false
0
0
The concept of "admin-privileges" in our day of fine grained privilege control is becoming hard to define. If you are running on unix with "traditional" access control model, getting the effective user id (available in os module) and checking that against root (0) could be what you are looking for. If you know accessin...
1
2
0
how can i check admin-privileges for my script during running?
Admin privileges for script
1
0
0
2,996
874,815
2009-05-17T15:20:00.000
1
0
0
1
python,subprocess,stdout,popen
2,328,115
10
false
0
0
I've been running into this problem as well. The problem occurs because you are trying to read stderr as well. If there are no errors, then trying to read from stderr would block. On Windows, there is no easy way to poll() file descriptors (only Winsock sockets). So a solution is not to try and read from stderr.
2
47
0
I'd like to use the subprocess module in the following way: create a new process that potentially takes a long time to execute. capture stdout (or stderr, or potentially both, either together or separately) Process data from the subprocess as it comes in, perhaps firing events on every line received (in wxPython sa...
How do I get 'real-time' information back from a subprocess.Popen in python (2.5)
0.019997
0
0
13,436
874,815
2009-05-17T15:20:00.000
7
0
0
1
python,subprocess,stdout,popen
874,865
10
false
0
0
stdout will be buffered - so you won't get anything till that buffer is filled, or the subprocess exits. You can try flushing stdout from the sub-process, or using stderr, or changing stdout on non-buffered mode.
2
47
0
I'd like to use the subprocess module in the following way: create a new process that potentially takes a long time to execute. capture stdout (or stderr, or potentially both, either together or separately) Process data from the subprocess as it comes in, perhaps firing events on every line received (in wxPython sa...
How do I get 'real-time' information back from a subprocess.Popen in python (2.5)
1
0
0
13,436
874,856
2009-05-17T15:45:00.000
0
0
0
0
python,import,wxpython
875,039
3
false
0
1
You could create a global boolean variable like g_window_was_drawn and check it in the function that does the work of creating a window. The value would be false at the start of the program and would change to True when first creating a window. The function that creates the window would check if the g_window_was_drawn ...
1
0
0
I'm sorry for the verbal description. I have a wxPython app in a file called applicationwindow.py that resides in a package called garlicsimwx. When I launch the app by launching the aforementioned file, it all works well. However, I have created a file rundemo.py in a folder which contains the garlicsimwx package, whi...
wxPython launches my app twice when importing a sub-package
0
0
0
223