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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
35,922 | 2008-08-30T12:19:00.000 | 1 | 0 | 0 | 0 | python,user-interface | 36,761 | 5 | false | 0 | 1 | I use pyGtk. I think wxPython is nice but it's too limited, and PyQt is, well, Qt. =) | 1 | 19 | 0 | I've played around with GTK, TK, wxPython, Cocoa, curses and others. They are are fairly horrible to use.. GTK/TK/wx/curses all seem to basically be direct-ports of the appropriate C libraries, and Cocoa basically mandates using both PyObjC and Interface Builder, both of which I dislike..
The Shoes GUI library for Ruby... | Are there any "nice to program" GUI toolkits for Python? | 0.039979 | 0 | 0 | 10,824 |
36,647 | 2008-08-31T05:07:00.000 | 1 | 1 | 0 | 0 | python,unit-testing | 1,310,119 | 9 | false | 0 | 0 | I recommend Nose.
After the reasonable simple installation, you just have to run "nosetests" in your project folder and Nose will find all your tests and run them. I also like the collection of plugins (coverage, GAE, etc.) and the abilty to call Nose directly from within my Python scripts. | 3 | 20 | 0 | Does Python have a unit testing framework compatible with the standard xUnit style of test framework? If so, what is it, where is it, and is it any good? | Unit tests in Python | 0.022219 | 0 | 0 | 8,490 |
36,647 | 2008-08-31T05:07:00.000 | 0 | 1 | 0 | 0 | python,unit-testing | 2,194,729 | 9 | false | 0 | 0 | nose seems to be the best combination of flexibility and convenience. It runs unittests, doctests, coverage (with an extension) and py.test-like tests from one framework and does so admirably. It has enough popularity that it has had some IDE integration done as well for Komodo Edit and I wouldn't be surprised to see... | 3 | 20 | 0 | Does Python have a unit testing framework compatible with the standard xUnit style of test framework? If so, what is it, where is it, and is it any good? | Unit tests in Python | 0 | 0 | 0 | 8,490 |
36,647 | 2008-08-31T05:07:00.000 | 2 | 1 | 0 | 0 | python,unit-testing | 36,654 | 9 | false | 0 | 0 | @Greg: PyUnit is included in the standard library as unittest | 3 | 20 | 0 | Does Python have a unit testing framework compatible with the standard xUnit style of test framework? If so, what is it, where is it, and is it any good? | Unit tests in Python | 0.044415 | 0 | 0 | 8,490 |
37,486 | 2008-09-01T05:25:00.000 | 0 | 0 | 1 | 0 | python,html | 38,646 | 8 | false | 1 | 0 | Looking at the amount of sense people are demonstrating in other answers here, I'd say that using a regex probably isn't the best idea for your situation. Go for something tried and tested, and treat my previous answer as a demonstration that regexes need not be that scary. | 2 | 18 | 0 | Because regular expressions scare me, I'm trying to find a way to remove all HTML tags and resolve HTML entities from a string in Python. | Filter out HTML tags and resolve entities in python | 0 | 0 | 0 | 25,958 |
37,486 | 2008-09-01T05:25:00.000 | 0 | 0 | 1 | 0 | python,html | 37,604 | 8 | false | 1 | 0 | Regular expressions are not scary, but writing your own regexes to strip HTML is a sure path to madness (and it won't work, either). Follow the path of wisdom, and use one of the many good HTML-parsing libraries.
Lucas' example is also broken because "sub" is not a method of a Python string. You'd have to "import re"... | 2 | 18 | 0 | Because regular expressions scare me, I'm trying to find a way to remove all HTML tags and resolve HTML entities from a string in Python. | Filter out HTML tags and resolve entities in python | 0 | 0 | 0 | 25,958 |
38,197 | 2008-09-01T17:40:00.000 | 8 | 0 | 1 | 1 | python,subprocess | 38,222 | 3 | true | 0 | 0 | Now, I'm not saying that this is the greatest name in the world, but here was the idea as I understand it.
Originally, the popen family was in the os module and was an implementation of the venerable posix popen. The movement to the subprocess module would have been an opportune time to rename them, but I guess that k... | 2 | 4 | 0 | The primary class in the subprocess module is name Popen, and represents a subprocess. Popen sounds like someone was trying to force the name to follow some function naming format, rather than chosing a name that actually represents what the object is. Does anyone know why it was chosen over something simple like, say... | Why is the subprocess.Popen class not named Subprocess? | 1.2 | 0 | 0 | 691 |
38,197 | 2008-09-01T17:40:00.000 | -1 | 0 | 1 | 1 | python,subprocess | 38,202 | 3 | false | 0 | 0 | I suppose the name was chosen because the functionality subprocess is replacing was formerly in the os module as the os.popen function. There could be even ways to automate migration between the two. | 2 | 4 | 0 | The primary class in the subprocess module is name Popen, and represents a subprocess. Popen sounds like someone was trying to force the name to follow some function naming format, rather than chosing a name that actually represents what the object is. Does anyone know why it was chosen over something simple like, say... | Why is the subprocess.Popen class not named Subprocess? | -0.066568 | 0 | 0 | 691 |
39,104 | 2008-09-02T09:40:00.000 | 19 | 0 | 1 | 0 | python,distutils | 9,918,496 | 4 | false | 0 | 0 | Use pkgutil.get_data. It’s the cousin of pkg_resources.resource_stream, but in the standard library, and should work with flat filesystem installs as well as zipped packages and other importers. | 2 | 32 | 0 | I've written a Python package that includes a bsddb database of pre-computed values for one of the more time-consuming computations. For simplicity, my setup script installs the database file in the same directory as the code which accesses the database (on Unix, something like /usr/lib/python2.5/site-packages/mypacka... | Finding a file in a Python module distribution | 1 | 1 | 0 | 28,993 |
39,104 | 2008-09-02T09:40:00.000 | 3 | 0 | 1 | 0 | python,distutils | 39,295 | 4 | false | 0 | 0 | That's probably the way to do it, without resorting to something more advanced like using setuptools to install the files where they belong.
Notice there's a problem with that approach, because on OSes with real a security framework (UNIXes, etc.) the user running your script might not have the rights to access the DB ... | 2 | 32 | 0 | I've written a Python package that includes a bsddb database of pre-computed values for one of the more time-consuming computations. For simplicity, my setup script installs the database file in the same directory as the code which accesses the database (on Unix, something like /usr/lib/python2.5/site-packages/mypacka... | Finding a file in a Python module distribution | 0.148885 | 1 | 0 | 28,993 |
39,847 | 2008-09-02T15:46:00.000 | 0 | 0 | 1 | 1 | python,c,cross-platform,posix,scripting | 39,865 | 4 | false | 0 | 0 | You know, you should look at static linking.
These days, we all have HUGE hard drives, and a few extra megabytes (for carrying around libc and what not) is really not that big a deal anymore.
You could also try running your applications in chroot() jails and distributing those. | 4 | 2 | 0 | I write tools that are used in a shared workspace. Since there are multiple OS's working in this space, we generally use Python and standardize the version that is installed across machines. However, if I wanted to write some things in C, I was wondering if maybe I could have the application wrapped in a Python script,... | Using C in a shared multi-platform POSIX environment | 0 | 0 | 0 | 293 |
39,847 | 2008-09-02T15:46:00.000 | 1 | 0 | 1 | 1 | python,c,cross-platform,posix,scripting | 39,878 | 4 | false | 0 | 0 | Also, you could use autoconf and distribute your application in source form only. :) | 4 | 2 | 0 | I write tools that are used in a shared workspace. Since there are multiple OS's working in this space, we generally use Python and standardize the version that is installed across machines. However, if I wanted to write some things in C, I was wondering if maybe I could have the application wrapped in a Python script,... | Using C in a shared multi-platform POSIX environment | 0.049958 | 0 | 0 | 293 |
39,847 | 2008-09-02T15:46:00.000 | 2 | 0 | 1 | 1 | python,c,cross-platform,posix,scripting | 40,367 | 4 | false | 0 | 0 | Launching a Python interpreter instance just to select the right binary to run would be much heavier than you need. I'd distribute a shell .rc file which provides aliases.
In /shared/bin, you put the various binaries: /shared/bin/toolname-mac, /shared/bin/toolname-debian-x86, /shared/bin/toolname-netbsd-dreamcast, etc... | 4 | 2 | 0 | I write tools that are used in a shared workspace. Since there are multiple OS's working in this space, we generally use Python and standardize the version that is installed across machines. However, if I wanted to write some things in C, I was wondering if maybe I could have the application wrapped in a Python script,... | Using C in a shared multi-platform POSIX environment | 0.099668 | 0 | 0 | 293 |
39,847 | 2008-09-02T15:46:00.000 | 0 | 0 | 1 | 1 | python,c,cross-platform,posix,scripting | 39,871 | 4 | false | 0 | 0 | Depending on your mix os OSes, you might be better off creating packages for each class of system.
Alternatively, if they all share the same ABI and hardware architecture, you could also compile static binaries. | 4 | 2 | 0 | I write tools that are used in a shared workspace. Since there are multiple OS's working in this space, we generally use Python and standardize the version that is installed across machines. However, if I wanted to write some things in C, I was wondering if maybe I could have the application wrapped in a Python script,... | Using C in a shared multi-platform POSIX environment | 0 | 0 | 0 | 293 |
41,701 | 2008-09-03T13:48:00.000 | 3 | 0 | 1 | 0 | python,tuples | 41,721 | 9 | false | 0 | 0 | Perhaps this is overkill for your case, but I would be tempted to create a "Job" class that takes the tuple as its constructor argument and has respective properties on it. I'd then pass instances of this class around instead. | 1 | 13 | 0 | I have a method in my Python code that returns a tuple - a row from a SQL query. Let's say it has three fields: (jobId, label, username)
For ease of passing it around between functions, I've been passing the entire tuple as a variable called 'job'. Eventually, however, I want to get at the bits, so I've been using code... | Splitting tuples in Python - best practice? | 0.066568 | 0 | 0 | 9,634 |
42,034 | 2008-09-03T16:13:00.000 | 65 | 0 | 1 | 0 | python,tuples | 42,048 | 11 | true | 0 | 0 | Tuples are used whenever you want to return multiple results from a function.
Since they're immutable, they can be used as keys for a dictionary (lists can't). | 5 | 56 | 0 | I am learning Python for a class now, and we just covered tuples as one of the data types. I read the Wikipedia page on it, but, I could not figure out where such a data type would be useful in practice. Can I have some examples, perhaps in Python, where an immutable set of numbers would be needed? How is this differen... | What is a tuple useful for? | 1.2 | 0 | 0 | 46,193 |
42,034 | 2008-09-03T16:13:00.000 | 2 | 0 | 1 | 0 | python,tuples | 42,049 | 11 | false | 0 | 0 | I find them useful when you always deal with two or more objects as a set. | 5 | 56 | 0 | I am learning Python for a class now, and we just covered tuples as one of the data types. I read the Wikipedia page on it, but, I could not figure out where such a data type would be useful in practice. Can I have some examples, perhaps in Python, where an immutable set of numbers would be needed? How is this differen... | What is a tuple useful for? | 0.036348 | 0 | 0 | 46,193 |
42,034 | 2008-09-03T16:13:00.000 | 0 | 0 | 1 | 0 | python,tuples | 51,200 | 11 | false | 0 | 0 | In addition to the places where they're syntactically required like the string % operation and for multiple return values, I use tuples as a form of lightweight classes. For example, suppose you have an object that passes out an opaque cookie to a caller from one method which is then passed into another method. A tup... | 5 | 56 | 0 | I am learning Python for a class now, and we just covered tuples as one of the data types. I read the Wikipedia page on it, but, I could not figure out where such a data type would be useful in practice. Can I have some examples, perhaps in Python, where an immutable set of numbers would be needed? How is this differen... | What is a tuple useful for? | 0 | 0 | 0 | 46,193 |
42,034 | 2008-09-03T16:13:00.000 | 4 | 0 | 1 | 0 | python,tuples | 42,060 | 11 | false | 0 | 0 | Tuples and lists have the same uses in general. Immutable data types in general have many benefits, mostly about concurrency issues.
So, when you have lists that are not volatile in nature and you need to guarantee that no consumer is altering it, you may use a tuple.
Typical examples are fixed data in an application l... | 5 | 56 | 0 | I am learning Python for a class now, and we just covered tuples as one of the data types. I read the Wikipedia page on it, but, I could not figure out where such a data type would be useful in practice. Can I have some examples, perhaps in Python, where an immutable set of numbers would be needed? How is this differen... | What is a tuple useful for? | 0.072599 | 0 | 0 | 46,193 |
42,034 | 2008-09-03T16:13:00.000 | 1 | 0 | 1 | 0 | python,tuples | 42,055 | 11 | false | 0 | 0 | A tuple is useful for storing multiple values.. As you note a tuple is just like a list that is immutable - e.g. once created you cannot add/remove/swap elements.
One benefit of being immutable is that because the tuple is fixed size it allows the run-time to perform certain optimizations. This is particularly benefici... | 5 | 56 | 0 | I am learning Python for a class now, and we just covered tuples as one of the data types. I read the Wikipedia page on it, but, I could not figure out where such a data type would be useful in practice. Can I have some examples, perhaps in Python, where an immutable set of numbers would be needed? How is this differen... | What is a tuple useful for? | 0.01818 | 0 | 0 | 46,193 |
42,690 | 2008-09-03T21:52:00.000 | 5 | 1 | 1 | 0 | .net,ironpython,ironruby,dynamic-language-runtime,dynamic-languages | 42,702 | 6 | false | 0 | 0 | Without getting into the relative merits of the languages (which would be an entire pissing contest in itself), IronPython (stable 1.1.1, beta 2.0) is further along in development than IronRuby (alpha) | 3 | 5 | 0 | I'd like to take some time to learn more about dynamic languages built on top of the DLR and I'm not sure which language would be better to learn.
Having limited time, I really only have time to look learn one of them.
Any opinions on which of the two (Iron Ruby or Iron Python) would be more useful in the long run? | Which Dynamic .NET language makes more sense to learn, Iron Ruby or Iron Python? | 0.16514 | 0 | 0 | 1,222 |
42,690 | 2008-09-03T21:52:00.000 | 1 | 1 | 1 | 0 | .net,ironpython,ironruby,dynamic-language-runtime,dynamic-languages | 467,185 | 6 | false | 0 | 0 | I just want to mention that there is also a DLR version of Javascript(JScript), which is my personal fav. If you are looking for a new language to learn for dlr use, I'd suggest ironpython as mentioned, it is farther along in terms of the dlr. Python is also fairly popular outside the dlr for gui programming, and of... | 3 | 5 | 0 | I'd like to take some time to learn more about dynamic languages built on top of the DLR and I'm not sure which language would be better to learn.
Having limited time, I really only have time to look learn one of them.
Any opinions on which of the two (Iron Ruby or Iron Python) would be more useful in the long run? | Which Dynamic .NET language makes more sense to learn, Iron Ruby or Iron Python? | 0.033321 | 0 | 0 | 1,222 |
42,690 | 2008-09-03T21:52:00.000 | 4 | 1 | 1 | 0 | .net,ironpython,ironruby,dynamic-language-runtime,dynamic-languages | 61,734 | 6 | true | 0 | 0 | If this is 'Which language runs better on the CLR,' then right now, IronPython wins hands down.
For the long term though, 'which language will teach me more, and serve me better in my career as a programmer', I would definitely say IronRuby (this would be true of CPython vs CRuby also)
Ruby will expose you to more 'con... | 3 | 5 | 0 | I'd like to take some time to learn more about dynamic languages built on top of the DLR and I'm not sure which language would be better to learn.
Having limited time, I really only have time to look learn one of them.
Any opinions on which of the two (Iron Ruby or Iron Python) would be more useful in the long run? | Which Dynamic .NET language makes more sense to learn, Iron Ruby or Iron Python? | 1.2 | 0 | 0 | 1,222 |
43,290 | 2008-09-04T07:36:00.000 | 4 | 0 | 0 | 0 | python,django,url,django-urls | 72,249 | 4 | false | 1 | 0 | Be aware that using reverse() requires that your urlconf module is 100% error free and can be processed - iow no ViewDoesNotExist errors or so, or you get the dreaded NoReverseMatch exception (errors in templates usually fail silently resulting in None). | 1 | 35 | 0 | In Django's template language, you can use {% url [viewname] [args] %} to generate a URL to a specific view with parameters. How can you programatically do the same in Python code?
What I need is to create a list of menu items where each item has name, URL, and an active flag (whether it's the current page or not). Th... | How to generate urls in django | 0.197375 | 0 | 0 | 37,259 |
43,368 | 2008-09-04T08:53:00.000 | 1 | 0 | 0 | 0 | python,sql,metadata,coupling,data-driven | 48,479 | 5 | false | 1 | 0 | I know that you specificity ask for a framework but I thought I would let you know about what I get up to here. I have just undergone converting my company's web application from a custom in-house ORM layer into sqlAlchemy so I am far from an expert but something that occurred to me was that sqlAlchemy has types for al... | 1 | 11 | 0 | I'm a firm believer of the heretic thought of tight coupling between the backend and frontend: I want existing, implied knowledge about a backend to be automatically made use of when generating user interfaces. E.g., if a VARCHAR column has a maximum with of 20 characters, there GUIs should automatically constrain the ... | A python web application framework for tight DB/GUI coupling? | 0.039979 | 0 | 0 | 2,785 |
43,580 | 2008-09-04T12:07:00.000 | 1 | 1 | 0 | 0 | python,mime | 11,101,343 | 18 | false | 0 | 0 | The mimetypes module just recognise an file type based on file extension. If you will try to recover a file type of a file without extension, the mimetypes will not works. | 3 | 242 | 0 | Let's say you want to save a bunch of files somewhere, for instance in BLOBs. Let's say you want to dish these files out via a web page and have the client automatically open the correct application/viewer.
Assumption: The browser figures out which application/viewer to use by the mime-type (content-type?) header in th... | How to find the mime type of a file in python? | 0.011111 | 0 | 0 | 233,034 |
43,580 | 2008-09-04T12:07:00.000 | 0 | 1 | 0 | 0 | python,mime | 51,510,950 | 18 | false | 0 | 0 | For byte Array type data you can use
magic.from_buffer(_byte_array,mime=True) | 3 | 242 | 0 | Let's say you want to save a bunch of files somewhere, for instance in BLOBs. Let's say you want to dish these files out via a web page and have the client automatically open the correct application/viewer.
Assumption: The browser figures out which application/viewer to use by the mime-type (content-type?) header in th... | How to find the mime type of a file in python? | 0 | 0 | 0 | 233,034 |
43,580 | 2008-09-04T12:07:00.000 | 11 | 1 | 0 | 0 | python,mime | 12,297,929 | 18 | false | 0 | 0 | There are 3 different libraries that wraps libmagic.
2 of them are available on pypi (so pip install will work):
filemagic
python-magic
And another, similar to python-magic is available directly in the latest libmagic sources, and it is the one you probably have in your linux distribution.
In Debian the package pytho... | 3 | 242 | 0 | Let's say you want to save a bunch of files somewhere, for instance in BLOBs. Let's say you want to dish these files out via a web page and have the client automatically open the correct application/viewer.
Assumption: The browser figures out which application/viewer to use by the mime-type (content-type?) header in th... | How to find the mime type of a file in python? | 1 | 0 | 0 | 233,034 |
43,775 | 2008-09-04T13:36:00.000 | 16 | 0 | 1 | 0 | python,math,modulo | 43,794 | 12 | true | 0 | 0 | By the way: most programming languages would disagree with Python and give the result -2. Depending on the interpretation of modulus this is correct. However, the most agreed-upon mathematical definition states that the modulus of a and b is the (strictly positive) rest r of the division of a / b. More precisely, 0 <= ... | 6 | 18 | 0 | Can you please tell me how much is (-2) % 5?
According to my Python interpreter is 3, but do you have a wise explanation for this?
I've read that in some languages the result can be machine-dependent, but I'm not sure though. | Modulus operation with negatives values - weird thing? | 1.2 | 0 | 0 | 11,706 |
43,775 | 2008-09-04T13:36:00.000 | 14 | 0 | 1 | 0 | python,math,modulo | 43,780 | 12 | false | 0 | 0 | Your Python interpreter is correct.
One (stupid) way of calculating a modulus is to subtract or add the modulus until the resulting value is between 0 and (modulus − 1).
e.g.:
13 mod 5 = (13 − 5) mod 5 = (13 − 10) mod 5 = 3
or in your case: −2 mod 5 = (−2 + 5) mod 5 = 3 | 6 | 18 | 0 | Can you please tell me how much is (-2) % 5?
According to my Python interpreter is 3, but do you have a wise explanation for this?
I've read that in some languages the result can be machine-dependent, but I'm not sure though. | Modulus operation with negatives values - weird thing? | 1 | 0 | 0 | 11,706 |
43,775 | 2008-09-04T13:36:00.000 | 0 | 0 | 1 | 0 | python,math,modulo | 43,781 | 12 | false | 0 | 0 | Well, -2 divided by 5 would be 0 with a remainder of 3. I don't believe that should be very platform dependent, but I've seen stranger things. | 6 | 18 | 0 | Can you please tell me how much is (-2) % 5?
According to my Python interpreter is 3, but do you have a wise explanation for this?
I've read that in some languages the result can be machine-dependent, but I'm not sure though. | Modulus operation with negatives values - weird thing? | 0 | 0 | 0 | 11,706 |
43,775 | 2008-09-04T13:36:00.000 | 4 | 0 | 1 | 0 | python,math,modulo | 43,785 | 12 | false | 0 | 0 | Well, 0 % 5 should be 0, right?
-1 % 5 should be 4 because that's the next allowed digit going in the reverse direction (i.e., it can't be 5, since that's out of range).
And following along by that logic, -2 must be 3.
The easiest way to think of how it will work is that you keep adding or subtracting 5 until the numbe... | 6 | 18 | 0 | Can you please tell me how much is (-2) % 5?
According to my Python interpreter is 3, but do you have a wise explanation for this?
I've read that in some languages the result can be machine-dependent, but I'm not sure though. | Modulus operation with negatives values - weird thing? | 0.066568 | 0 | 0 | 11,706 |
43,775 | 2008-09-04T13:36:00.000 | 0 | 0 | 1 | 0 | python,math,modulo | 43,799 | 12 | false | 0 | 0 | The result depends on the language. Python returns the sign of the divisor, where for example c# returns the sign of the dividend (ie. -2 % 5 returns -2 in c#). | 6 | 18 | 0 | Can you please tell me how much is (-2) % 5?
According to my Python interpreter is 3, but do you have a wise explanation for this?
I've read that in some languages the result can be machine-dependent, but I'm not sure though. | Modulus operation with negatives values - weird thing? | 0 | 0 | 0 | 11,706 |
43,775 | 2008-09-04T13:36:00.000 | 0 | 0 | 1 | 0 | python,math,modulo | 5,203,460 | 12 | false | 0 | 0 | There seems to be a common confusion between the terms "modulo" and "remainder".
In math, a remainder should always be defined consistent with the quotient, so that if a / b == c rem d then (c * b) + d == a. Depending on how you round your quotient, you get different remainders.
However, modulo should always give a res... | 6 | 18 | 0 | Can you please tell me how much is (-2) % 5?
According to my Python interpreter is 3, but do you have a wise explanation for this?
I've read that in some languages the result can be machine-dependent, but I'm not sure though. | Modulus operation with negatives values - weird thing? | 0 | 0 | 0 | 11,706 |
44,101 | 2008-09-04T16:15:00.000 | 1 | 0 | 1 | 0 | python,image,watermark | 44,132 | 11 | false | 0 | 0 | What about Exif? It's probably not as secure as what you're thinking, but most users don't even know it exists and if you make it that easy to read the watermark information those who care will still be able to do it anyway. | 4 | 12 | 0 | How do you insert invisible watermarks in images for copyright purposes? I'm looking for a python library.
What algorithm do you use? What about performance and efficiency? | invisible watermarks in images | 0.01818 | 0 | 0 | 13,301 |
44,101 | 2008-09-04T16:15:00.000 | 2 | 0 | 1 | 0 | python,image,watermark | 541,170 | 11 | false | 0 | 0 | Well, invisible watermarking is not that easy. Check digimarc, what money did they earn on it. There is no free C/Python code that a lonely genius has written a leave it for free usage. I've implemented my own algorithm and the name of the tool is SignMyImage. Google it if interested ... F> | 4 | 12 | 0 | How do you insert invisible watermarks in images for copyright purposes? I'm looking for a python library.
What algorithm do you use? What about performance and efficiency? | invisible watermarks in images | 0.036348 | 0 | 0 | 13,301 |
44,101 | 2008-09-04T16:15:00.000 | 6 | 0 | 1 | 0 | python,image,watermark | 44,217 | 11 | false | 0 | 0 | You might want to look into Steganography; that is hiding data inside of images. There are forms that won't get lost if you convert to a lossier format or even crop parts of the image out. | 4 | 12 | 0 | How do you insert invisible watermarks in images for copyright purposes? I'm looking for a python library.
What algorithm do you use? What about performance and efficiency? | invisible watermarks in images | 1 | 0 | 0 | 13,301 |
44,101 | 2008-09-04T16:15:00.000 | 0 | 0 | 1 | 0 | python,image,watermark | 44,221 | 11 | false | 0 | 0 | I was going to post an answer similar to Ugh. I would suggest putting a small TXT file describing the image source (and perhaps a small copyright statement, if one applies) into the image in a manner that is difficult to detect and break. | 4 | 12 | 0 | How do you insert invisible watermarks in images for copyright purposes? I'm looking for a python library.
What algorithm do you use? What about performance and efficiency? | invisible watermarks in images | 0 | 0 | 0 | 13,301 |
44,135 | 2008-09-04T16:36:00.000 | 1 | 0 | 0 | 0 | python,django | 427,643 | 6 | false | 1 | 0 | My current layout stems from me wanting to have a test-version of my sites. This means having two projects for every site, since they need different configurations, and forces me to move all the applications out of the projects.
I've created two folders: $APP_ROOT/devel and $APP_ROOT/prod. These contain all the apps.... | 1 | 44 | 0 | What is the best way to layout a large django project? The tutorials provide simple instructions for setting up apps, models, and views, but there is less information about how apps and projects should be broken down, how much sharing is allowable/necessary between apps in a typical project (obviously that is largely ... | Project design / FS layout for large django projects | 0.033321 | 0 | 0 | 7,973 |
44,834 | 2008-09-04T21:28:00.000 | 797 | 0 | 1 | 0 | python,syntax,namespaces | 44,842 | 11 | true | 0 | 0 | It's a list of public objects of that module, as interpreted by import *. It overrides the default of hiding everything that begins with an underscore. | 1 | 1,420 | 0 | I see __all__ in __init__.py files. What does it do? | What does __all__ mean in Python? | 1.2 | 0 | 0 | 473,666 |
45,507 | 2008-09-05T10:26:00.000 | 1 | 1 | 1 | 0 | python,favicon | 45,520 | 7 | false | 0 | 0 | I don't know if this applies for all cases, but on WinXP an .ico can be a bmp of size 16x16, 32x32 or 64x64. Just change the extension to ico from bmp and you're ready to go. | 1 | 32 | 0 | I'm looking to create favicon.ico files programatically from Python, but PIL only has support for reading ico files. | Is there a Python library for generating .ico files? | 0.028564 | 0 | 0 | 25,030 |
47,198 | 2008-09-06T02:22:00.000 | 0 | 1 | 1 | 0 | python,compatibility | 2,036,609 | 6 | false | 0 | 0 | If the project is going to be mainstream and will be run on Linux the only sensible choise is 2.4 - just because it is a pain to get anything else installed as default on Enterprise Linuxes.
In any case, any modern OS will/can have 2.4 or newer. | 2 | 15 | 0 | If I was going to start an open source project using Python what version should I use to ensure that the vast majority of users can use it on their system?
I'm the kind of person who quickly jumps to the next version (which I'll do when Python 3 comes out) but many people may be more conservative if their current versi... | Which Version of Python to Use for Maximum Compatibility | 0 | 0 | 0 | 3,460 |
47,198 | 2008-09-06T02:22:00.000 | 1 | 1 | 1 | 0 | python,compatibility | 47,264 | 6 | false | 0 | 0 | You can use different versions of python on each machine.
Coding something new, I would not use anything less than python2.5. You can do apt-get install python2.5 on stock debian stable.
For windows, don't really worry about it. It's very easy to install the python2.5 msi.
If the users can't be bothered to do that, ... | 2 | 15 | 0 | If I was going to start an open source project using Python what version should I use to ensure that the vast majority of users can use it on their system?
I'm the kind of person who quickly jumps to the next version (which I'll do when Python 3 comes out) but many people may be more conservative if their current versi... | Which Version of Python to Use for Maximum Compatibility | 0.033321 | 0 | 0 | 3,460 |
47,701 | 2008-09-06T18:14:00.000 | 4 | 0 | 1 | 0 | python,debugging | 277,800 | 10 | false | 0 | 0 | My experience debugging multi-threaded programs in PyDev (Eclipse on Windows XP) is, threads created using thread.start_new_thread could not be hooked, but thread created using threading.Thread could be hooked. Hope the information is helpful. | 1 | 35 | 0 | I'm trying to debug a deadlock in a multi-threaded Python application after it has locked up. Is there a way to attach a debugger to inspect the state of the process?
Edit: I'm attempting this on Linux, but it would be great if there were a cross-platform solution. It's Python after all :) | Is there a way to attach a debugger to a multi-threaded Python process? | 0.07983 | 0 | 0 | 34,732 |
47,953 | 2008-09-06T23:35:00.000 | 1 | 1 | 1 | 1 | python,zip,packaging,software-distribution,egg | 138,090 | 6 | false | 0 | 0 | For simple Python programs, you probably don't need to use eggs. Distributing the raw .py files should suffice; it's like distributing source files for GNU/Linux. You can also use the various OS "packagers" (like py2exe or py2app) to create .exe, .dmg, or other files for different operating systems.
More complex progra... | 3 | 27 | 0 | I've read some about .egg files and I've noticed them in my lib directory but what are the advantages/disadvantages of using then as a developer? | What are the advantages of packaging your python library/application as an .egg file? | 0.033321 | 0 | 0 | 10,471 |
47,953 | 2008-09-06T23:35:00.000 | 1 | 1 | 1 | 1 | python,zip,packaging,software-distribution,egg | 137,903 | 6 | false | 0 | 0 | Whatever you do, do not stop distributing your application, also, as a tarball, as that is the easiest packagable format for operating systems with a package sysetem. | 3 | 27 | 0 | I've read some about .egg files and I've noticed them in my lib directory but what are the advantages/disadvantages of using then as a developer? | What are the advantages of packaging your python library/application as an .egg file? | 0.033321 | 0 | 0 | 10,471 |
47,953 | 2008-09-06T23:35:00.000 | 4 | 1 | 1 | 1 | python,zip,packaging,software-distribution,egg | 47,958 | 6 | false | 0 | 0 | Eggs are a pretty good way to distribute python apps. Think of it as a platform independent .deb file that will install all dependencies and whatnot. The advantage is that it's easy to use for the end user. The disadvantage are that it can be cumbersome to package your app up as a .egg file.
You should also offer an... | 3 | 27 | 0 | I've read some about .egg files and I've noticed them in my lib directory but what are the advantages/disadvantages of using then as a developer? | What are the advantages of packaging your python library/application as an .egg file? | 0.132549 | 0 | 0 | 10,471 |
48,123 | 2008-09-07T04:00:00.000 | 1 | 0 | 1 | 0 | python,gtk,pygtk,glade,gtk2 | 751,707 | 11 | false | 0 | 1 | Personally I would recommend coding it out instead of using Glade. I'm still learning python and pyGtk but I will say that writing out the UI by hand gave me a lot of insight on how things work under the hood.
Once you have it learned I'd say to give glade, or other UI designers a try but definitely learn how to do it... | 8 | 32 | 0 | I've been learning python for a while now with some success. I even managed to create one or two (simple) programs using PyGtk + Glade.
The thing is: I am not sure if the best way to use GTK with python is by building the interfaces using Glade.
I was wondering if the more experienced ones among us (remember, I'm just ... | Glade or no glade: What is the best way to use PyGtk? | 0.01818 | 0 | 0 | 8,539 |
48,123 | 2008-09-07T04:00:00.000 | 1 | 0 | 1 | 0 | python,gtk,pygtk,glade,gtk2 | 199,167 | 11 | false | 0 | 1 | For quick and simple screens I use Glade. But for anything that needs finer levels of control, I create a custom classes for what I actually need (this is important, because it's too easy to get carried away with generalisations).
With a skinny applications specific classes, I can rapidly change the look and feel appl... | 8 | 32 | 0 | I've been learning python for a while now with some success. I even managed to create one or two (simple) programs using PyGtk + Glade.
The thing is: I am not sure if the best way to use GTK with python is by building the interfaces using Glade.
I was wondering if the more experienced ones among us (remember, I'm just ... | Glade or no glade: What is the best way to use PyGtk? | 0.01818 | 0 | 0 | 8,539 |
48,123 | 2008-09-07T04:00:00.000 | 5 | 0 | 1 | 0 | python,gtk,pygtk,glade,gtk2 | 106,889 | 11 | false | 0 | 1 | I started out using glade, but soon moved to just doing everything in code. Glade is nice for simple things, and it's good when you're learning how GTK organizes the widgets (how things are packed, etc). Constructing everything in code, however, you have much more flexibility. Plus, you don't have the glade dependency. | 8 | 32 | 0 | I've been learning python for a while now with some success. I even managed to create one or two (simple) programs using PyGtk + Glade.
The thing is: I am not sure if the best way to use GTK with python is by building the interfaces using Glade.
I was wondering if the more experienced ones among us (remember, I'm just ... | Glade or no glade: What is the best way to use PyGtk? | 0.090659 | 0 | 0 | 8,539 |
48,123 | 2008-09-07T04:00:00.000 | 2 | 0 | 1 | 0 | python,gtk,pygtk,glade,gtk2 | 305,667 | 11 | false | 0 | 1 | I recommend using Glade for rapid development, but not for learning. Why? because some times you will need to tune up some widgets in order to work as you want they to work, and if you don't really know/understand the properties attributes of every widget then you will be in troubles. | 8 | 32 | 0 | I've been learning python for a while now with some success. I even managed to create one or two (simple) programs using PyGtk + Glade.
The thing is: I am not sure if the best way to use GTK with python is by building the interfaces using Glade.
I was wondering if the more experienced ones among us (remember, I'm just ... | Glade or no glade: What is the best way to use PyGtk? | 0.036348 | 0 | 0 | 8,539 |
48,123 | 2008-09-07T04:00:00.000 | 4 | 0 | 1 | 0 | python,gtk,pygtk,glade,gtk2 | 107,959 | 11 | false | 0 | 1 | I usually start with Glade until I come to a point where it doesn't have the features I need, e.g. creating a wizard. As long as I'm using the standard widgets that Glade provides, there's really no reason to hand-code the GUI.
The more comfortable I become with how Glade formats the code, the better my hand-coding bec... | 8 | 32 | 0 | I've been learning python for a while now with some success. I even managed to create one or two (simple) programs using PyGtk + Glade.
The thing is: I am not sure if the best way to use GTK with python is by building the interfaces using Glade.
I was wondering if the more experienced ones among us (remember, I'm just ... | Glade or no glade: What is the best way to use PyGtk? | 0.072599 | 0 | 0 | 8,539 |
48,123 | 2008-09-07T04:00:00.000 | 2 | 0 | 1 | 0 | python,gtk,pygtk,glade,gtk2 | 2,149,087 | 11 | false | 0 | 1 | First, start to put this in perspective.
You will be using GTK. This is a huge C library built in 1993 using the best traditions of 1970s coding style. It was built to help implement the GIMP, a Photoshop competitor wanna-be with user interface blunders of legend. A typical gui field might have forty or more paramet... | 8 | 32 | 0 | I've been learning python for a while now with some success. I even managed to create one or two (simple) programs using PyGtk + Glade.
The thing is: I am not sure if the best way to use GTK with python is by building the interfaces using Glade.
I was wondering if the more experienced ones among us (remember, I'm just ... | Glade or no glade: What is the best way to use PyGtk? | 0.036348 | 0 | 0 | 8,539 |
48,123 | 2008-09-07T04:00:00.000 | 5 | 0 | 1 | 0 | python,gtk,pygtk,glade,gtk2 | 54,313 | 11 | false | 0 | 1 | Glade is very useful for creating interfaces, it means you can easily change the GUI without doing much coding. You'll find that if you want to do anything useful (e.g. build a treeview) you will have to get familiar with various parts of the GTK documentation - in practice finding a good tutorial/examples. | 8 | 32 | 0 | I've been learning python for a while now with some success. I even managed to create one or two (simple) programs using PyGtk + Glade.
The thing is: I am not sure if the best way to use GTK with python is by building the interfaces using Glade.
I was wondering if the more experienced ones among us (remember, I'm just ... | Glade or no glade: What is the best way to use PyGtk? | 0.090659 | 0 | 0 | 8,539 |
48,123 | 2008-09-07T04:00:00.000 | 12 | 0 | 1 | 0 | python,gtk,pygtk,glade,gtk2 | 48,136 | 11 | false | 0 | 1 | Use GtkBuilder instead of Glade, it's integrated into Gtk itself instead of a separate library.
The main benefit of Glade is that it's much, much easier to create the interface. It's a bit more work to connect signal handlers, but I've never felt that matters much. | 8 | 32 | 0 | I've been learning python for a while now with some success. I even managed to create one or two (simple) programs using PyGtk + Glade.
The thing is: I am not sure if the best way to use GTK with python is by building the interfaces using Glade.
I was wondering if the more experienced ones among us (remember, I'm just ... | Glade or no glade: What is the best way to use PyGtk? | 1 | 0 | 0 | 8,539 |
49,137 | 2008-09-08T03:53:00.000 | 0 | 1 | 0 | 1 | c++,python,embedded-language | 69,672,216 | 7 | false | 0 | 0 | Using Inter Process Communication (IPC) over socket can be a possible solution. Use a local network socket to listen/trasfer commands between both. | 1 | 65 | 0 | I would like to call python script files from my c++ program.
I am not sure that the people I will distribute to will have python installed.
Basically I'm looking for a .lib file that I can use that has an Apache like distribution license. | Calling python from a c++ program for distribution | 0 | 0 | 0 | 100,997 |
49,146 | 2008-09-08T03:59:00.000 | 4 | 0 | 1 | 0 | python,exe,executable | 10,241,354 | 7 | false | 0 | 0 | Also known as Frozen Binaries but not the same as as the output of a true compiler- they run byte code through a virtual machine (PVM). Run the same as a compiled program just larger because the program is being compiled along with the PVM. Py2exe can freeze standalone programs that use the tkinter, PMW, wxPython, and ... | 2 | 115 | 0 | I've used several modules to make EXEs for Python, but I'm not sure if I'm doing it right.
How should I go about this, and why? Please base your answers on personal experience, and provide references where necessary. | How can I make an EXE file from a Python program? | 0.113791 | 0 | 0 | 289,620 |
49,146 | 2008-09-08T03:59:00.000 | 3 | 0 | 1 | 0 | python,exe,executable | 15,667,090 | 7 | false | 0 | 0 | Use cx_Freeze to make exe your python program | 2 | 115 | 0 | I've used several modules to make EXEs for Python, but I'm not sure if I'm doing it right.
How should I go about this, and why? Please base your answers on personal experience, and provide references where necessary. | How can I make an EXE file from a Python program? | 0.085505 | 0 | 0 | 289,620 |
49,195 | 2008-09-08T05:23:00.000 | 1 | 1 | 0 | 0 | python,c | 49,246 | 14 | false | 0 | 0 | C is a bridge onto itself.
K&R is the only programming language book you can read in one sitting and almost never pick it up again ... | 12 | 4 | 0 | The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.
So, what language should I learn to bridge between Python to C | What language should I learn as a bridge to C (and derivatives) | 0.014285 | 0 | 0 | 871 |
49,195 | 2008-09-08T05:23:00.000 | 5 | 1 | 0 | 0 | python,c | 49,285 | 14 | false | 0 | 0 | I generally agree with most of the others - There's not really a good stepping stone language.
It is, however, useful to understand what is difficult about learning C, which might help you understand what's making it difficult for you.
I'd say the things that would prove difficult in C for someone coming from PHP would... | 12 | 4 | 0 | The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.
So, what language should I learn to bridge between Python to C | What language should I learn as a bridge to C (and derivatives) | 0.071307 | 0 | 0 | 871 |
49,195 | 2008-09-08T05:23:00.000 | 0 | 1 | 0 | 0 | python,c | 49,237 | 14 | false | 0 | 0 | Java might actually be a good option here, believe it or not. It is strongly based on C/C++, so if you can get the syntax and the strong typing, picking up C might be easier. The benefit is you can learn the lower level syntax without having to learn pointers (since memory is managed for you just like in Python and P... | 12 | 4 | 0 | The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.
So, what language should I learn to bridge between Python to C | What language should I learn as a bridge to C (and derivatives) | 0 | 0 | 0 | 871 |
49,195 | 2008-09-08T05:23:00.000 | 0 | 1 | 0 | 0 | python,c | 49,248 | 14 | false | 0 | 0 | I think C++ is a good "bridge" to C. I learned C++ first at University, and since it's based on C you'll learn a lot of the same concepts - perhaps most notably pointers - but also Object Oriented Design. OO can be applied to all kinds of modern languages, so it's worth learning.
After learning C++, I found it wasn... | 12 | 4 | 0 | The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.
So, what language should I learn to bridge between Python to C | What language should I learn as a bridge to C (and derivatives) | 0 | 0 | 0 | 871 |
49,195 | 2008-09-08T05:23:00.000 | 1 | 1 | 0 | 0 | python,c | 49,245 | 14 | false | 0 | 0 | Forget Java - it is not going to bring you anywhere closer to C (you have allready proved that you don't have a problem learning new syntax).
Either read K&R or go one lower: Learn about the machine itself. The only tricky part in C is pointers and memory management (which is closely related to pointers, but also has a... | 12 | 4 | 0 | The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.
So, what language should I learn to bridge between Python to C | What language should I learn as a bridge to C (and derivatives) | 0.014285 | 0 | 0 | 871 |
49,195 | 2008-09-08T05:23:00.000 | 0 | 1 | 0 | 0 | python,c | 49,502 | 14 | false | 0 | 0 | Languages are easy to learn (especially one like C)... the hard part is learning the libraries and/or coding style of the language. For instance, I know C++ fairly well, but most C/C++ code I see confuses me because the naming conventions are so different from what I work with on a daily basis.
Anyway, I guess what I'... | 12 | 4 | 0 | The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.
So, what language should I learn to bridge between Python to C | What language should I learn as a bridge to C (and derivatives) | 0 | 0 | 0 | 871 |
49,195 | 2008-09-08T05:23:00.000 | 0 | 1 | 0 | 0 | python,c | 49,217 | 14 | false | 0 | 0 | I'm feeling your pain, I also learned PHP first and I'm trying to learn C++, it's not easy, and I am really struggling, It's been 2 years since I started on c++ and Still the extent of what I can do is cout, cin, and math.
If anyone reads this and wonders where to start, START LOWER. | 12 | 4 | 0 | The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.
So, what language should I learn to bridge between Python to C | What language should I learn as a bridge to C (and derivatives) | 0 | 0 | 0 | 871 |
49,195 | 2008-09-08T05:23:00.000 | 0 | 1 | 0 | 0 | python,c | 50,673 | 14 | false | 0 | 0 | Pascal! Close enough syntax, still requires you to do some memory management, but not as rough for beginners. | 12 | 4 | 0 | The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.
So, what language should I learn to bridge between Python to C | What language should I learn as a bridge to C (and derivatives) | 0 | 0 | 0 | 871 |
49,195 | 2008-09-08T05:23:00.000 | 0 | 1 | 0 | 0 | python,c | 49,295 | 14 | false | 0 | 0 | try to learn a language which you are comfortable with, try different approach and the basics. | 12 | 4 | 0 | The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.
So, what language should I learn to bridge between Python to C | What language should I learn as a bridge to C (and derivatives) | 0 | 0 | 0 | 871 |
49,195 | 2008-09-08T05:23:00.000 | 1 | 1 | 0 | 0 | python,c | 49,234 | 14 | false | 0 | 0 | Learning any language takes time, I always ensure I have a measurable goal; I set myself an objective, then start learning the language to achieve this objective, as opposed to trying to learn every nook and cranny of the language and syntax.
C is not easy, pointers can be hard to comprehend if you’re not coming assem... | 12 | 4 | 0 | The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.
So, what language should I learn to bridge between Python to C | What language should I learn as a bridge to C (and derivatives) | 0.014285 | 0 | 0 | 871 |
49,195 | 2008-09-08T05:23:00.000 | 15 | 1 | 0 | 0 | python,c | 49,202 | 14 | true | 0 | 0 | It's not clear why you need a bridge language. Why don't you start working with C directly? C is a very simple language itself. I think that hardest part for C learner is pointers and everything else related to memory management. Also C lang is oriented on structured programming, so you will need to learn how to implem... | 12 | 4 | 0 | The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.
So, what language should I learn to bridge between Python to C | What language should I learn as a bridge to C (and derivatives) | 1.2 | 0 | 0 | 871 |
49,195 | 2008-09-08T05:23:00.000 | 7 | 1 | 0 | 0 | python,c | 49,227 | 14 | false | 0 | 0 | The best place to start learning C is the book "The C Programming Language" by Kernighan and Ritchie.
You will recognise a lot of things from PHP, and you will be surprised how much PHP (and Perl, Python etc) do for you.
Oh and you also will need a C compiler, but i guess you knew that. | 12 | 4 | 0 | The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.
So, what language should I learn to bridge between Python to C | What language should I learn as a bridge to C (and derivatives) | 1 | 0 | 0 | 871 |
49,307 | 2008-09-08T08:25:00.000 | -2 | 0 | 1 | 0 | python,arrays,matlab,for-loop | 138,886 | 7 | false | 0 | 0 | for loops in MATLAB used to be slow, but this is not true anymore.
So vectorizing is not always the miracle solution. Just use the profiler, and tic and toc functions to help you identify possible bottlenecks. | 1 | 14 | 1 | Using the zip function, Python allows for loops to traverse multiple sequences in parallel.
for (x,y) in zip(List1, List2):
Does MATLAB have an equivalent syntax? If not, what is the best way to iterate over two parallel arrays at the same time using MATLAB? | Can parallel traversals be done in MATLAB just as in Python? | -0.057081 | 0 | 0 | 7,417 |
49,824 | 2008-09-08T14:36:00.000 | 47 | 1 | 1 | 0 | java,python | 49,953 | 5 | true | 0 | 0 | List comprehensions. I often find myself filtering/mapping lists, and being able to say [line.replace("spam","eggs") for line in open("somefile.txt") if line.startswith("nee")] is really nice.
Functions are first class objects. They can be passed as parameters to other functions, defined inside other function, and ha... | 2 | 29 | 0 | Besides the dynamic nature of Python (and the syntax), what are some of the major features of the Python language that Java doesn't have, and vice versa? | Java -> Python? | 1.2 | 0 | 0 | 11,654 |
49,824 | 2008-09-08T14:36:00.000 | 2 | 1 | 1 | 0 | java,python | 51,512 | 5 | false | 0 | 0 | Apart from what Eli Courtwright said:
I find iterators in Python more concise. You can use for i in something, and it works with pretty much everything. Yeah, Java has gotten better since 1.5, but for example you can iterate through a string in python with this same construct.
Introspection: In python you can get at r... | 2 | 29 | 0 | Besides the dynamic nature of Python (and the syntax), what are some of the major features of the Python language that Java doesn't have, and vice versa? | Java -> Python? | 0.07983 | 0 | 0 | 11,654 |
50,568 | 2008-09-08T20:16:00.000 | 3 | 0 | 0 | 0 | python,django,session,caching,mongodb | 100,464 | 5 | false | 1 | 0 | One thing that has to be considered when choosing session backend is "how often session data is modified"? Even sites with moderate traffic will suffer if session data is modified on each request, making many database trips to store and retrieve data.
In my previous work we used memcache as session backend exclusively ... | 3 | 38 | 0 | I'm looking at sessions in Django, and by default they are stored in the database. What are the benefits of filesystem and cache sessions and when should I use them? | Django Sessions | 0.119427 | 0 | 0 | 12,358 |
50,568 | 2008-09-08T20:16:00.000 | 1 | 0 | 0 | 0 | python,django,session,caching,mongodb | 326,046 | 5 | false | 1 | 0 | If the database have a DBA that isn't you, you may not be allowed to use a database-backed session (it being a front-end matter only). Until django supports easily merging data from several databases, so that you can have frontend-specific stuff like sessions and user-messages (the messages in django.contrib.auth are a... | 3 | 38 | 0 | I'm looking at sessions in Django, and by default they are stored in the database. What are the benefits of filesystem and cache sessions and when should I use them? | Django Sessions | 0.039979 | 0 | 0 | 12,358 |
50,568 | 2008-09-08T20:16:00.000 | 25 | 0 | 0 | 0 | python,django,session,caching,mongodb | 50,668 | 5 | false | 1 | 0 | The filesystem backend is only worth looking at if you're not going to use a database for any other part of your system. If you are using a database then the filesystem backend has nothing to recommend it.
The memcache backend is much quicker than the database backend, but you run the risk of a session being purged and... | 3 | 38 | 0 | I'm looking at sessions in Django, and by default they are stored in the database. What are the benefits of filesystem and cache sessions and when should I use them? | Django Sessions | 1 | 0 | 0 | 12,358 |
51,010 | 2008-09-09T00:28:00.000 | -1 | 0 | 1 | 0 | python,datetime,time | 108,603 | 7 | false | 0 | 0 | Retrieve the times in milliseconds and then do the subtraction. | 2 | 13 | 0 | I have 2 time values which have the type datetime.time. I want to find their difference. The obvious thing to do is t1 - t2, but this doesn't work. It works for objects of type datetime.datetime but not for datetime.time. So what is the best way to do this? | What is the simplest way to find the difference between 2 times in python? | -0.028564 | 0 | 0 | 10,861 |
51,010 | 2008-09-09T00:28:00.000 | -3 | 0 | 1 | 0 | python,datetime,time | 263,451 | 7 | false | 0 | 0 | Environment.TickCount seems to work well if you need something quick.
int start = Environment.TickCount
...DoSomething()
int elapsedtime = Environment.TickCount - start
Jon | 2 | 13 | 0 | I have 2 time values which have the type datetime.time. I want to find their difference. The obvious thing to do is t1 - t2, but this doesn't work. It works for objects of type datetime.datetime but not for datetime.time. So what is the best way to do this? | What is the simplest way to find the difference between 2 times in python? | -0.085505 | 0 | 0 | 10,861 |
51,233 | 2008-09-09T04:38:00.000 | 2 | 0 | 0 | 0 | python,html | 17,123,979 | 12 | false | 1 | 0 | soup.title.string actually returns a unicode string.
To convert that into normal string, you need to do
string=string.encode('ascii','ignore') | 1 | 86 | 0 | How can I retrieve the page title of a webpage (title html tag) using Python? | How can I retrieve the page title of a webpage using Python? | 0.033321 | 0 | 1 | 103,114 |
53,428 | 2008-09-10T04:49:00.000 | 0 | 0 | 0 | 0 | python,orm | 4,908,742 | 12 | false | 1 | 0 | I used Storm + SQLite for a small project, and was pretty happy with it until I added multiprocessing. Trying to use the database from multiple processes resulted in a "Database is locked" exception. I switched to SQLAlchemy, and the same code worked with no problems. | 3 | 236 | 0 | I'm evaluating and looking at using CherryPy for a project that's basically a JavaScript front-end from the client-side (browser) that talks to a Python web service on the back-end. So, I really need something fast and lightweight on the back-end that I can implement using Python that then speaks to the PostgreSQL DB v... | What are some good Python ORM solutions? | 0 | 0 | 0 | 178,152 |
53,428 | 2008-09-10T04:49:00.000 | -2 | 0 | 0 | 0 | python,orm | 2,510,845 | 12 | false | 1 | 0 | SQLAlchemy is very, very powerful. However it is not thread safe make sure you keep that in mind when working with cherrypy in thread-pool mode. | 3 | 236 | 0 | I'm evaluating and looking at using CherryPy for a project that's basically a JavaScript front-end from the client-side (browser) that talks to a Python web service on the back-end. So, I really need something fast and lightweight on the back-end that I can implement using Python that then speaks to the PostgreSQL DB v... | What are some good Python ORM solutions? | -0.033321 | 0 | 0 | 178,152 |
53,428 | 2008-09-10T04:49:00.000 | 1 | 0 | 0 | 0 | python,orm | 186,179 | 12 | false | 1 | 0 | There is no conceivable way that the unused features in Django will give a performance penalty. Might just come in handy if you ever decide to upscale the project. | 3 | 236 | 0 | I'm evaluating and looking at using CherryPy for a project that's basically a JavaScript front-end from the client-side (browser) that talks to a Python web service on the back-end. So, I really need something fast and lightweight on the back-end that I can implement using Python that then speaks to the PostgreSQL DB v... | What are some good Python ORM solutions? | 0.016665 | 0 | 0 | 178,152 |
53,543 | 2008-09-10T07:04:00.000 | 2 | 0 | 1 | 0 | python,ironpython,jython,cpython | 199,275 | 6 | false | 0 | 0 | I write code for CPython and IronPython but tip should work for Jython as well.
Basically, I write all the platform specific code in separate modules/packages and then import the appropriate one based on platform I'm running on. (see cdleary's comment above)
This is especially important when it comes to the differences... | 3 | 16 | 0 | Having tries to target two of these environments at the same time I can safely say the if you have to use a database etc. you end up having to write unique code for that environment. Have you got a great way to handle this situation? | What are some strategies to write python code that works in CPython, Jython and IronPython | 0.066568 | 0 | 0 | 1,296 |
53,543 | 2008-09-10T07:04:00.000 | 0 | 0 | 1 | 0 | python,ironpython,jython,cpython | 637,549 | 6 | false | 0 | 0 | There are two major issues at play here...
Firstly, to my knowledge, only CPython has RAII - you have to close your own resources in Jython, Ironpython, etc.
And Secondly, as has been mentioned, is thread safety. | 3 | 16 | 0 | Having tries to target two of these environments at the same time I can safely say the if you have to use a database etc. you end up having to write unique code for that environment. Have you got a great way to handle this situation? | What are some strategies to write python code that works in CPython, Jython and IronPython | 0 | 0 | 0 | 1,296 |
53,543 | 2008-09-10T07:04:00.000 | 1 | 0 | 1 | 0 | python,ironpython,jython,cpython | 342,835 | 6 | false | 0 | 0 | The #1 thing IMO: Focus on thread safety. CPython's GIL makes writing threadsafe code easy because only one thread can access the interpreter at a time. IronPython and Jython are a little less hand-holding though. | 3 | 16 | 0 | Having tries to target two of these environments at the same time I can safely say the if you have to use a database etc. you end up having to write unique code for that environment. Have you got a great way to handle this situation? | What are some strategies to write python code that works in CPython, Jython and IronPython | 0.033321 | 0 | 0 | 1,296 |
53,997 | 2008-09-10T13:12:00.000 | 0 | 0 | 0 | 1 | python,ajax,google-app-engine | 230,476 | 11 | false | 1 | 0 | I'm currently using JQuery for my GAE app and it works beautifully for me. I have a chart (google charts) that is dynamic and uses an Ajax call to grab a JSON string. It really seems to work fine for me. | 2 | 14 | 0 | I am trying to implement AJAX in my Google App Engine application, and so I am looking for a good AJAX framework that will help me. Anyone has any idea?
I am thinking about Google Web Toolkit, how good it is in terms of creating AJAX for Google App Engine? | Any good AJAX framework for Google App Engine apps? | 0 | 0 | 0 | 11,904 |
53,997 | 2008-09-10T13:12:00.000 | 3 | 0 | 0 | 1 | python,ajax,google-app-engine | 54,015 | 11 | false | 1 | 0 | I'd recommend looking into a pure javascript framework (probably Jquery) for your client-side code, and write JSON services in python- that seems to be the easiest / bestest way to go.
Google Web Toolkit lets you write the UI in Java and compile it to javascript. As Dave says, it may be a better choice where the backen... | 2 | 14 | 0 | I am trying to implement AJAX in my Google App Engine application, and so I am looking for a good AJAX framework that will help me. Anyone has any idea?
I am thinking about Google Web Toolkit, how good it is in terms of creating AJAX for Google App Engine? | Any good AJAX framework for Google App Engine apps? | 0.054491 | 0 | 0 | 11,904 |
54,867 | 2008-09-10T18:01:00.000 | 8 | 0 | 1 | 0 | python,class,oop,types,new-style-class | 16,295,402 | 8 | false | 0 | 0 | New style classes may use super(Foo, self) where Foo is a class and self is the instance.
super(type[, object-or-type])
Return a proxy object that delegates method calls to a parent or sibling class of type. This is useful for accessing inherited methods that have been overridden in a class. The search order is same a... | 2 | 1,091 | 0 | What is the difference between old style and new style classes in Python? When should I use one or the other? | What is the difference between old style and new style classes in Python? | 1 | 0 | 0 | 257,866 |
54,867 | 2008-09-10T18:01:00.000 | 41 | 0 | 1 | 0 | python,class,oop,types,new-style-class | 3,228,045 | 8 | false | 0 | 0 | Old style classes are still marginally faster for attribute lookup. This is not usually important, but it may be useful in performance-sensitive Python 2.x code:
In [3]: class A:
...: def __init__(self):
...: self.a = 'hi there'
...:
In [4]: class B(object):
...: def __init__(self):
...... | 2 | 1,091 | 0 | What is the difference between old style and new style classes in Python? When should I use one or the other? | What is the difference between old style and new style classes in Python? | 1 | 0 | 0 | 257,866 |
55,365 | 2008-09-10T21:32:00.000 | 6 | 0 | 1 | 0 | python,emacs,ide,keyboard | 56,008 | 3 | true | 0 | 0 | IDLE provides Emacs keybindings without having to install other software.
Open up the menu item Options -> Configure IDLE...
Go to Keys tab
In the drop down menu on the right
side of the dialog change the select
to "IDLE Classic Unix"
It's not the true emacs key bindings but you get the basics like movement, saving/... | 1 | 6 | 0 | I use Emacs primarily for coding Python but sometimes I use IDLE. Is there a way to change the key bindings easily in IDLE to match Emacs? | How can I get Emacs' key bindings in Python's IDLE? | 1.2 | 0 | 0 | 1,983 |
56,011 | 2008-09-11T08:18:00.000 | 1 | 0 | 1 | 0 | python,coding-style | 1,167,795 | 19 | false | 0 | 0 | I just use whatever strikes my fancy at the time; it's convenient to be able to switch between the two at a whim!
Of course, when quoting quote characetrs, switching between the two might not be so whimsical after all... | 12 | 718 | 0 | According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to use one over the other? | Single quotes vs. double quotes in Python | 0.010526 | 0 | 0 | 712,544 |
56,011 | 2008-09-11T08:18:00.000 | 3 | 0 | 1 | 0 | python,coding-style | 56,047 | 19 | false | 0 | 0 | I use double quotes in general, but not for any specific reason - Probably just out of habit from Java.
I guess you're also more likely to want apostrophes in an inline literal string than you are to want double quotes. | 12 | 718 | 0 | According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to use one over the other? | Single quotes vs. double quotes in Python | 0.031568 | 0 | 0 | 712,544 |
56,011 | 2008-09-11T08:18:00.000 | 0 | 0 | 1 | 0 | python,coding-style | 56,025 | 19 | false | 0 | 0 | Your team's taste or your project's coding guidelines.
If you are in a multilanguage environment, you might wish to encourage the use of the same type of quotes for strings that the other language uses, for instance. Else, I personally like best the look of ' | 12 | 718 | 0 | According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to use one over the other? | Single quotes vs. double quotes in Python | 0 | 0 | 0 | 712,544 |
56,011 | 2008-09-11T08:18:00.000 | 44 | 0 | 1 | 0 | python,coding-style | 56,210 | 19 | false | 0 | 0 | I'm with Will:
Double quotes for text
Single quotes for anything that behaves like an identifier
Double quoted raw string literals for regexps
Tripled double quotes for docstrings
I'll stick with that even if it means a lot of escaping.
I get the most value out of single quoted identifiers standing out because of t... | 12 | 718 | 0 | According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to use one over the other? | Single quotes vs. double quotes in Python | 1 | 0 | 0 | 712,544 |
56,011 | 2008-09-11T08:18:00.000 | -1 | 0 | 1 | 0 | python,coding-style | 3,179,675 | 19 | false | 0 | 0 | I use double quotes because I have been doing so for years in most languages (C++, Java, VB…) except Bash, because I also use double quotes in normal text and because I'm using a (modified) non-English keyboard where both characters require the shift key. | 12 | 718 | 0 | According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to use one over the other? | Single quotes vs. double quotes in Python | -0.010526 | 0 | 0 | 712,544 |
56,011 | 2008-09-11T08:18:00.000 | 26 | 0 | 1 | 0 | python,coding-style | 56,041 | 19 | false | 0 | 0 | If the string you have contains one, then you should use the other. For example, "You're able to do this", or 'He said "Hi!"'. Other than that, you should simply be as consistent as you can (within a module, within a package, within a project, within an organisation).
If your code is going to be read by people who wo... | 12 | 718 | 0 | According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to use one over the other? | Single quotes vs. double quotes in Python | 1 | 0 | 0 | 712,544 |
56,011 | 2008-09-11T08:18:00.000 | 0 | 0 | 1 | 0 | python,coding-style | 56,029 | 19 | false | 0 | 0 | None as far as I know. Although if you look at some code, " " is commonly used for strings of text (I guess ' is more common inside text than "), and ' ' appears in hashkeys and things like that. | 12 | 718 | 0 | According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to use one over the other? | Single quotes vs. double quotes in Python | 0 | 0 | 0 | 712,544 |
56,011 | 2008-09-11T08:18:00.000 | 3 | 0 | 1 | 0 | python,coding-style | 145,149 | 19 | false | 0 | 0 | Personally I stick with one or the other. It doesn't matter. And providing your own meaning to either quote is just to confuse other people when you collaborate. | 12 | 718 | 0 | According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to use one over the other? | Single quotes vs. double quotes in Python | 0.031568 | 0 | 0 | 712,544 |
56,011 | 2008-09-11T08:18:00.000 | 1 | 0 | 1 | 0 | python,coding-style | 629,106 | 19 | false | 0 | 0 | I chose to use double quotes because they are easier to see. | 12 | 718 | 0 | According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to use one over the other? | Single quotes vs. double quotes in Python | 0.010526 | 0 | 0 | 712,544 |
56,011 | 2008-09-11T08:18:00.000 | 0 | 0 | 1 | 0 | python,coding-style | 16,048,319 | 19 | false | 0 | 0 | I aim to minimize both pixels and surprise. I typically prefer ' in order to minimize pixels, but " instead if the string has an apostrophe, again to minimize pixels. For a docstring, however, I prefer """ over ''' because the latter is non-standard, uncommon, and therefore surprising. If now I have a bunch of strings ... | 12 | 718 | 0 | According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to use one over the other? | Single quotes vs. double quotes in Python | 0 | 0 | 0 | 712,544 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.