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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1,188,585 | 2009-07-27T14:45:00.000 | 10 | 0 | 0 | 0 | python,database,data-structures,persistence | 1,188,704 | 7 | true | 0 | 0 | Pickling is a two-face coin.
On one side, you have a way to store your object in a very easy way. Just four lines of code and you pickle. You have the object exactly as it is.
On the other side, it can become a compatibility nightmare. You cannot unpickle objects if they are not defined in your code, exactly as they were defined when pickled. This strongly limits your ability to refactor the code, or rearrange stuff in your modules.
Also, not everything can be pickled, and if you are not strict on what gets pickled and the client of your code has full freedom of including any object, sooner or later it will pass something unpicklable to your system, and the system will go boom.
Be very careful about its use. there's no better definition of quick and dirty. | 4 | 5 | 0 | I'm considering the idea of creating a persistent storage like a dbms engine, what would be the benefits to create a custom binary format over directly cPickling the object and/or using the shelve module? | What are the benefits of not using cPickle to create a persistent storage for data? | 1.2 | 1 | 0 | 1,116 |
1,188,585 | 2009-07-27T14:45:00.000 | 2 | 0 | 0 | 0 | python,database,data-structures,persistence | 1,188,679 | 7 | false | 0 | 0 | Note that not all objects may be directly pickled - only basic types, or objects that have defined the pickle protocol.
Using your own binary format would allow you to potentially store any kind of object.
Just for note, Zope Object DB (ZODB) is following that very same approach, storing objects with the Pickle format. You may be interested in getting their implementations. | 4 | 5 | 0 | I'm considering the idea of creating a persistent storage like a dbms engine, what would be the benefits to create a custom binary format over directly cPickling the object and/or using the shelve module? | What are the benefits of not using cPickle to create a persistent storage for data? | 0.057081 | 1 | 0 | 1,116 |
1,188,585 | 2009-07-27T14:45:00.000 | 0 | 0 | 0 | 0 | python,database,data-structures,persistence | 1,189,928 | 7 | false | 0 | 0 | Will you ever need to process data from untrusted sources? If so, you should know that the pickle format is actually a virtual machine that is capable of executing arbitrary code on behalf of the process doing the unpickling. | 4 | 5 | 0 | I'm considering the idea of creating a persistent storage like a dbms engine, what would be the benefits to create a custom binary format over directly cPickling the object and/or using the shelve module? | What are the benefits of not using cPickle to create a persistent storage for data? | 0 | 1 | 0 | 1,116 |
1,188,737 | 2009-07-27T15:11:00.000 | 2 | 0 | 1 | 0 | python,http | 1,188,759 | 1 | true | 0 | 0 | Why would you need a specific order in the POST parameters in the first place? As far as I know there are no requirements that POST parameter order is preserved by web servers.
Every language I have used, has used a dictionary type object to hold these parameters as they are inherently key/value pairs. | 1 | 2 | 0 | I have a web service that accepts passed in params using http POST but in a specific order, eg (name,password,data). I have tried to use httplib but all the Python http POST libraries seem to take a dictionary, which is an unordered data structure. Any thoughts on how to http POST params in order for Python?
Thanks! | Python POST ordered params | 1.2 | 0 | 1 | 345 |
1,191,689 | 2009-07-28T02:43:00.000 | 2 | 1 | 0 | 0 | python,r,statistics | 1,832,314 | 7 | false | 0 | 0 | I apply hierarchical Bayes models in R in combination with JAGS (Linux) or sometimes WinBUGS (Windows, or Wine). Check out the book of Andrew Gelman, as referred to above. | 3 | 12 | 1 | Hierarchical Bayes models are commonly used in Marketing, Political Science, and Econometrics. Yet, the only package I know of is bayesm, which is really a companion to a book (Bayesian Statistics and Marketing, by Rossi, et al.) Am I missing something? Is there a software package for R or Python doing the job out there, and/or a worked-out example in the associated language? | Hierarchical Bayes for R or Python | 0.057081 | 0 | 0 | 8,690 |
1,191,689 | 2009-07-28T02:43:00.000 | 0 | 1 | 0 | 0 | python,r,statistics | 55,978,470 | 7 | false | 0 | 0 | This answer comes almost ten years late, but it will hopefully help someone in the future.
The brms package in R is a very good option for Bayesian hierarchical/multilevel models, using a syntax very similar to the lme4 package.
The brms package uses the probabilistic programming language Stan in the back to do the inferences. Stan uses more advanced sampling methods than JAGS and BUGS, such as Hamiltonian Monte Carlo, which provides more efficient and reliable samples from the posterior distribution.
If you wish to model more complicated phenomena, then you can use the rstanpackage to compile Stan models from R. There is also the Python alternative PyStan. However, in order to do this, you must learn how to use Stan. | 3 | 12 | 1 | Hierarchical Bayes models are commonly used in Marketing, Political Science, and Econometrics. Yet, the only package I know of is bayesm, which is really a companion to a book (Bayesian Statistics and Marketing, by Rossi, et al.) Am I missing something? Is there a software package for R or Python doing the job out there, and/or a worked-out example in the associated language? | Hierarchical Bayes for R or Python | 0 | 0 | 0 | 8,690 |
1,191,689 | 2009-07-28T02:43:00.000 | 0 | 1 | 0 | 0 | python,r,statistics | 1,197,766 | 7 | false | 0 | 0 | The lme4 package, which estimates hierarchical models using frequentist methods, has a function called mcmcsamp that allows you to sample from the posterior distribution of the model using MCMC. This currently works only for linear models, quite unfortunately. | 3 | 12 | 1 | Hierarchical Bayes models are commonly used in Marketing, Political Science, and Econometrics. Yet, the only package I know of is bayesm, which is really a companion to a book (Bayesian Statistics and Marketing, by Rossi, et al.) Am I missing something? Is there a software package for R or Python doing the job out there, and/or a worked-out example in the associated language? | Hierarchical Bayes for R or Python | 0 | 0 | 0 | 8,690 |
1,192,480 | 2009-07-28T07:47:00.000 | 2 | 0 | 1 | 0 | python,vim | 1,214,504 | 6 | false | 0 | 0 | glenn jackman asked how to enter the characters (I'm assuming he means characters like "»").
Brian Carper suggests a method using the character's Unicode index number. Since many of these distinctive-looking characters are digraphs [ :help digraphs ], you can also use the CNTL-k shortcut, which is generally easier to remember.
So, for example, you can generate the "»" in Insert mode by typing CNTL-k and the ">" character twice. | 1 | 9 | 0 | How to make tabulation look different than whitespace in vim (highlighted for example).
That would be useful for code in Python. | Making tabulation look different than just whitespace | 0.066568 | 0 | 0 | 480 |
1,194,802 | 2009-07-28T15:12:00.000 | 0 | 0 | 1 | 1 | macos,mono,ironpython | 1,195,079 | 2 | false | 0 | 0 | Look at the Terminal menu, Preferences... menu item.
In the Preferences dialog box, click on the Settings selection.
Within the settings, click on the Keyboard tab.
You have probably modified your tab key to not work correctly. It should not be mentioned as a special key and should generate an ordinary tab character.
Also, run a stty -a command in your Terminal tool. Someone may have changed your oxtabs setting or mapped tab (^I) to something unexpected. | 1 | 0 | 0 | I am running IronPython 2.0.2 interactive console with Mono 2.4 on OSX Terminal.app . How do I insert indent/tab in the Terminal.app ? I want to do this so I can indent my code.
For example I want to input print "hello tab" what I see is print "hellotab" despite pressing the tab key many times. When the command gets executed it prints hellotab. Another weird behavior is that after pressing tab a bunch of time and then press delete the tabs shows up, but cannot be removed, and ipy still prints hellotab .
I tried inserting tabs with IronRuby (ir.exe) and I don't see the tab showing up when I press it, but it is displayed when the command is executed. | How to insert indent/tab in os x terminal for IronPython (ipy.exe)? | 0 | 0 | 0 | 1,938 |
1,196,074 | 2009-07-28T18:56:00.000 | 0 | 0 | 1 | 1 | python,process,daemon | 71,059,019 | 9 | false | 0 | 0 | I haven't tried this yet but using .pyw files instead of .py files should help. pyw files dosen't have a console so in theory it should not appear and work like a background process. | 1 | 363 | 0 | I'm trying to port a shell script to the much more readable python version. The original shell script starts several processes (utilities, monitors, etc.) in the background with "&". How can I achieve the same effect in python? I'd like these processes not to die when the python scripts complete. I am sure it's related to the concept of a daemon somehow, but I couldn't find how to do this easily. | How to start a background process in Python? | 0 | 0 | 0 | 549,636 |
1,196,708 | 2009-07-28T21:01:00.000 | -2 | 0 | 1 | 0 | python,import,directory,shared | 1,196,815 | 6 | false | 0 | 0 | "I appended to sys.path ..."
Please don't.
Set the PYTHONPATH environment variable from outside your application. | 3 | 0 | 0 | I have some python modules in a shared folder on a Windows machine.
The file is \mtl12366150\test\mymodule.py
os.path.exists tells me this path is valid.
I appended to sys.path the folder \mtl12366150\test (and os.path.exists tells me this path is valid).
When I try to import mymodule I get an error saying the module doesn't exist.
Is there a way to import module that are located in shared path? | How to import python module in a shared folder? | -0.066568 | 0 | 0 | 3,164 |
1,196,708 | 2009-07-28T21:01:00.000 | 0 | 0 | 1 | 0 | python,import,directory,shared | 1,200,216 | 6 | false | 0 | 0 | I think I found the answer. I was using Python 2.6.1 and with Python 2.6.2 it now works. I had the same faulty behavior with python 2.5.4. | 3 | 0 | 0 | I have some python modules in a shared folder on a Windows machine.
The file is \mtl12366150\test\mymodule.py
os.path.exists tells me this path is valid.
I appended to sys.path the folder \mtl12366150\test (and os.path.exists tells me this path is valid).
When I try to import mymodule I get an error saying the module doesn't exist.
Is there a way to import module that are located in shared path? | How to import python module in a shared folder? | 0 | 0 | 0 | 3,164 |
1,196,708 | 2009-07-28T21:01:00.000 | 1 | 0 | 1 | 0 | python,import,directory,shared | 1,196,801 | 6 | false | 0 | 0 | Did you forget to use a raw string, or escape the backslashes, in your additional sys.path component? Remember that "\t" is a tab, whereas r"\t" or "\t" are a backslash followed by a tab.
In most applications you are actually better off using forward slashes rather than backslashes even for Windows paths, and most Windows APIs will accept them just fine. Otherwise, be careful to use raw strings!
[There is no need to add __init__.py files in the directories above a simple Python module] | 3 | 0 | 0 | I have some python modules in a shared folder on a Windows machine.
The file is \mtl12366150\test\mymodule.py
os.path.exists tells me this path is valid.
I appended to sys.path the folder \mtl12366150\test (and os.path.exists tells me this path is valid).
When I try to import mymodule I get an error saying the module doesn't exist.
Is there a way to import module that are located in shared path? | How to import python module in a shared folder? | 0.033321 | 0 | 0 | 3,164 |
1,197,981 | 2009-07-29T04:00:00.000 | 2 | 1 | 0 | 0 | python,ascii | 1,198,002 | 4 | true | 0 | 0 | ASCII is the American Standard Code for Information Interchange and does not include any accented letters. Your best bet is to get Unicode (as you say you can) and encode it as UTF-8 (maybe ISO-8859-1 or some weird codepage if you're dealing with seriously badly coded user-agents/clients, sigh) -- the content type header of that part together with text/plain can express what encoding you've chosen to use (I do recommend trying UTF-8 unless you have positively demonstrated it cannot work -- it's almost universally supported these days and MUCH more flexible than any ISO-8859 or "codepage" hack!). | 1 | 4 | 0 | I need to convert any html entity into its ASCII equivalent using Python. My use case is that I am cleaning up some HTML used to build emails to create plaintext emails from the HTML.
Right now, I only really know how to create unicode from these entities when I need ASCII (I think) so that the plaintext email reads correctly with things like accented characters. I think a basic example is the html entity "& aacute;" or á being encoded into ASCII.
Furthermore, I'm not even 100% sure that ASCII is what I need for a plaintext email. As you can tell, I'm completely lost on this encoding stuff. | Convert html entities to ascii in Python | 1.2 | 0 | 0 | 8,608 |
1,199,350 | 2009-07-29T10:44:00.000 | 0 | 0 | 1 | 0 | python,file,csv | 1,199,371 | 6 | false | 0 | 0 | Probably either a dict of list or a list of dict. Personally, I'd go with the former. So, parse the heading row of the CSV to get a dict from column heading to column index. Then when you're reading through each row, work out what index you're at, grab the column heading, and then append to the end of the list for that column heading. | 2 | 2 | 1 | I have a CSV file which I am processing and putting the processed data into a text file.
The entire data that goes into the text file is one big table(comma separated instead of space). My problem is How do I remember the column into which a piece of data goes in the text file?
For eg. Assume there is a column called 'col'.
I just put some data under col. Now after a few iterations, I want to put some other piece of data under col again (In a different row). How do I know where exactly col comes? (And there are a lot of columns like this.)
Hope I am not too vague... | Whats the best way of putting tabular data into python? | 0 | 0 | 0 | 798 |
1,199,350 | 2009-07-29T10:44:00.000 | 1 | 0 | 1 | 0 | python,file,csv | 1,199,409 | 6 | false | 0 | 0 | Is SQLite an option for you? I know that you have CSV input and output. However, you can import all the data into the SQLite database. Then do all the necessary processing with the power of SQL. Then you can export the results as CSV. | 2 | 2 | 1 | I have a CSV file which I am processing and putting the processed data into a text file.
The entire data that goes into the text file is one big table(comma separated instead of space). My problem is How do I remember the column into which a piece of data goes in the text file?
For eg. Assume there is a column called 'col'.
I just put some data under col. Now after a few iterations, I want to put some other piece of data under col again (In a different row). How do I know where exactly col comes? (And there are a lot of columns like this.)
Hope I am not too vague... | Whats the best way of putting tabular data into python? | 0.033321 | 0 | 0 | 798 |
1,199,493 | 2009-07-29T11:13:00.000 | 0 | 1 | 0 | 0 | python,unit-testing,buildbot | 1,371,766 | 3 | true | 0 | 0 | We've decided to go with decorators that, using platform module and others, check whether the tests should be executed, and if not simply let it pass (though, we saw that python2.7 already has in its trunk a SkipTest exception that could be raised in such cases, to ignore the test). | 1 | 5 | 0 | We have a python project that we want to start testing using buildbot. Its unit tests include tests that should only work on some platforms. So, we've got tests that should pass on all platforms, tests that should only run on 1 specific platform, tests that should pass on platforms A, B, C and tests that pass on B and D.
What is the best way of doing this? Simple suites would be a hassle, since, as described, each test can have a different list of target platforms. I thought about adding "@run_on" and "@ignore_on" decorators that would match platforms to test methods. Is there anything better? | How to distribute and execute platform-specific unit tests? | 1.2 | 0 | 0 | 709 |
1,199,703 | 2009-07-29T11:49:00.000 | 2 | 1 | 0 | 0 | python,server-side | 1,199,744 | 4 | true | 1 | 0 | If your server is running Apache HTTP server, then you need something like mod_wsgi or mod_python installed and running as a module (your server signature may tell you this).
Once running, you may need to add a handler to your apache config, or a default may be setup.
After that, look at the documentation for the middleware of the module you are running, then maybe go on and use something like Django. | 1 | 3 | 0 | I've been told by my hosting company that Python is installed on their servers. How would I go about using it to output a simple HTML page? This is just as a learning exercise at the moment, but one day I'd like to use Python in the same way as I currently use PHP. | How do I use Python serverside with shared hosting? | 1.2 | 0 | 0 | 2,969 |
1,200,726 | 2009-07-29T14:36:00.000 | 1 | 1 | 0 | 0 | .net,xml,ironpython,python,lxml | 1,211,395 | 2 | false | 0 | 0 | Something which you might have already considered:
An alternative is to first port the lxml library to IPy and then your code (depending on the code size). You might have to write some C# wrappers for the native C calls to the C extensions -- I'm not sure what issues, if any, are involved in this with regards to IPy.
Or if the code which you are porting is small, as compared to lxml, then maybe you can just remove the lxml dependency and use the .NET XML libraries. | 1 | 6 | 0 | I need to port some code that relies heavily on lxml from a CPython application to IronPython.
lxml is very Pythonic and I would like to keep using it under IronPython, but it depends on libxslt and libxml2, which are C extensions.
Does anyone know of a workaround to allow lxml under IronPython or a version of lxml that doesn't have those C-extension dependencies? | How to get lxml working under IronPython? | 0.099668 | 0 | 1 | 2,349 |
1,201,507 | 2009-07-29T16:34:00.000 | 1 | 1 | 0 | 0 | python,exception,simplexmlrpcserver | 1,202,742 | 2 | false | 0 | 0 | Yes, this is what happens when you raise an exception on the server side. Are you expecting the SimpleXMLRPCServer to return the exception to the client?
You can only use objects that can be marshalled through XML. This includes
boolean : The True and False constants
integers : Pass in directly
floating-point numbers : Pass in directly
strings : Pass in directly
arrays : Any Python sequence type containing conformable elements. Arrays are returned as lists
structures : A Python dictionary. Keys must be strings, values may be any conformable type. Objects of user-defined classes can be passed in; only their __dict__ attribute is transmitted.
dates : in seconds since the epoch (pass in an instance of the DateTime class) or a datetime.datetime instance.
binary data : pass in an instance of the Binary wrapper class | 1 | 0 | 0 | I'm trying to raise an exception on the Server Side of an SimpleXMLRPCServer; however, all attempts get a "Fault 1" exception on the client side.
RPC_Server.AbortTest()
File "C:\Python25\lib\xmlrpclib.py", line 1147, in call
return self.__send(self.__name, args)
File "C:\Python25\lib\xmlrpclib.py", line 1437, in __request
verbose=self.__verbose
File "C:\Python25\lib\xmlrpclib.py", line 1201, in request
return self._parse_response(h.getfile(), sock)
File "C:\Python25\lib\xmlrpclib.py", line 1340, in _parse_response
return u.close()
File "C:\Python25\lib\xmlrpclib.py", line 787, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: :Test Aborted by a RPC
request"> | Sending an exception on the SimpleXMLRPCServer | 0.099668 | 0 | 1 | 746 |
1,201,628 | 2009-07-29T16:53:00.000 | 4 | 1 | 0 | 1 | java,python,perl,web-services,wrapper | 1,201,722 | 5 | true | 1 | 0 | This depends heavily upon your needs. If Jython is an option for the Python code (it isn't always 100% compatible), then it is probably the best option there. Otherwise, you will need to use Java's Process Builder to call the interpretters directly and return the results on their output stream. This will not be fast (but then again, Jython isn't that fast either, relative to regular Java code), but it is an extremely flexible solution. | 1 | 4 | 0 | I have to deploy some Web Services on a server that only supports the Java ones, but some of them will be done using perl or python. I want to know if is possible to develop a Java wrapper to call a specific code written in perl or python. So, I want to have all the Web Services in Java, but some of them will call some code using other languages.
Thanks in advance.
Regards,
Ukrania | Java Wrapper to Perl/Python code | 1.2 | 0 | 0 | 2,709 |
1,201,771 | 2009-07-29T17:14:00.000 | 3 | 0 | 0 | 0 | python,windows,proxy,registry | 1,205,881 | 3 | true | 0 | 0 | urllib module automatically retrieves settings from registry when no proxies are specified as a parameter or in the environment variables
In a Windows environment, if no proxy
environment variables are set, proxy
settings are obtained from the
registry’s Internet Settings section.
See the documentation of urllib module referenced in the earlier post.
To set the proxy I assume you'll need to use the pywin32 module and modify the registry directly. | 1 | 2 | 0 | How can I get the current Windows' browser proxy setting, as well as set them to a value?
I know I can do this by looking in the registry at Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer, but I'm looking, if it is possible, to do this without messing directly with the registry. | How to set proxy in Windows with Python? | 1.2 | 0 | 1 | 12,290 |
1,201,785 | 2009-07-29T17:17:00.000 | 0 | 0 | 0 | 0 | python,django | 1,201,895 | 1 | false | 1 | 0 | I'd go with option number 2. I don't think your django user is any more likely to get compromised than your Tkinter user. If there's something else under apache that you're worried about, run it under a separate apache with the right user. | 1 | 0 | 0 | I am integrating "legacy" code with Django, and have problems when the process executing Django must write to legacy code directories where it lacks write permissions. (The legacy code is a Python backend to a Tkinter GUI, which I'm repurposing to a browser-based UI.)
I could:
Make the legacy directory writeable
to all, but this seems like bad
practice.
Find the userid of the Django
execution process, assign that to a
group and give that group write
permissions to the whole legacy
directory. (I suspect this is the
user running apache.) This too seems
bad -- if that user is
compromised,the whole directory is at
risk.
Isolate the "write" calls in the
code, ensure they all go somewhere in
a designated subdirectory tree, and
make that tree world (or Django user
group) writeable. This seems the
least risky, but also the most work.
Any other ideas? Am I missing some obvious fix? I'm completely new to this. | Django and File Permissions: Best Practices? | 0 | 0 | 0 | 915 |
1,201,817 | 2009-07-29T17:24:00.000 | 20 | 0 | 0 | 0 | python,numpy | 1,208,039 | 2 | true | 0 | 0 | If you're using numpy 1.3, there's also numpy.lib.recfunctions.append_fields().
For many installations, you'll need to import numpy.lib.recfunctions to access this. import numpy will not allow one to see the numpy.lib.recfunctions | 1 | 22 | 1 | What is the cleanest way to add a field to a structured numpy array? Can it be done destructively, or is it necessary to create a new array and copy over the existing fields? Are the contents of each field stored contiguously in memory so that such copying can be done efficiently? | Adding a field to a structured numpy array | 1.2 | 0 | 0 | 9,033 |
1,203,295 | 2009-07-29T21:55:00.000 | 1 | 0 | 0 | 0 | python,django,testing,sqlite | 1,203,393 | 3 | false | 1 | 0 | The test framework is not saving the data to the database, the data is cleaned once the tests have finished. | 1 | 6 | 0 | I'm trying to provide integration to my django application from subversion through the post commit hook.
I have a django test case (a subclass of unittest.TestCase) that (a) inserts a couple of records into a table, (b) spawns an svn commit, (c) svn commit runs a hook that uses my django model to look up info.
I'm using an sqlite3 db. The test is not using the :memory: db, it is using a real file. I have modified the django test code (for debugging this issue) to avoid deleting the test db when it is finished so I can inspect it.
The test code dumps model.MyModel.objects.all() and the records are there between (a) and (b).
When the hook fires at (c) it also dumps the model and there are no records. When I inspect the db manually after the test runs, there are no records.
Is there something going on in the django test framework that isn't commiting the records to the db file?
To clarify: (d) end the test case. Thus the svn commit hook is run before the test case terminates, and before any django db cleanup code should be run.
Extra info: I added a 15 second delay between (b) and (b) so that I could examine the db file manually in the middle of the test. The records aren't in the file. | can't see records inserted by django test case | 0.066568 | 0 | 0 | 1,488 |
1,204,376 | 2009-07-30T03:51:00.000 | 1 | 0 | 1 | 0 | python,eval | 1,204,403 | 2 | false | 0 | 0 | Do you mean eval or exec? Please post exactly what you ran, plus the full traceback and error message.
The problem is probably because the Python grammar says that lines are terminated by newlines ('\n'), not the two-character sequence '\r\n'.
In general, it would be safer for you to use replace('\r\n', '\n') in case there's a meaningful '\r' in there somewhere. It would be better if you didn't have the '\r' there in the first place ... how are you obtaining the text -- binary read on a Windows box??
Talking about safety, you should be careful about using eval or exec on any old code obtained from a possible enemy. | 1 | 4 | 0 | Why eval function doesn't work with \r\n but with \n. for example
eval("for i in range(5):\r\n print 'hello'") doesn't work
eval("for i in range(5):\n print 'hello'") works
I know there is not a problem cause using replace("\r","") is corrected, but someone knows why happens?
--Edit--
Oh! sorry , exactly, I meant exec. Carriage returns appeared because I'm reading from a HTML textarea via POST (I'm on a Linux box). now It is clearer, thanks to everyone. | \r\n vs \n in python eval function | 0.099668 | 0 | 0 | 4,425 |
1,204,378 | 2009-07-30T03:52:00.000 | 3 | 0 | 1 | 0 | python,wxpython | 1,204,394 | 5 | false | 0 | 0 | You can't do this with just the standard Python library, although there might be some third party package that does it. Barring that, you can use the os package to determine which operating system you're on and use that information to acquire the info you want for that system (and encapsulate that into a single cross-platform function). | 1 | 9 | 0 | From within a Python application, how can I get the total amount of RAM of the system and how much of it is currently free, in a cross-platform way?
Ideally, the amount of free RAM should consider only physical memory that can actually be allocated to the Python process. | Getting total/free RAM from within Python | 0.119427 | 0 | 0 | 10,853 |
1,205,449 | 2009-07-30T09:22:00.000 | 3 | 0 | 0 | 0 | python,neural-network | 1,205,509 | 4 | true | 0 | 0 | You have to encode your input and your output to something that can be represented by the neural network units. ( for example 1 for "x has a certain property p" -1 for "x doesn't have the property p" if your units' range is in [-1, 1])
The way you encode your input and the way you decode your output depends on what you want to train the neural network for.
Moreover, there are many "neural networks" algoritms and learning rules for different tasks( Back propagation, boltzman machines, self organizing maps). | 4 | 3 | 1 | Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types
i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out
if someone could provide examples in python that would be a big help | Neural net input/output | 1.2 | 0 | 0 | 671 |
1,205,449 | 2009-07-30T09:22:00.000 | 0 | 0 | 0 | 0 | python,neural-network | 20,683,280 | 4 | false | 0 | 0 | You have to add the number of units for input and output you need for the problem. If the unknown function to approximate depends on n parameter, you will have n input units. The number of output units depends on the nature of the funcion. For real functions with n real parameters you will have one output unit.
Some problems, for example in forecasting of time series, you will have m output units for the m succesive values of the function. The encoding is important and depends on the choosen algorithm. For example, in backpropagation for feedforward nets, is better to transform, if possible, the greater number of features in discrete inputs, as for classification tasks.
Other aspect of the encoding is that you have to evaluate the number of input and hidden units in function of the amount of data. Too many units related to data may give poor approximation due the course ff dimensionality problem. In some cases, you may to aggregate some of the input data in some way to avoid that problem or use some reduction mechanism as PCA. | 4 | 3 | 1 | Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types
i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out
if someone could provide examples in python that would be a big help | Neural net input/output | 0 | 0 | 0 | 671 |
1,205,449 | 2009-07-30T09:22:00.000 | 2 | 0 | 0 | 0 | python,neural-network | 1,207,505 | 4 | false | 0 | 0 | Your features must be decomposed into parts that can be represented as real numbers. The magic of a Neural Net is it's a black box, the correct associations will be made (with internal weights) during the training
Inputs
Choose as few features as are needed to accurately describe the situation, then decompose each into a set of real valued numbers.
Weather: [temp today, humidity today, temp yesterday, humidity yesterday...] the association between today's temp and today's humidity is made internally
Team stats: [ave height, ave weight, max height, top score,...]
Dice: not sure I understand this one, do you mean how to encode discrete values?*
Complex number: [a,ai,b,bi,...]
* Discrete valued features are tricky, but can still still be encoded as (0.0,1.0). The problem is they don't provide a gradient to learn the threshold on.
Outputs
You decide what you want the output to mean, and then encode your training examples in that format. The fewer output values, the easier to train.
Weather: [tomorrow's chance of rain, tomorrow's temp,...] **
Team stats: [chance of winning, chance of winning by more than 20,...]
Complex number: [x,xi,...]
** Here your training vectors would be: 1.0 if it rained the next day, 0.0 if it didn't
Of course, whether or not the problem can actually be modeled by a neural net is a different question. | 4 | 3 | 1 | Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types
i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out
if someone could provide examples in python that would be a big help | Neural net input/output | 0.099668 | 0 | 0 | 671 |
1,205,449 | 2009-07-30T09:22:00.000 | 0 | 0 | 0 | 0 | python,neural-network | 1,206,597 | 4 | false | 0 | 0 | More complex data usually means adding more neurons in the input and output layers.
You can feed each "field" of your register, properly encoded as a real value (normalized, etc.) to each input neuron, or maybe you can even decompose even further into bit fields, assigning saturated inputs of 1 or 0 to the neurons... for the output, it depends on how you train the neural network, it will try to mimic the training set outputs. | 4 | 3 | 1 | Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types
i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out
if someone could provide examples in python that would be a big help | Neural net input/output | 0 | 0 | 0 | 671 |
1,207,954 | 2009-07-30T17:04:00.000 | 0 | 0 | 1 | 0 | python,path | 5,176,531 | 5 | false | 0 | 0 | May be one can use os.path.relpath(path1, path2) as workaround for os.path.samefile(path1, path2) on Windows?
If os.path.relpath(path1, path2) returns '.' than path1 and path2 point to the same place | 1 | 10 | 0 | How can I check whether two file paths point to the same file in Python? | Check absolute paths in Python | 0 | 0 | 0 | 4,658 |
1,210,711 | 2009-07-31T04:38:00.000 | -10 | 0 | 0 | 0 | python,django | 1,211,756 | 3 | false | 1 | 0 | SQL Join queries are a hack because SQL doesn't have objects or navigation among objects.
Objects don't need "joins". Just access the related objects. | 2 | 4 | 0 | guys, how or where is the "join" query in Django?
i think that Django dont have "join"..but how ill make join?
Thanks | Django .."join" query? | -1 | 0 | 0 | 5,258 |
1,210,711 | 2009-07-31T04:38:00.000 | 4 | 0 | 0 | 0 | python,django | 1,211,769 | 3 | true | 1 | 0 | If you're using models, the select_related method will return the object for any foreign keys you have set up (up to a limit you specify) within that model. | 2 | 4 | 0 | guys, how or where is the "join" query in Django?
i think that Django dont have "join"..but how ill make join?
Thanks | Django .."join" query? | 1.2 | 0 | 0 | 5,258 |
1,211,363 | 2009-07-31T08:47:00.000 | 2 | 0 | 0 | 0 | python,django,web-applications | 1,211,434 | 3 | false | 1 | 0 | Don't do this.
Most files are cached anyway.
But if you really want to add this (because users asked for it), make it optional (default off). | 2 | 0 | 0 | I am trying to download mp3 file to users machine without his/her consent while they are listening the song.So, next time they visit that web page they would not have to download same mp3, but palypack from the local file. this will save some bandwidth for me and for them. it something pandora used to do but I really don't know how to.
any ideas? | downloading files to users machine? | 0.132549 | 0 | 1 | 170 |
1,211,363 | 2009-07-31T08:47:00.000 | 4 | 0 | 0 | 0 | python,django,web-applications | 1,211,370 | 3 | true | 1 | 0 | You can't forcefully download files to a user without his consent. If that was possible you can only imagine what severe security flaw that would be.
You can do one of two things:
count on the browser to cache the media file
serve the media via some 3rd party plugin (Flash, for example) | 2 | 0 | 0 | I am trying to download mp3 file to users machine without his/her consent while they are listening the song.So, next time they visit that web page they would not have to download same mp3, but palypack from the local file. this will save some bandwidth for me and for them. it something pandora used to do but I really don't know how to.
any ideas? | downloading files to users machine? | 1.2 | 0 | 1 | 170 |
1,211,380 | 2009-07-31T08:51:00.000 | 0 | 0 | 0 | 0 | python,user-interface,wxpython,color-scheme | 1,272,807 | 1 | false | 0 | 1 | You can use
styledTextCtrl.StyleSetSpec(wx.stc.STC_STYLE_INDENTGUIDE, "fore:#CDCDCD")
(Bunch of .StyleSetSpec properties)
...
...
...
styCtrl.SetCaretForeground("BLUE")
styCtrl.SetSelBackground(True, wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT))
styCtrl.SetSelForeground(True, wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHTTEXT))
...
(Bunch of Set*() commands)
Don't know if there is a way to load a pre-defined color scheme.
You could define it in YAML and load it up via the commands above and more. | 1 | 1 | 0 | I have a PyShell, which is supposed to be derived from wx.stc.StyledTextCtrl. How do I change the color scheme that it currently uses? | wxPython: Changing the color scheme of a wx.stc.StyledTextCtrl | 0 | 0 | 0 | 828 |
1,213,090 | 2009-07-31T15:10:00.000 | 1 | 0 | 0 | 0 | python,gtk,drawing,pygtk | 6,578,903 | 5 | false | 0 | 1 | You should connect to the expose-event (GTK 2) or draw (GTK 3) signal. In that handler, simply use image.window to get the widget's gtk.gdk.Window; this is a subclass of gtk.gdk.Drawable, so you can draw on it. | 1 | 3 | 0 | I'm using pygtk with PIL. I've already figured out a way to convert PIL Images to gtk.gdk.Pixbufs. What I do to display the pixbuf is I create a gtk.gdk.Image, and then use img.set_from_pixbuf. I now want to draw a few lines onto this image. Apparently I need a Drawable to do that. I've started looking through the docs but already I have 8-10 windows open and it is not being straightforward at all.
So - what magic do I need to type to get a Drawable representing my picture, draw some things on to it, and then turn it into a gdk.Image so I can display it on my app? | pygtk: Draw lines onto a gtk.gdk.Pixbuf | 0.039979 | 0 | 0 | 5,113 |
1,213,328 | 2009-07-31T15:49:00.000 | 1 | 1 | 0 | 0 | python | 1,400,264 | 2 | false | 0 | 0 | To continue where Alex left off..
Download the uuid-1.30.tar.gz from Alex's pypi link.
unzip and untar.
place the uuid.py to your application's python path (e.g., same dir with your own .py files) | 1 | 1 | 0 | I have an older version of python on the server i'm using and cannot upgrade it. is there a way to get the uuid module? | how can I get the uuid module for python 2.4.3 | 0.099668 | 0 | 0 | 3,485 |
1,213,427 | 2009-07-31T16:05:00.000 | 2 | 0 | 0 | 0 | python,django,apache,nginx,centos | 19,777,706 | 1 | false | 1 | 0 | The problem is in the max body size
If you are using NGinx, add client_max_body_size 35m
And if you are using Apache you have to increase this size too. | 1 | 2 | 0 | WheneverI try to upload an mp3 file through a CMS I built with the Django Admin contrib pacakage, the server takes a couple minutes, then gives me a "Connection was reset" error.
I'm running Django on a CentOS server using NGINX which is proxying Apache with mod_wsgi for python. Could this be a server settings issue? | "Connection Reset" error on Django Admin file upload | 0.379949 | 0 | 0 | 1,962 |
1,213,690 | 2009-07-31T16:58:00.000 | 2 | 1 | 0 | 1 | python,macos,module,packages,macports | 49,869,959 | 13 | false | 0 | 0 | You may already have pip3 pre-installed, so just try it! | 3 | 127 | 0 | I'm starting to learn python and loving it. I work on a Mac mainly as well as Linux. I'm finding that on Linux (Ubuntu 9.04 mostly) when I install a python module using apt-get it works fine. I can import it with no trouble.
On the Mac, I'm used to using Macports to install all the Unixy stuff. However, I'm finding that most of the python modules I install with it are not being seen by python. I've spent some time playing around with PATH settings and using python_select . Nothing has really worked and at this point I'm not really understanding, instead I'm just poking around.
I get the impression that Macports isn't universally loved for managing python modules. I'd like to start fresh using a more "accepted" (if that's the right word) approach.
So, I was wondering, what is the method that Mac python developers use to manage their modules?
Bonus questions:
Do you use Apple's python, or some other version?
Do you compile everything from source or is there a package manger that works well (Fink?). | What is the most compatible way to install python modules on a Mac? | 0.03076 | 0 | 0 | 168,159 |
1,213,690 | 2009-07-31T16:58:00.000 | 7 | 1 | 0 | 1 | python,macos,module,packages,macports | 1,214,123 | 13 | false | 0 | 0 | I use MacPorts to install Python and any third-party modules tracked by MacPorts into /opt/local, and I install any manually installed modules (those not in the MacPorts repository) into /usr/local, and this has never caused any problems. I think you may be confused as to the use of certain MacPorts scripts and environment variables.
MacPorts python_select is used to select the "current" version of Python, but it has nothing to do with modules. This allows you to, e.g., install both Python 2.5 and Python 2.6 using MacPorts, and switch between installs.
The $PATH environment variables does not affect what Python modules are loaded. $PYTHONPATH is what you are looking for. $PYTHONPATH should point to directories containing Python modules you want to load. In my case, my $PYTHONPATH variable contains /usr/local/lib/python26/site-packages. If you use MacPorts' Python, it sets up the other proper directories for you, so you only need to add additional paths to $PYTHONPATH. But again, $PATH isn't used at all when Python searches for modules you have installed.
$PATH is used to find executables, so if you install MacPorts' Python, make sure /opt/local/bin is in your $PATH. | 3 | 127 | 0 | I'm starting to learn python and loving it. I work on a Mac mainly as well as Linux. I'm finding that on Linux (Ubuntu 9.04 mostly) when I install a python module using apt-get it works fine. I can import it with no trouble.
On the Mac, I'm used to using Macports to install all the Unixy stuff. However, I'm finding that most of the python modules I install with it are not being seen by python. I've spent some time playing around with PATH settings and using python_select . Nothing has really worked and at this point I'm not really understanding, instead I'm just poking around.
I get the impression that Macports isn't universally loved for managing python modules. I'd like to start fresh using a more "accepted" (if that's the right word) approach.
So, I was wondering, what is the method that Mac python developers use to manage their modules?
Bonus questions:
Do you use Apple's python, or some other version?
Do you compile everything from source or is there a package manger that works well (Fink?). | What is the most compatible way to install python modules on a Mac? | 1 | 0 | 0 | 168,159 |
1,213,690 | 2009-07-31T16:58:00.000 | 6 | 1 | 0 | 1 | python,macos,module,packages,macports | 2,380,159 | 13 | false | 0 | 0 | If you use Python from MacPorts, it has it's own easy_install located at: /opt/local/bin/easy_install-2.6 (for py26, that is). It's not the same one as simply calling easy_install directly, even if you used python_select to change your default python command. | 3 | 127 | 0 | I'm starting to learn python and loving it. I work on a Mac mainly as well as Linux. I'm finding that on Linux (Ubuntu 9.04 mostly) when I install a python module using apt-get it works fine. I can import it with no trouble.
On the Mac, I'm used to using Macports to install all the Unixy stuff. However, I'm finding that most of the python modules I install with it are not being seen by python. I've spent some time playing around with PATH settings and using python_select . Nothing has really worked and at this point I'm not really understanding, instead I'm just poking around.
I get the impression that Macports isn't universally loved for managing python modules. I'd like to start fresh using a more "accepted" (if that's the right word) approach.
So, I was wondering, what is the method that Mac python developers use to manage their modules?
Bonus questions:
Do you use Apple's python, or some other version?
Do you compile everything from source or is there a package manger that works well (Fink?). | What is the most compatible way to install python modules on a Mac? | 1 | 0 | 0 | 168,159 |
1,215,610 | 2009-08-01T01:45:00.000 | 4 | 0 | 1 | 1 | python,ubuntu,setuptools,virtualenv | 6,919,668 | 5 | false | 0 | 0 | You really should not touch Ubuntu's Python installation unless you are building system admin tools, or building something that could be considered to be a new system service.
If you are using Ubuntu to develop or deploy Python applications, always build your own Python from source, tar it up, and use that for deployment. That way you will have all the directories in the right place and virtualenv will work normally. If you will deploy several Python apps on the server, then make your Python live in some place like /home/python or /opt/python or somewhere outside of your home directory. Make sure that you have write permissions for the developers group (users?) so that people can easily add packages.
This also allows you to have two tiers of packages. The ones that are your in-house standard tools can be installed in your Python distro and be part of the tarball that you deploy, and only the app-specific packages would be in a virtualenv.
Do not upgrade or modify the Ubuntu system installed Python. | 3 | 14 | 0 | Can someone please explain to me what is going on with python in ubuntu 9.04?
I'm trying to spin up virtualenv, and the --no-site-packages flag seems to do nothing with ubuntu. I installed virtualenv 1.3.3 with easy_install (which I've upgraded to setuptools 0.6c9) and everything seems to be installed to /usr/local/lib/python2.6/dist-packages
I assume that when installing a package using apt-get, it's placed in /usr/lib/python2.6/dist-packages/ ?
The issue is, there is a /usr/local/lib/python2.6/site-packages as well that just sits there being empty. It would seem (by looking at the path in a virtualenv) that this is the folder virtualenv uses as backup. Thus even thought I omit --no-site-packages, I cant access my local systems packages from any of my virtualenv's.
So my questions are:
How do I get virtualenv to point to one of the dist-packages?
Which dist-packages should I point it to? /usr/lib/python2.6/dist-packages or /usr/local/lib/python2.6/dist-packages/
What is the point of /usr/lib/python2.6/site-packages? There's nothing in there!
Is it first come first serve on the path? If I have a newer version of package XYZ installed in /usr/local/lib/python2.6/dist-packages/ and and older one (from ubuntu repos/apt-get) in /usr/lib/python2.6/dist-packages, which one gets imported when I import xyz? I'm assuming this is based on the path list, yes?
Why the hell is this so confusing? Is there something I'm missing here?
Where is it defined that easy_install should install to /usr/local/lib/python2.6/dist-packages?
Will this affect pip as well?
Thanks to anyone who can clear this up! | Ubuntu + virtualenv = a mess? virtualenv hates dist-packages, wants site-packages | 0.158649 | 0 | 0 | 8,965 |
1,215,610 | 2009-08-01T01:45:00.000 | 9 | 0 | 1 | 1 | python,ubuntu,setuptools,virtualenv | 1,215,627 | 5 | true | 0 | 0 | I'd be tempted to hack it by making site-packages a link to dist-packages, but I guess this might affect other cases where you want to install some extension other than from the ubuntu dist. I can't think of another answer to 1 except tweaking virtualenv's sources (with both ubuntu and virtualenv being so popular I wouldn't be surprised to find tweaked versions already exist).
Re 2, if you're using /usr/local/bin/python you should use the /usr/local version of the lib (including site-packages) and conversely if you're using /usr/bin/python.
Re 3, there will be something there if you ever install an extension for /usr/bin/python from sources (not via easy_install or from ubuntu's distro).
Re 4, yes, earlier entries on the path take precedence.
Re 5, easy_install is easy only in its name -- it does so much dark magic that it's been carefully kept out of the standard python library despite its convenience because the consensus among us python committers is that deep dark magic for convenience is "easy" only on the surface.
Re 6, I think that's an ubuntu modification to easy_install -- if that's right then it's defined wherever Canonical or other ubuntu maintainers make their collective decisions.
Re 7, sorry, no idea -- I have no reasonably recent ubuntu at hand to check. | 3 | 14 | 0 | Can someone please explain to me what is going on with python in ubuntu 9.04?
I'm trying to spin up virtualenv, and the --no-site-packages flag seems to do nothing with ubuntu. I installed virtualenv 1.3.3 with easy_install (which I've upgraded to setuptools 0.6c9) and everything seems to be installed to /usr/local/lib/python2.6/dist-packages
I assume that when installing a package using apt-get, it's placed in /usr/lib/python2.6/dist-packages/ ?
The issue is, there is a /usr/local/lib/python2.6/site-packages as well that just sits there being empty. It would seem (by looking at the path in a virtualenv) that this is the folder virtualenv uses as backup. Thus even thought I omit --no-site-packages, I cant access my local systems packages from any of my virtualenv's.
So my questions are:
How do I get virtualenv to point to one of the dist-packages?
Which dist-packages should I point it to? /usr/lib/python2.6/dist-packages or /usr/local/lib/python2.6/dist-packages/
What is the point of /usr/lib/python2.6/site-packages? There's nothing in there!
Is it first come first serve on the path? If I have a newer version of package XYZ installed in /usr/local/lib/python2.6/dist-packages/ and and older one (from ubuntu repos/apt-get) in /usr/lib/python2.6/dist-packages, which one gets imported when I import xyz? I'm assuming this is based on the path list, yes?
Why the hell is this so confusing? Is there something I'm missing here?
Where is it defined that easy_install should install to /usr/local/lib/python2.6/dist-packages?
Will this affect pip as well?
Thanks to anyone who can clear this up! | Ubuntu + virtualenv = a mess? virtualenv hates dist-packages, wants site-packages | 1.2 | 0 | 0 | 8,965 |
1,215,610 | 2009-08-01T01:45:00.000 | 2 | 0 | 1 | 1 | python,ubuntu,setuptools,virtualenv | 1,216,108 | 5 | false | 0 | 0 | Well I have a Ubuntu 9.04 and quickly tried setting up a couple sandboxes with site-packages and one without. And things are working fine.
The only difference in the approach I took is I used Ubuntu's python-virtualenv package (1.3.3). And presume that it is tweaked by Ubuntu team to suit Ubuntu setups.
To sum up disable easy_installed virtualenv for a while, use packaged python-virtualenv and see if that meets your expectations.
In fact we use similar setup for production without any problem. Rest is already answered by Alex. | 3 | 14 | 0 | Can someone please explain to me what is going on with python in ubuntu 9.04?
I'm trying to spin up virtualenv, and the --no-site-packages flag seems to do nothing with ubuntu. I installed virtualenv 1.3.3 with easy_install (which I've upgraded to setuptools 0.6c9) and everything seems to be installed to /usr/local/lib/python2.6/dist-packages
I assume that when installing a package using apt-get, it's placed in /usr/lib/python2.6/dist-packages/ ?
The issue is, there is a /usr/local/lib/python2.6/site-packages as well that just sits there being empty. It would seem (by looking at the path in a virtualenv) that this is the folder virtualenv uses as backup. Thus even thought I omit --no-site-packages, I cant access my local systems packages from any of my virtualenv's.
So my questions are:
How do I get virtualenv to point to one of the dist-packages?
Which dist-packages should I point it to? /usr/lib/python2.6/dist-packages or /usr/local/lib/python2.6/dist-packages/
What is the point of /usr/lib/python2.6/site-packages? There's nothing in there!
Is it first come first serve on the path? If I have a newer version of package XYZ installed in /usr/local/lib/python2.6/dist-packages/ and and older one (from ubuntu repos/apt-get) in /usr/lib/python2.6/dist-packages, which one gets imported when I import xyz? I'm assuming this is based on the path list, yes?
Why the hell is this so confusing? Is there something I'm missing here?
Where is it defined that easy_install should install to /usr/local/lib/python2.6/dist-packages?
Will this affect pip as well?
Thanks to anyone who can clear this up! | Ubuntu + virtualenv = a mess? virtualenv hates dist-packages, wants site-packages | 0.07983 | 0 | 0 | 8,965 |
1,215,846 | 2009-08-01T04:40:00.000 | 1 | 0 | 0 | 0 | events,wxpython | 1,263,720 | 2 | false | 0 | 1 | Actually, I figured it out. There are events like EVT_GRID_LABEL_LEFT_CLICK and then I test event.GetCol() == -1, to make sure the click is on a whole row, not a whole column. | 1 | 3 | 0 | I would like to be warned when user selects the whole row in a wxGrid but I do not see an event that handles this.What is the best way to do it? | Detect row selection in wxGrid | 0.099668 | 0 | 0 | 3,008 |
1,217,901 | 2009-08-02T00:51:00.000 | 2 | 0 | 0 | 0 | python,django,admin | 3,144,134 | 6 | false | 1 | 0 | If you change the permissions to restrict access then you'll still get the plus sign by a FK/MtM field. Clicking that will open a popup window with 'Permission Denied' in it.
You can actually completely remove the plus sign by not simply not registering the model with the admin.
I have a situation where I have predefined categories that I want users to be able to select more than one of. The best way to do this is with a models.ManyToMany field. You can register the model with the admin, enter the data as required and then remove the registration. | 4 | 8 | 0 | Is there a way to remove the "Add" functionality on the Django admin site? For certain entities, I only want the Django admin to be able to view them or change existing ones, but not add new ones. | Remove the "Add" functionality in Django admin | 0.066568 | 0 | 0 | 6,592 |
1,217,901 | 2009-08-02T00:51:00.000 | 1 | 0 | 0 | 0 | python,django,admin | 8,795,993 | 6 | false | 1 | 0 | An easy effective way is to set max_num=0 for that particular inline. | 4 | 8 | 0 | Is there a way to remove the "Add" functionality on the Django admin site? For certain entities, I only want the Django admin to be able to view them or change existing ones, but not add new ones. | Remove the "Add" functionality in Django admin | 0.033321 | 0 | 0 | 6,592 |
1,217,901 | 2009-08-02T00:51:00.000 | 3 | 0 | 0 | 0 | python,django,admin | 1,218,080 | 6 | false | 1 | 0 | You can customize the permission for each user group from within the admin interface: try going to /admin/auth/group and it should be straightforward from there.
This won't be as granular as the solution offered by the earlier answer, but it will take care of most of your needs without needing to customize the admin. | 4 | 8 | 0 | Is there a way to remove the "Add" functionality on the Django admin site? For certain entities, I only want the Django admin to be able to view them or change existing ones, but not add new ones. | Remove the "Add" functionality in Django admin | 0.099668 | 0 | 0 | 6,592 |
1,217,901 | 2009-08-02T00:51:00.000 | 0 | 0 | 0 | 0 | python,django,admin | 13,954,260 | 6 | false | 1 | 0 | Satya's suggestion of setting max_num=0 works perfectly.
Per the Django docs on the ModelForm class:
For users with JavaScript-enabled browsers, an "Add another" link is provided to enable any number of additional inlines to be added in addition to those provided as a result of the extra argument.
The dynamic link will not appear if the number of currently displayed forms exceeds max_num, or if the user does not have JavaScript enabled.
and
As with regular formsets, you can use the max_num and extra parameters to modelformset_factory to limit the number of extra forms displayed.
max_num does not prevent existing objects from being displayed | 4 | 8 | 0 | Is there a way to remove the "Add" functionality on the Django admin site? For certain entities, I only want the Django admin to be able to view them or change existing ones, but not add new ones. | Remove the "Add" functionality in Django admin | 0 | 0 | 0 | 6,592 |
1,217,939 | 2009-08-02T01:22:00.000 | 0 | 0 | 0 | 0 | python,fullscreen,pygame,pyopengl | 1,218,011 | 3 | false | 0 | 1 | If you are not changing your clock.tick() when you change between full screen and windowed mode this is almost certainly a vsync issue. If you are on an LCD then it's 100% certain.
Unfortunately v-sync can be handled in many places including SDL, Pyopengl, your display server and your video drivers. If you are using windows you can adjust the vsync toggle in the nvidia control panel to test, and there's more than likely something in nvidia-settings for linux as well. I'd guess other manufacturers drivers have similar settings but that's a guess. | 1 | 2 | 0 | I'm currently working on a game engine written in pygame and I wanted to add OpenGL support.
I wrote a test to see how to make pygame and OpenGL work together, and when it's running in windowed mode, it runs between 150 and 200 fps. When I run it full screen (all I did was add the FULLSCREEN flag when I set up the window), it drops down to 60 fps. I added a lot more drawing functions to see if it was just a huge performance drop, but it always ran at 60 fps.
Is there something extra I need to do to tell OpenGL that it's running fullscreen or is this a limitation of OpenGL?
(I am running in Windows XP) | PyOpenGL + Pygame capped to 60 FPS in Fullscreen | 0 | 0 | 0 | 3,949 |
1,218,891 | 2009-08-02T13:23:00.000 | 1 | 0 | 1 | 1 | python,macos,osx-leopard,zope | 1,219,303 | 4 | false | 0 | 0 | The approach I prefer which should work on every UNIX-like operating system:
Create for each application which need an specific python version an user account. Install in each user count the corresponding python version with an user-local prefix (like ~/build/python) and add ~/build/bin/ to the PATH environment variable of the user. Install/use your python applications in their correct user.
The advantage of this approach is the perfect isolation between the individual python installations and relatively convenient selection of the correct python environment (just su to the appropriate user). Also the operating system remains untouched. | 1 | 21 | 0 | I currently have multiple versions of Python installed on my Mac, the one that came with it, a version I downloaded recently from python.org, an older version used to run Zope locally and another version that Appengine is using. It's kind of a mess. Any recommendations of using one version of python to rule them all? How would I go about deleted older versions and linking all of my apps to a single install. Any Mac specific gotchas I should know about? Is this a dumb idea? | Multiple versions of Python on OS X Leopard | 0.049958 | 0 | 0 | 19,206 |
1,219,815 | 2009-08-02T20:49:00.000 | 3 | 0 | 1 | 0 | python,refactoring,module | 1,219,850 | 6 | false | 0 | 0 | Personally I find it easier to keep things like this in a single file, just for the practicality of editing a smaller number of files in my editor.
The important thing to do is treat the different pieces of code as though they were in separate files, so you ensure that you can trivially separate them later, for the reasons you cite. So for instance, don't introduce dependencies between the different pieces that will make it hard to disentangle them later. | 5 | 15 | 0 | I'm working on a Python web application in which I have some small modules that serve very specific functions: session.py, logger.py, database.py, etc. And by "small" I really do mean small; each of these files currently includes around 3-5 lines of code, or maybe up to 10 at most. I might have a few imports and a class definition or two in each. I'm wondering, is there any reason I should or shouldn't merge these into one module, something like misc.py?
My thoughts are that having separate modules helps with code clarity, and later on, if by some chance these modules grow to more than 10 lines, I won't feel so bad about having them separated. But on the other hand, it just seems like such a waste to have a bunch of files with only a few lines in each! And is there any significant difference in resource usage between the multi-file vs. single-file approach? (Of course I'm nowhere near the point where I should be worrying about resource usage, but I couldn't resist asking...)
I checked around to see whether this had been asked before and didn't see anything specific to Python, but if it's in fact a duplicate, I'd appreciate being pointed in the right direction. | Python: prefer several small modules or one larger module? | 0.099668 | 0 | 0 | 2,930 |
1,219,815 | 2009-08-02T20:49:00.000 | -2 | 0 | 1 | 0 | python,refactoring,module | 1,219,914 | 6 | false | 0 | 0 | Small. | 5 | 15 | 0 | I'm working on a Python web application in which I have some small modules that serve very specific functions: session.py, logger.py, database.py, etc. And by "small" I really do mean small; each of these files currently includes around 3-5 lines of code, or maybe up to 10 at most. I might have a few imports and a class definition or two in each. I'm wondering, is there any reason I should or shouldn't merge these into one module, something like misc.py?
My thoughts are that having separate modules helps with code clarity, and later on, if by some chance these modules grow to more than 10 lines, I won't feel so bad about having them separated. But on the other hand, it just seems like such a waste to have a bunch of files with only a few lines in each! And is there any significant difference in resource usage between the multi-file vs. single-file approach? (Of course I'm nowhere near the point where I should be worrying about resource usage, but I couldn't resist asking...)
I checked around to see whether this had been asked before and didn't see anything specific to Python, but if it's in fact a duplicate, I'd appreciate being pointed in the right direction. | Python: prefer several small modules or one larger module? | -0.066568 | 0 | 0 | 2,930 |
1,219,815 | 2009-08-02T20:49:00.000 | 3 | 0 | 1 | 0 | python,refactoring,module | 1,220,447 | 6 | false | 0 | 0 | For command line scripts there most likely will not be much difference unless each invocation invokes all files in the module, in which case there will be a slight performance cost as n files need to be opened vs one.
For mod_python there most likely will be no difference as byte-compiled modules stay alive for the duration of the apache process.
For google app engine though there will be a performance hit unless the service is constantly used and is "hot" as each cold start would require opening all files. | 5 | 15 | 0 | I'm working on a Python web application in which I have some small modules that serve very specific functions: session.py, logger.py, database.py, etc. And by "small" I really do mean small; each of these files currently includes around 3-5 lines of code, or maybe up to 10 at most. I might have a few imports and a class definition or two in each. I'm wondering, is there any reason I should or shouldn't merge these into one module, something like misc.py?
My thoughts are that having separate modules helps with code clarity, and later on, if by some chance these modules grow to more than 10 lines, I won't feel so bad about having them separated. But on the other hand, it just seems like such a waste to have a bunch of files with only a few lines in each! And is there any significant difference in resource usage between the multi-file vs. single-file approach? (Of course I'm nowhere near the point where I should be worrying about resource usage, but I couldn't resist asking...)
I checked around to see whether this had been asked before and didn't see anything specific to Python, but if it's in fact a duplicate, I'd appreciate being pointed in the right direction. | Python: prefer several small modules or one larger module? | 0.099668 | 0 | 0 | 2,930 |
1,219,815 | 2009-08-02T20:49:00.000 | 8 | 0 | 1 | 0 | python,refactoring,module | 1,219,844 | 6 | true | 0 | 0 | My thoughts are that having separate
modules helps with code clarity, and
later on, if by some chance these
modules grow to more than 10 lines, I
won't feel so bad about having them
separated.
This. Keep it the way you have it. | 5 | 15 | 0 | I'm working on a Python web application in which I have some small modules that serve very specific functions: session.py, logger.py, database.py, etc. And by "small" I really do mean small; each of these files currently includes around 3-5 lines of code, or maybe up to 10 at most. I might have a few imports and a class definition or two in each. I'm wondering, is there any reason I should or shouldn't merge these into one module, something like misc.py?
My thoughts are that having separate modules helps with code clarity, and later on, if by some chance these modules grow to more than 10 lines, I won't feel so bad about having them separated. But on the other hand, it just seems like such a waste to have a bunch of files with only a few lines in each! And is there any significant difference in resource usage between the multi-file vs. single-file approach? (Of course I'm nowhere near the point where I should be worrying about resource usage, but I couldn't resist asking...)
I checked around to see whether this had been asked before and didn't see anything specific to Python, but if it's in fact a duplicate, I'd appreciate being pointed in the right direction. | Python: prefer several small modules or one larger module? | 1.2 | 0 | 0 | 2,930 |
1,219,815 | 2009-08-02T20:49:00.000 | 2 | 0 | 1 | 0 | python,refactoring,module | 1,219,867 | 6 | false | 0 | 0 | Off course you can have as many modules as you like.
But now let as think a little, what happens when we put every small code snippet into one single file.
We will end up in hundreds of import statements in any less trivial module. And off course you could also save a little by having all explicit in seperated files. But guess what: Nobody can remember so many module names and you might end up in searching for the right file anyway ...
I try to put things that belong together in one single file (unless it becomes to big!). But when I have small functions or classes that do not belong to other components in my system, I have "util" modules or the like. I also try to group these for example according to my application layering or seperate them by other means. One seperation criteria could be: Utilities that are used for UI and those that are not. | 5 | 15 | 0 | I'm working on a Python web application in which I have some small modules that serve very specific functions: session.py, logger.py, database.py, etc. And by "small" I really do mean small; each of these files currently includes around 3-5 lines of code, or maybe up to 10 at most. I might have a few imports and a class definition or two in each. I'm wondering, is there any reason I should or shouldn't merge these into one module, something like misc.py?
My thoughts are that having separate modules helps with code clarity, and later on, if by some chance these modules grow to more than 10 lines, I won't feel so bad about having them separated. But on the other hand, it just seems like such a waste to have a bunch of files with only a few lines in each! And is there any significant difference in resource usage between the multi-file vs. single-file approach? (Of course I'm nowhere near the point where I should be worrying about resource usage, but I couldn't resist asking...)
I checked around to see whether this had been asked before and didn't see anything specific to Python, but if it's in fact a duplicate, I'd appreciate being pointed in the right direction. | Python: prefer several small modules or one larger module? | 0.066568 | 0 | 0 | 2,930 |
1,220,465 | 2009-08-03T02:24:00.000 | 1 | 0 | 1 | 0 | python,debugging | 1,221,572 | 6 | false | 0 | 0 | "Basically I want to see what is going on, but be able to jump in if a traceback occurs."
Here's a radical thought: Don't.
"Watching" is a crutch. You should be writing small sections of code that you know will work. Then put those together.
Watching sometimes results from "I'm not sure what Python's really doing", so there's an urge to "watch" execution and see what's happening. Other times watching results from writing a script that's too big and complex without proper decomposition. Sometimes watching results from having a detailed specification which was translated into Python without a deep understanding. I've seen people doing these; of course, there are lots more reasons.
The advice, however, is the same for all:
Break things into small pieces,
usually classes of functions. Make
them simple enough that you can
actually understand what Python is
doing.
Knit them together to create your
larger application from pieces you
actually understand.
Watching will limit your ability to actually write working software. It will -- in a very real way -- limit you to trivial programming exercises. It's not a good learning tool; and it's a perfectly awful way to create production code.
Bottom Line.
Don't pursue "watching". Decompose into smaller pieces so you don't need to watch. | 1 | 1 | 0 | I'm looking for a debugging tool that will run my Python app, but display which line is currently being processed -- like an automatically stepping debugger. Basically I want to see what is going on, but be able to jump in if a traceback occurs. | "Watching" program being processed line-by-line? | 0.033321 | 0 | 0 | 215 |
1,222,147 | 2009-08-03T12:42:00.000 | 1 | 0 | 0 | 0 | python,convolution | 1,226,509 | 2 | true | 0 | 0 | Yes, SciPy/Numpy is mostly concerned about arrays.
If you can tolerate an approximate solution, and your functions only operate over a range of value (not infinite) you can fill an array with the values and convolve the arrays.
If you want something more "correct" calculus-wise you would probably need a powerful solver (mathmatica, maple...) | 1 | 2 | 1 | I will have to implement a convolution of two functions in Python, but SciPy/Numpy appear to have functions only for the convolution of two arrays.
Before I try to implement this by using the the regular integration expression of convolution, I would like to ask if someone knows of an already available module that performs these operations.
Failing that, which of the several kinds of integration that SciPy provides is the best suited for this?
Thanks! | Convolution of two functions in Python | 1.2 | 0 | 0 | 8,768 |
1,222,782 | 2009-08-03T14:52:00.000 | 2 | 0 | 1 | 0 | python,python-3.x | 1,222,924 | 8 | false | 0 | 0 | Python 3.1 should not be used until other libraries have caught up with support for it.
You should use 2.6 now. It has several 3.x features back-ported to it, so that migrating to 3.x won't be difficult later on, and you won't learn obsolete practices. | 7 | 12 | 0 | Recently I decided to expand my programming horizons and learn the python programming language. While I have used python a little bit for classes in college and for a project or two at work I am by no means an expert. My question is as follows: should I bother with the 2.x releases or should I jump straight to 3.0? I am leaning towards 3.0 since I will be programming applications more for personal/learning use, but I wanted to see if there were any good arguments against it before I began. | Should I Start With Python 3.0? | 0.049958 | 0 | 0 | 2,297 |
1,222,782 | 2009-08-03T14:52:00.000 | 2 | 0 | 1 | 0 | python,python-3.x | 1,222,832 | 8 | false | 0 | 0 | Use python 3.1, Luke. | 7 | 12 | 0 | Recently I decided to expand my programming horizons and learn the python programming language. While I have used python a little bit for classes in college and for a project or two at work I am by no means an expert. My question is as follows: should I bother with the 2.x releases or should I jump straight to 3.0? I am leaning towards 3.0 since I will be programming applications more for personal/learning use, but I wanted to see if there were any good arguments against it before I began. | Should I Start With Python 3.0? | 0.049958 | 0 | 0 | 2,297 |
1,222,782 | 2009-08-03T14:52:00.000 | 4 | 0 | 1 | 0 | python,python-3.x | 1,222,804 | 8 | false | 0 | 0 | I think that you will be better served going straight into 3.0. Unless you have a legacy codebase to contend with, there are very few advantages to learning the 2.xx ways of doing things.
In the Python world (as in most others, really), releases do tend to take a while to migrate down to all of the subprojects, but if you ever find the need to transition back to 2.xx, I don't think you'll find relearning things to be particularly painful. | 7 | 12 | 0 | Recently I decided to expand my programming horizons and learn the python programming language. While I have used python a little bit for classes in college and for a project or two at work I am by no means an expert. My question is as follows: should I bother with the 2.x releases or should I jump straight to 3.0? I am leaning towards 3.0 since I will be programming applications more for personal/learning use, but I wanted to see if there were any good arguments against it before I began. | Should I Start With Python 3.0? | 0.099668 | 0 | 0 | 2,297 |
1,222,782 | 2009-08-03T14:52:00.000 | 8 | 0 | 1 | 0 | python,python-3.x | 1,540,468 | 8 | false | 0 | 0 | Use 3.1
Why?
1) Because as long as everyone is still using 2.6, the libraries will have less reasons to migrate to 3.1. As long as those libraries are not ported to 3.1, you are stuck with the choice of either not using the strengths of 3.1, or only doing the jobs half way by using the hackish solution of using a back-ported feature set. Be a forward thinker and help push Python forward.
2) If you learn and use 3.1 now, you wont have to relearn it later when the mass port is complete. I know some people say you wont have to learn much, but why learn the old crap at all? Python itself is moving towards 3.1, the libraries will move toward 3.1, and it sucks to have to play catch-up and relearn a language you are already using.
3) 3.1 is all around a better language, more stable and more consistent than 2.6... this is normal. The lessons learned from 2.6 were all poured into 3.1 to make it better. It is a process called PROGRESS. This is why nobody still uses Windows 3.1. It is the way things move FORWARD. Why else do you think they went to the trouble of back porting a feature set in the first place?
4) If you are learning Python, and learn 2.6, then by the time you are really comfortable with the language, the ports will be out, and you will have to learn the libraries, and the language all over again. If you start with 3.1, then by the time you are comfortable with the language, the ports will be out, and then you can learn the libraries that you are interested in. It is a smoother process.
5) To be a better developer. If you have to learn and relearn the same things, your understanding will not be very deep. By learning this language, and its libraries only once, you will have more time to work with them rather than relearning syntax. This allows you to understand them better. If you are really missing some pieces by forgoing on the libraries? WRITE THEM. You will probably not need an entire library, and can usually write only those pieces that you need, and develop tools for yourself. This, again, helps you understand the language better, and more deeply. | 7 | 12 | 0 | Recently I decided to expand my programming horizons and learn the python programming language. While I have used python a little bit for classes in college and for a project or two at work I am by no means an expert. My question is as follows: should I bother with the 2.x releases or should I jump straight to 3.0? I am leaning towards 3.0 since I will be programming applications more for personal/learning use, but I wanted to see if there were any good arguments against it before I began. | Should I Start With Python 3.0? | 1 | 0 | 0 | 2,297 |
1,222,782 | 2009-08-03T14:52:00.000 | 7 | 0 | 1 | 0 | python,python-3.x | 1,225,173 | 8 | false | 0 | 0 | Short answer: Start with Python 2.6.
Why: Programming is more fun and useful when you can leverage the work of others. This means using 3rd party libraries often. Many of the popular libraries for Python don't have 3.x support yet. PIL and NumPy/SciPy come to mind. My favorite interpreter, ipython, also doesn't work with 3.0 yet. Many unit testing frameworks and web frameworks are also not on 3.0 yet.
So if you start out in 3.x many doors will be closed to you, at least until 3.x porting takes on steam. There are admittedly a lot of nice features in Python 3.x, but some of them have been backported to 2.6 and some more will make it into 2.7. So stick with 2.6 for now, and re-evaluate 3.x in a year's time or so. | 7 | 12 | 0 | Recently I decided to expand my programming horizons and learn the python programming language. While I have used python a little bit for classes in college and for a project or two at work I am by no means an expert. My question is as follows: should I bother with the 2.x releases or should I jump straight to 3.0? I am leaning towards 3.0 since I will be programming applications more for personal/learning use, but I wanted to see if there were any good arguments against it before I began. | Should I Start With Python 3.0? | 1 | 0 | 0 | 2,297 |
1,222,782 | 2009-08-03T14:52:00.000 | 20 | 0 | 1 | 0 | python,python-3.x | 1,222,843 | 8 | true | 0 | 0 | Absolutely not 3.0 - 3.1 is out and is stabler, better, faster in every respect; it makes absolutely no sense to start with 3.0 at this time, if you want to take up the 3 series it should on all accounts be 3.1.
As for 2.6 vs 3.1, 3.1 is a better language (especially because some cruft was removed that had accumulated over the years but has to stay in 2.* for backwards compatibility) but all the rest of the ecosystem (from extensions to tools, from books to collective knowledge) is still very much in favor of 2.6 -- if you don't care about being able to use (e.g.) certain GUIs or scientific extensions, deploy on App Engine, script Windows with COM, have a spiffy third party IDE, and so on, 3.1 is advisable, but if you care about such things, still 2.* for now. | 7 | 12 | 0 | Recently I decided to expand my programming horizons and learn the python programming language. While I have used python a little bit for classes in college and for a project or two at work I am by no means an expert. My question is as follows: should I bother with the 2.x releases or should I jump straight to 3.0? I am leaning towards 3.0 since I will be programming applications more for personal/learning use, but I wanted to see if there were any good arguments against it before I began. | Should I Start With Python 3.0? | 1.2 | 0 | 0 | 2,297 |
1,222,782 | 2009-08-03T14:52:00.000 | 3 | 0 | 1 | 0 | python,python-3.x | 1,222,856 | 8 | false | 0 | 0 | You should go with the latest release of any programming language you learn unless you have a specific reason not to. Since you don't have an existing project that won't work with Python 3.0, you should feel free to use the newest version. | 7 | 12 | 0 | Recently I decided to expand my programming horizons and learn the python programming language. While I have used python a little bit for classes in college and for a project or two at work I am by no means an expert. My question is as follows: should I bother with the 2.x releases or should I jump straight to 3.0? I am leaning towards 3.0 since I will be programming applications more for personal/learning use, but I wanted to see if there were any good arguments against it before I began. | Should I Start With Python 3.0? | 0.07486 | 0 | 0 | 2,297 |
1,222,929 | 2009-08-03T15:18:00.000 | 4 | 0 | 1 | 0 | python,multithreading,gil | 1,224,503 | 7 | false | 0 | 0 | The GIL is a good thing.
Just make your C++ application release the GIL while it is doing its multithreaded work. Python code will continue to run in the other threads, unspoiled. Only acquire the GIL when you have to touch python objects. | 2 | 16 | 0 | Does anybody knows fate of Global Interpreter Lock in Python 3.1 against C++ multithreading integration | GIL in Python 3.1 | 0.113791 | 0 | 0 | 13,312 |
1,222,929 | 2009-08-03T15:18:00.000 | 9 | 0 | 1 | 0 | python,multithreading,gil | 1,225,350 | 7 | false | 0 | 0 | The GIL will not affect your code which does not use python objects. In Numpy, we release the GIL for computational code (linear algebra calls, etc...), and the underlying code can use multithreading freely (in fact, those are generally 3rd party libraries which do not know anything about python) | 2 | 16 | 0 | Does anybody knows fate of Global Interpreter Lock in Python 3.1 against C++ multithreading integration | GIL in Python 3.1 | 1 | 0 | 0 | 13,312 |
1,223,007 | 2009-08-03T15:33:00.000 | 0 | 1 | 1 | 0 | python,string,partitioning | 1,223,236 | 5 | false | 0 | 0 | You should look into the itertools module. It can create a generator for you that is very fast. Given your input string, it will provide you with all possible permutations. Depending on what you need, there is also a combinations() generator. I'm not quite sure if you're looking at "b|ca" when you're looking at "abc," but either way, this module may prove useful to you. | 1 | 3 | 0 | I'm working on a statistical project that involves iterating over every possible way to partition a collection of strings and running a simple calculation on each. Specifically, each possible substring has a probability associated with it, and I'm trying to get the sum across all partitions of the product of the substring probability in the partition.
For example, if the string is 'abc', then there would be probabilities for 'a', 'b', 'c', 'ab, 'bc' and 'abc'. There are four possible partitionings of the string: 'abc', 'ab|c', 'a|bc' and 'a|b|c'. The algorithm needs to find the product of the component probabilities for each partitioning, then sum the four resultant numbers.
Currently, I've written a python iterator that uses binary representations of integers for the partitions (eg 00, 01, 10, 11 for the example above) and simply runs through the integers. Unfortunately, this is immensely slow for strings longer than 20 or so characters.
Can anybody think of a clever way to perform this operation without simply running through every partition one at a time? I've been stuck on this for days now.
In response to some comments here is some more information:
The string can be just about anything, eg "foobar(foo2)" -- our alphabet is lowercase alphanumeric plus all three type of braces ("(","[","{"), hyphens and spaces.
The goal is to get the likelihood of the string given individual 'word' likelihoods. So L(S='abc')=P('abc') + P('ab')P('c') + P('a')P('bc') + P('a')P('b')P('c') (Here "P('abc')" indicates the probability of the 'word' 'abc', while "L(S='abc')" is the statistical likelihood of observing the string 'abc'). | Are there any cleverly efficient algorithms to perform a calculation over the space of partitionings of a string? | 0 | 0 | 0 | 323 |
1,223,289 | 2009-08-03T16:30:00.000 | 8 | 0 | 1 | 1 | python | 1,223,313 | 2 | false | 0 | 0 | How about os.write(<file descriptor>, os.linesep)? (import os is unnecessary because you seem to have already imported it, otherwise you'd be getting errors using os.write to begin with.) | 1 | 43 | 0 | The os.write function can be used to writes bytes into a file descriptor (not file object). If I execute os.write(fd, '\n'), only the LF character will be written into the file, even on Windows. I would like to have CRLF in the file on Windows and only LF in Linux.
What is the best way to achieve this?
I'm using Python 2.6, but I'm also wondering if Python 3 has a different solution. | How to write native newline character to a file descriptor in Python? | 1 | 0 | 0 | 36,433 |
1,224,567 | 2009-08-03T20:52:00.000 | 1 | 0 | 1 | 0 | python,windows,xml,ide,wxpython | 1,224,958 | 7 | false | 0 | 0 | Taking the headline question literally, the answer has to be IronPython. The 2.0 releases are equivalent to CPython 2.5, and the 2.6 release (currently at beta2) is intended to match CPython 2.6 (full 2.6 release some time in the next couple of months). With either you can use the state of the art in Windows GUI frameworks, i.e. WPF; and you get the whole .net XML support libraries (excepting Linq to XML, which relies on clever bits of C# that IronPython cannot yet emulate).
I've used NetBeans Python plug-in happily as an IDE for IronPython using WPF. | 2 | 1 | 0 | I'm looking to set up my development environment at home for writing Windows applications in Python.
For my first piece, I'm writing a simple, forms-based application that stores data input as XML (and can read that information back.) I do want to set up the tools I'd use professionally, though, having already done a round of didactic programming.
What tools are professional python developers using these days? In order to have a working python environment, what version of the compiler should I be using? What editor is common for professionals? What libraries are considered a must-have for every serious python developer?
Specifically, which Windowing and XML libraries are de rigeur for working in Windows? | What's the state-of-the-art in Python programming in Windows? | 0.028564 | 0 | 0 | 1,473 |
1,224,567 | 2009-08-03T20:52:00.000 | 1 | 0 | 1 | 0 | python,windows,xml,ide,wxpython | 1,224,727 | 7 | false | 0 | 0 | "What tools are professional python developers using these days?"
Lots
"In order to have a working python environment, what version of the compiler should I be using?"
["compiler" is meaningless. I'll assume you mean "Python"]
We use 2.5.4. We'll be upgrading to 2.6 as soon as we've done the testing.
"What editor is common for professionals?"
We use Komodo Edit.
"What libraries are considered a must-have for every serious python developer?"
We use Django, XLRD, PIL, and a few others. We don't plan this kind of thing in advance. As our requirements arrive, we start looking for libraries. We don't "pre-load" a bunch of "must-have" libraries. The very idea is silly. We load what we need to solve the problems we have. | 2 | 1 | 0 | I'm looking to set up my development environment at home for writing Windows applications in Python.
For my first piece, I'm writing a simple, forms-based application that stores data input as XML (and can read that information back.) I do want to set up the tools I'd use professionally, though, having already done a round of didactic programming.
What tools are professional python developers using these days? In order to have a working python environment, what version of the compiler should I be using? What editor is common for professionals? What libraries are considered a must-have for every serious python developer?
Specifically, which Windowing and XML libraries are de rigeur for working in Windows? | What's the state-of-the-art in Python programming in Windows? | 0.028564 | 0 | 0 | 1,473 |
1,224,726 | 2009-08-03T21:30:00.000 | 5 | 0 | 0 | 1 | python,linux,cygwin,debhelper | 1,250,118 | 1 | true | 0 | 0 | Both cdbs and debhelper are only needed if you are trying to build a debian package. Just do a regular python setup.py build, and it should work fine (assuming you have the other prerequisites available). | 1 | 0 | 0 | python purple says it needs dbms and debhelper in order to run, but I don't run debian. Is there a way to get this running on a different linux? or in cygwin? | is it possible to get python purple running either in cygwin or on a linux that isn't debian? | 1.2 | 0 | 0 | 266 |
1,224,910 | 2009-08-03T22:20:00.000 | 3 | 0 | 0 | 0 | python,urllib2 | 1,224,950 | 1 | false | 0 | 0 | urllib2.urlopen returns a file-like object, and you can (at least in theory) .read(N) from such an object to limit the amount of data returned to N bytes at most.
This approach is not entirely fool-proof, because an actively-hostile site may go to quite some lengths to fool a reasonably trusty received, like urllib2's default opener; in this case, you'll need to implement and install your own opener that knows how to guard itself against such attacks (for example, getting no more than a MB at a time from the open socket, etc, etc). | 1 | 3 | 0 | Is there a way to limit amount of data downloaded by python's urllib2 module ? Sometimes I encounter with broken sites with sort of /dev/random as a page and it turns out that they use up all memory on a server. | limit downloaded page size | 0.53705 | 0 | 1 | 869 |
1,225,686 | 2009-08-04T04:03:00.000 | 0 | 0 | 0 | 0 | python,dialog,webpage | 1,226,061 | 3 | false | 0 | 0 | You can't, and you don't want to. When you ask a question, try explaining what you are trying to achieve, and not just the task immediately before you. You are likely barking down the wrong path. There is some other way of doing what you are trying to do. | 1 | 0 | 0 | When I try to automatically download a file from some webpage using Python,
I get Webpage Dialog window (I use IE). The window has two buttons, such as 'Continue' and 'Cancel'. I cannot figure out how to click on the Continue Button. The problem is
that I don't know how to control Webpage Dialog with Python. I tried to use
winGuiAuto to find the controls of the window, but it fails to recognize any Button type
controls... An ideas?
Sasha
A clarification of my question:
My purpose is to download stock data from a certain web site. I need to perform it for many stocks so I need python to do it for me in a repetitive way. This specific site exports the data by letting me download it in Excel file by clicking a link. However after clicking the link I get a Web Page dialog box asking me if I am sure that I want to download this file. This Web page dialog is my problem - it is not an html page and it is not a regular windows dialog box. It is something else and I cannot configure how to control it with python. It has two buttons and I need to click on one of them (i.e. Continue). It seems like it is a special kind of window implemented in IE. It is distinguished by its title which looks like this: Webpage Dialog -- Download blalblabla. If I click Continue mannually it opens a regular windows dialog box (open,save,cancel) which i know how to handle with winGuiAuto library. Tried to use this library for the Webpage Dialog window with no luck. Tried to recognize the buttons with Autoit Info tool -no luck either. In fact, maybe these are not buttons, but actually links, however I cannot see the links and there is no source code visible... What I need is someone to tell me what this Web page Dialog box is and how to control it with Python. That was my question. | How to control Webpage dialog with python | 0 | 0 | 1 | 2,761 |
1,226,091 | 2009-08-04T07:25:00.000 | 1 | 0 | 1 | 0 | python,multithreading | 1,226,101 | 4 | false | 0 | 0 | Use synchronization objects and ask the thread to terminate. Basically, write co-operative handling of this.
If you start yanking out the thread beneath the python interpreter, all sorts of odd things can occur, and it's not just in Python either, most runtimes have this problem.
For instance, let's say you kill a thread after it has opened a file, there's no way that file will be closed until the application terminates. | 1 | 5 | 0 | What is the recommended way to terminate unexpectedly long running threads in python ? I can't use SIGALRM, since
Some care must be taken if both
signals and threads are used in the
same program. The fundamental thing to
remember in using signals and threads
simultaneously is: always perform
signal() operations in the main thread
of execution. Any thread can perform
an alarm(), getsignal(), pause(),
setitimer() or getitimer(); only the
main thread can set a new signal
handler, and the main thread will be
the only one to receive signals
(this is enforced by the Python signal
module, even if the underlying thread
implementation supports sending
signals to individual threads). This
means that signals can’t be used as a
means of inter-thread
communication.Use locks instead.
Update: each thread in my case blocks -- it is downloading a web page using urllib2 module and sometimes operation takes too many time on an extremely slow sites. That's why I want to terminate such slow threads | Terminate long running python threads | 0.049958 | 0 | 0 | 6,170 |
1,226,584 | 2009-08-04T09:47:00.000 | 0 | 0 | 1 | 0 | python,multithreading,multiprocess | 1,227,628 | 8 | false | 0 | 0 | If you can easily partition and separate the data you have, it sounds like you should just do that partitioning externally, and feed them to several processes of your program. (i.e. several processes instead of threads) | 2 | 32 | 0 | I have a python application that grabs a collection of data and for each piece of data in that collection it performs a task. The task takes some time to complete as there is a delay involved. Because of this delay, I don't want each piece of data to perform the task subsequently, I want them to all happen in parallel. Should I be using multiprocess? or threading for this operation?
I attempted to use threading but had some trouble, often some of the tasks would never actually fire. | multiprocess or threading in python? | 0 | 0 | 0 | 18,548 |
1,226,584 | 2009-08-04T09:47:00.000 | 0 | 0 | 1 | 0 | python,multithreading,multiprocess | 1,252,808 | 8 | false | 0 | 0 | IronPython has real multithreading, unlike CPython and it's GIL. So depending on what you're doing it may be worth looking at. But it sounds like your use case is better suited to the multiprocessing module.
To the guy who recommends stackless python, I'm not an expert on it, but it seems to me that he's talking about software "multithreading", which is actually not parallel at all (still runs in one physical thread, so cannot scale to multiple cores.) It's merely an alternative way to structure asynchronous (but still single-threaded, non-parallel) application. | 2 | 32 | 0 | I have a python application that grabs a collection of data and for each piece of data in that collection it performs a task. The task takes some time to complete as there is a delay involved. Because of this delay, I don't want each piece of data to perform the task subsequently, I want them to all happen in parallel. Should I be using multiprocess? or threading for this operation?
I attempted to use threading but had some trouble, often some of the tasks would never actually fire. | multiprocess or threading in python? | 0 | 0 | 0 | 18,548 |
1,227,031 | 2009-08-04T11:48:00.000 | 0 | 1 | 0 | 0 | python,c,configuration-management | 1,227,256 | 4 | false | 0 | 0 | Despite being hated by techies and disowned by Microsoft, INI files are actually quite popular with users, as they are easy to understand and edit. They are also very simple to write parsers for, should your libraries not already support them. | 1 | 5 | 0 | I am looking for a good config file library for c that is not xml. Optimally I would really like one that also has python bindings. The best option I have come up with is to use a JSON library in both c and python. What would you recommend, or what method of reading/writing configuration settings do you prefer? | What is a good configuration file library for c thats not xml (preferably has python bindings)? | 0 | 0 | 0 | 1,054 |
1,229,068 | 2009-08-04T18:10:00.000 | 1 | 0 | 1 | 0 | python,dictionary,persistence,object-persistence | 1,229,114 | 8 | false | 0 | 0 | Assuming the keys and values have working implementations of repr, one solution is that you save the string representation of the dictionary (repr(dict)) to file. YOu can load it using the eval function (eval(inputstring)). There are two main disadvantages of this technique:
1) Is will not work with types that have an unuseable implementation of repr (or may even seem to work, but fail). You'll need to pay at least some attention to what is going on.
2) Your file-load mechanism is basically straight-out executing Python code. Not great for security unless you fully control the input.
It has 1 advantage: Absurdly easy to do. | 3 | 14 | 0 | So, I want to store a dictionary in a persistent file. Is there a way to use regular dictionary methods to add, print, or delete entries from the dictionary in that file?
It seems that I would be able to use cPickle to store the dictionary and load it, but I'm not sure where to take it from there. | With Python, can I keep a persistent dictionary and modify it? | 0.024995 | 0 | 0 | 10,869 |
1,229,068 | 2009-08-04T18:10:00.000 | 6 | 0 | 1 | 0 | python,dictionary,persistence,object-persistence | 1,229,084 | 8 | false | 0 | 0 | Unpickle from file when program loads, modify as a normal dictionary in memory while program is running, pickle to file when program exits? Not sure exactly what more you're asking for here. | 3 | 14 | 0 | So, I want to store a dictionary in a persistent file. Is there a way to use regular dictionary methods to add, print, or delete entries from the dictionary in that file?
It seems that I would be able to use cPickle to store the dictionary and load it, but I'm not sure where to take it from there. | With Python, can I keep a persistent dictionary and modify it? | 1 | 0 | 0 | 10,869 |
1,229,068 | 2009-08-04T18:10:00.000 | 0 | 0 | 1 | 0 | python,dictionary,persistence,object-persistence | 1,229,320 | 8 | false | 0 | 0 | pickling has one disadvantage. it can be expensive if your dictionary has to be read and written frequently from disk and it's large. pickle dumps the stuff down (whole). unpickle gets the stuff up (as a whole).
if you have to handle small dicts, pickle is ok. If you are going to work with something more complex, go for berkelydb. It is basically made to store key:value pairs. | 3 | 14 | 0 | So, I want to store a dictionary in a persistent file. Is there a way to use regular dictionary methods to add, print, or delete entries from the dictionary in that file?
It seems that I would be able to use cPickle to store the dictionary and load it, but I'm not sure where to take it from there. | With Python, can I keep a persistent dictionary and modify it? | 0 | 0 | 0 | 10,869 |
1,229,933 | 2009-08-04T21:04:00.000 | 6 | 0 | 0 | 0 | python,layout,gtk,pygtk | 1,229,981 | 1 | true | 0 | 1 | You should use GtkSizeGroup for this. Create a GtkSizeGroup, add both widgets to it. This will ensure that both widgets have the same size. If you want that widget have the same size in only one direction (width or height), set the "mode" property of SizeGroup. | 1 | 1 | 0 | I'm using pyGTK. I want to layout a large element with 2 smaller ones on each side. For aesthetic reasons, I want the 2 smaller ones to be the same size. As it is, they differ by a few pixels, and the middle element is not centered as a result.
I tried using gtk.Table with 3 cells, but having homogeneous=True doesn't have the desired effect. I tried messing with it by making 8 cells, and then having the center one take up more cells, but it doesn't work well. Is there any way to do this? | How to make two elements in gtk have the same size? | 1.2 | 0 | 0 | 238 |
1,230,089 | 2009-08-04T21:47:00.000 | 5 | 0 | 0 | 0 | python,django | 1,242,238 | 9 | false | 1 | 0 | The single greatest thing you can do to make your life with Django better is -Learn Python-
I have watched people inundate the mailing lists and IRC with problems directly related to their lack of language knowledge. I am not even talking about hard concepts, but rather things like this example interaction:
User: How do I display all the things in a query
Developer: It's an iterable list. You do it the same way you would with any list
User: Uh, I'm new to python how do I do that.
That is an example of what you don't want to be asking when you try to get django help. | 2 | 16 | 0 | First question:
What is your favorite Django book or online learning material? CodeProject examples + Django documentation, O'Reilly, etc.
Second Question: What are some good tips and advice you have picked up along the way which helps you to use Django more effectively? Certain design patterns, language idioms, frameworks which tie into Django well, etc.
Thanks! | Two parter: Django book recommendation + Django real world advice | 0.110656 | 0 | 0 | 3,014 |
1,230,089 | 2009-08-04T21:47:00.000 | 1 | 0 | 0 | 0 | python,django | 1,242,465 | 9 | false | 1 | 0 | I Just finished the Practical Django Projects (for version 1.1)as mentioned in piquadrat, Travis' and Alasdairs' answers. I had a lot of aha moments and many more I'll need to get back to that again to fully digest moments.
When James Bennet, the author gets the code samples into the Mercurial repository on BitBucket it will improve my overall rating of the book since you will presumably be able to test the code as it progresses through the book (only the first three chapters' code is up there at the moment). The last sections of the book on development methods are in particular very helpful.
If you decide to buy the book, it's a good excuse to learn the basics of revision control with Mercurial.
I believe in picking up operating projects and working them though, helps me learn better and also seeing good practices. A new pretty comprehensive blog engine is Mingus on bit bucket, worth a look, still early stage, but is teaching me a lot, there are others take your pick. | 2 | 16 | 0 | First question:
What is your favorite Django book or online learning material? CodeProject examples + Django documentation, O'Reilly, etc.
Second Question: What are some good tips and advice you have picked up along the way which helps you to use Django more effectively? Certain design patterns, language idioms, frameworks which tie into Django well, etc.
Thanks! | Two parter: Django book recommendation + Django real world advice | 0.022219 | 0 | 0 | 3,014 |
1,230,392 | 2009-08-04T23:17:00.000 | 0 | 0 | 0 | 0 | python,django | 1,230,419 | 2 | false | 1 | 0 | you can just write a middleware that does exactly that, no need to repeat logging code on every view function. | 1 | 0 | 0 | I was hoping that Django had a built in way of getting the last url that was visited in the app itself. As I write this I realize that there are some complications in doing something like that (excluding pages that redirect, for example) but i thought I'd give it a shot.
if there isn't a built-in for this, what strategy would you use? I mean other than just storing a url in the session manually and referring to that when redirecting. That would work, of course, but I hate the thought of having to remember to do that for each view. Seems error-prone and not very elegant.
Oh, and I'd rather not depend on server specific referral environment variables. | Does Django have a built in way of getting the last app url the current user visited? | 0 | 0 | 0 | 747 |
1,230,479 | 2009-08-04T23:45:00.000 | 1 | 0 | 1 | 0 | python,py2exe,msvcr90.dll | 1,230,912 | 2 | true | 0 | 0 | Vista 64bit has a 32 bit emulator I believe, so you will not need to worry about this.
However, I would just tell them to install the msvcrt runtime which is supposed to be the correct way to deal with this sxs mess. | 1 | 0 | 0 | I was working on an update to my application and before I began I migrated to 2.62 because it seemed to be the time to. I walked right into the issue of having problems building my application using py2exe because of the MSVCR90.dlls. There seems to be a fair amount of information on how to solve this issue, including some good answers here on SO.
I am deploying to users that more likely than not have 32 bit XP or Vista machines. Some of my users will be migrated to 64 bit Vista in the near future. My understanding of these issues is that I have to make sure they have the correct dlls that relate to the version of python that exists on the application development computer. Since I have an x86 processor then they need the x86 version of the dlls. The configuration of their computer is irrelevant.
Is this correct or do I have to account for their architecture if I am going to deliver the dlls as private assemblies?
Thanks for any responses | Do I only need to check the users machine for the version of the MSVCR90.dll that was installed with my python installation? | 1.2 | 0 | 0 | 314 |
1,231,397 | 2009-08-05T05:47:00.000 | 3 | 0 | 1 | 0 | python,ide | 1,231,658 | 9 | false | 0 | 0 | Under Unix, Emacs is a good choice, to which I always come back, because it is convenient to have a single editor for everything, and because it's open source.
What is best for you depends on your past experience with IDEs. I'd say: stick with what you've been using, or take this opportunity to try an even better IDE.
Note: Python comes with Idle, which is a very simple (if limited) IDE. | 1 | 1 | 0 | I'm a complete newbie to Python. I've worked on PHP/JavaScript earlier but starting today I'm moving onto Python. I have no idea about the environment needed for it. I could use some suggestions on it for me to get started. | New to Python. Need info on the environment for it | 0.066568 | 0 | 0 | 297 |
1,231,688 | 2009-08-05T07:33:00.000 | 7 | 0 | 1 | 0 | python,packages,setuptools,easy-install | 4,320,437 | 13 | false | 0 | 0 | To list installed Python packages, you can use yolk -l. You'll need to use easy_install yolk first though. | 4 | 713 | 0 | Python's easy_install makes installing new packages extremely convenient. However, as far as I can tell, it doesn't implement the other common features of a dependency manager - listing and removing installed packages.
What is the best way of finding out what's installed, and what is the preferred way of removing installed packages? Are there any files that need to be updated if I remove packages manually (e.g. by rm /usr/local/lib/python2.6/dist-packages/my_installed_pkg.egg or similar)? | How do I remove packages installed with Python's easy_install? | 1 | 0 | 0 | 547,972 |
1,231,688 | 2009-08-05T07:33:00.000 | 193 | 0 | 1 | 0 | python,packages,setuptools,easy-install | 1,233,282 | 13 | false | 0 | 0 | To uninstall an .egg you need to rm -rf the egg (it might be a directory) and remove the matching line from site-packages/easy-install.pth | 4 | 713 | 0 | Python's easy_install makes installing new packages extremely convenient. However, as far as I can tell, it doesn't implement the other common features of a dependency manager - listing and removing installed packages.
What is the best way of finding out what's installed, and what is the preferred way of removing installed packages? Are there any files that need to be updated if I remove packages manually (e.g. by rm /usr/local/lib/python2.6/dist-packages/my_installed_pkg.egg or similar)? | How do I remove packages installed with Python's easy_install? | 1 | 0 | 0 | 547,972 |
1,231,688 | 2009-08-05T07:33:00.000 | 0 | 0 | 1 | 0 | python,packages,setuptools,easy-install | 49,375,186 | 13 | false | 0 | 0 | This worked for me. It's similar to previous answers but the path to the packages is different.
sudo easy_install -m
sudo rm -rf /Library/Python/2.7/site-packages/.egg
Plaform: MacOS High Sierra version 10.13.3 | 4 | 713 | 0 | Python's easy_install makes installing new packages extremely convenient. However, as far as I can tell, it doesn't implement the other common features of a dependency manager - listing and removing installed packages.
What is the best way of finding out what's installed, and what is the preferred way of removing installed packages? Are there any files that need to be updated if I remove packages manually (e.g. by rm /usr/local/lib/python2.6/dist-packages/my_installed_pkg.egg or similar)? | How do I remove packages installed with Python's easy_install? | 0 | 0 | 0 | 547,972 |
1,231,688 | 2009-08-05T07:33:00.000 | 3 | 0 | 1 | 0 | python,packages,setuptools,easy-install | 26,481,670 | 13 | false | 0 | 0 | For me only deleting this file : easy-install.pth
worked, rest pip install django==1.3.7 | 4 | 713 | 0 | Python's easy_install makes installing new packages extremely convenient. However, as far as I can tell, it doesn't implement the other common features of a dependency manager - listing and removing installed packages.
What is the best way of finding out what's installed, and what is the preferred way of removing installed packages? Are there any files that need to be updated if I remove packages manually (e.g. by rm /usr/local/lib/python2.6/dist-packages/my_installed_pkg.egg or similar)? | How do I remove packages installed with Python's easy_install? | 0.046121 | 0 | 0 | 547,972 |
1,231,853 | 2009-08-05T08:22:00.000 | 3 | 0 | 1 | 0 | python,mercurial,ironpython | 1,231,883 | 4 | false | 0 | 0 | Mercurial bundles the necessary python binaries within it, I believe. | 2 | 8 | 0 | I have Mercurial 1.3 installed on my Windows 7 machine. I don't have python installed, but Mercurial seems to be OK with that.
How does it work?
Also, is it possible to force Mercurial run on IronPython and will it be compatible?
Thank you. | How does mercurial work without Python installed? | 0.148885 | 0 | 0 | 1,764 |
1,231,853 | 2009-08-05T08:22:00.000 | 6 | 0 | 1 | 0 | python,mercurial,ironpython | 1,283,908 | 4 | false | 0 | 0 | Others have answered the first question -- let me give a guess about the second part.
Mercurial will normally use some C extensions for speed. You cannot use those with IronPython.
But we also ship pure Python versions of these modules, and depending on how much IronPython implements of a standard Python 2.4 environment, those modules could be compatible. I have seen reports on IRC about Jython (the Java port of Python) being able to do a few operations using the pure modules. You should download Mercurial and take a look at the mercurial/pure folder. These modules simply has to be moved up one directory level to be found, the setup.py script can do this if you pass the --pure flag. Please see its source or come talk with us on the Mercurial mailinglist/IRC. | 2 | 8 | 0 | I have Mercurial 1.3 installed on my Windows 7 machine. I don't have python installed, but Mercurial seems to be OK with that.
How does it work?
Also, is it possible to force Mercurial run on IronPython and will it be compatible?
Thank you. | How does mercurial work without Python installed? | 1 | 0 | 0 | 1,764 |
1,233,448 | 2009-08-05T14:00:00.000 | -2 | 0 | 1 | 0 | python,syntax,lambda | 57,386,600 | 20 | false | 0 | 0 | because a lambda function is supposed to be one-lined, as its the simplest form of a function, an entrance, then return | 1 | 434 | 0 | I've heard it said that multiline lambdas can't be added in Python because they would clash syntactically with the other syntax constructs in Python. I was thinking about this on the bus today and realized I couldn't think of a single Python construct that multiline lambdas clash with. Given that I know the language pretty well, this surprised me.
Now, I'm sure Guido had a reason for not including multiline lambdas in the language, but out of curiosity: what's a situation where including a multiline lambda would be ambiguous? Is what I've heard true, or is there some other reason that Python doesn't allow multiline lambdas? | No Multiline Lambda in Python: Why not? | -0.019997 | 0 | 0 | 257,943 |
1,234,292 | 2009-08-05T16:23:00.000 | 0 | 0 | 0 | 1 | python,sockets,twisted,twisted.words | 1,236,382 | 1 | true | 0 | 0 | ok, for sorting out this issue I have set a __del__ method in the protocol class and I am now logging protocol instances that have not been garbage collected within 1 minute from the time the client has disconnected.
If anybody has any better solution I'll still be glad to hear about it but so far I have already fixed a few potential memory leaks using this log.
Thanks! | 1 | 4 | 0 | I have a pretty intensive chat socket server written in Twisted Python, I start it using internet.TCPServer with a factory and that factory references to a protocol object that handles all communications with the client.
How should I make sure a protocol instance completely destroys itself once a client has disconnected?
I've got a function named connectionLost that is fired up once a client disconnects and I try stopping all activity right there but I suspect some reactor stuff (like twisted.words instances) keep running for obsolete protocol instances.
What would be the best approach to handle this?
Thanks! | In Twisted Python - Make sure a protocol instance would be completely deallocated | 1.2 | 0 | 1 | 721 |
1,235,417 | 2009-08-05T19:59:00.000 | 4 | 0 | 0 | 0 | python,windows,gtk,pygtk | 1,235,424 | 2 | false | 0 | 1 | Just call the set_deletable with False on the window in question. It will work as long as GTK can convince the window manager to make the window unclosable. | 1 | 4 | 0 | For example, graying out the "X" on windows systems. | In GTK, how do I make a window unable to be closed? | 0.379949 | 0 | 0 | 721 |
1,235,777 | 2009-08-05T21:10:00.000 | 1 | 0 | 0 | 0 | python,django,centos | 1,252,372 | 2 | true | 1 | 0 | Didn't we solve this for you in IRC the other day? If not, there was someone with the same OS and vague problem description.
Turned out to be a third-party app causing the problem, not the newly added one (which a review of the trackback proved if read carefully) | 1 | 0 | 0 | i'm running on wsgi on centos 5...
i've recently updated locally from 1.0 to 1.1
I updated the server using svn update
now when I apply a new app developed locally to the server it returns with a 500 error.
all i'm doing is python manage.py startapp appname
adding the app into installed_apps in the settings file and uploading
this then causes a 500 error... anything that would be causing this? | new django app's from 1.1 causing 500 error | 1.2 | 0 | 0 | 301 |
1,236,060 | 2009-08-05T22:16:00.000 | 2 | 0 | 1 | 0 | python,debugging,visual-c++ | 2,190,931 | 5 | false | 0 | 0 | This works also when linking with static libraries. I made a copy of python26.lib, and renamed it python26_d.lib. I commented out the line #define PY_DEBUG in pyconfig.h. Also changed the pragma to "pragma comment(lib,"python26.lib")" on line 332. Voila! It worked. | 1 | 22 | 0 | Python rather stupidly has a pragma directive in its include files that forces a link against python26_d.lib when the DEBUG preprocessor variable is defined. This is a problem because the python installer doesn't come with python26_d.lib! So I can't build applications in MSVC in debug mode. If I temporarily #undef DEBUG for just one file I get many complaints about inconsistent DLL linkage. If I change the pragma in pythons include file I get undefined references to various debug functions.
I have tried compiling my own version of python but its somehow different enough from the python that gets distributed that I can't use my modules with apps built with the vanilla version of python
Can anyone give me any advice on how to get round this? | Compiling python modules with DEBUG defined on MSVC | 0.07983 | 0 | 0 | 10,281 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.